helptext /*********************************************** * File: createAdone.js * Author: Matt Fraser * Date: January 2009 * Purpose: Gives us a nice dynamic ad designer * ********************************************/ if (!document.getElementsByClassName) { document.getElementsByClassName = function (cn) { var rx = new RegExp("(?:^|\\s)" + cn+ "(?:$|\\s)"); var allT = document.getElementsByTagName("*"), allCN = [],ac="", i = 0, a; while (a = allT[i=i+1]) { ac=a.className; if ( ac && ac.indexOf(cn) !==-1) { if(ac===cn){ allCN[allCN.length] = a; continue; } rx.test(ac) ? (allCN[allCN.length] = a) : 0; } } return allCN; } } /* GLOBALS */ var form =""; var inputs = ""; var publication = ""; var publicationinputs = ""; var classes = ""; var classesoptions = ""; var classesinputs = ""; var titleText = ""; var bodyText = ""; var footerText = ""; var selectedpublication = ""; var selectedclass = ""; var caldiv = ""; var cal = ""; var datechooser = ""; var submitBtn = ""; var allpubserror = ""; var classmessage = "" //PVT var resp = ""; var badwords = ""; var helptext = ""; var helpimg = ""; var orighelptext = ""; var dealspans = {}; var maxchars = {}; var helptexts = {}; function urldecode(str) { str = str.replace(/\+/g, ' '); str = unescape(str); return str; } // 'Object Converter', converts an array to an object so we can // use the 'in' operator function oc(a) { var o = {}; for(var i=0;i\"Loading.\"Loading ...

"/* + element.innerHTML*/; } /* Updates global variables to keep track of which items have been selected */ function updateSelected(){ updateGlobals(); /* Get currently selected pub */ for(var i =0; i < publicationinputs.length; i++){ if (publicationinputs[i].checked){ selectedpublication = publicationinputs[i].value; break; } } /* Get currently selected classification */ for(var i =0; i firstdateindex + (dealspans[selectedpublication] - 1) || !(resp['alldates'][i] in oc(resp['pubdates']))){ cal.addRenderer(resp['alldates'][i],cal.renderOutOfBoundsDate); } } }else{ // Disable any dates that aren't on our list for(i=0; i'; $( msg ).insertBefore( "#instructions" ); establishEventListeners(); } var classmsg_callback = { success:updateClassmsgCallback } //PVT function updateClassificationMessage() { //PVT function for updating the classification message. var poststring = ""; var message = ""; poststring += "selectedclass="; poststring += selectedclass; YAHOO.util.Connect.asyncRequest('POST', 'updateClassificationMessage.php', classmsg_callback, poststring); } function updateDateMessage(){ updateGlobals(); updateClassificationMessage(); //PVT dates = get_cal_selected("#datepicker"); if(dates != '') { submitBtn.disabled = ''; allpubserror.style.display = 'none'; allpubserror.innerHTML = ' '; } else { submitBtn.disabled = 'disabled'; allpubserror.style.display = 'block'; allpubserror.innerHTML = 'You must select at least one run date.'; } } /*************************************************/ /* Forbidden Words */ /* (not used at this stage) */ /*************************************************/ // this gets run once we get our list of dates back var getforbiddenwordscallback = function callback(o){ alert('hi'); badwords = 'test'; } var failed = function failedcallback(o){ badwords = ''; } // this tells our ajax request which function to pass it's result to var getforbiddenwordscallback_def = { success: getforbiddenwordscallback, failure: failed, timeout: 1000 } function getForbiddenWordsInText(text){ poststring = "text=" + text; YAHOO.util.Connect.asyncRequest('post', 'getForbiddenWords.php', getforbiddenwordscallback_def, poststring); } /************************************************/ /* Form Validation / /************************************************/ function submitForm(){ updateGlobals(); updateSelected(); if(titleText.value == ''){ titleText.style.backgroundColor = "#fdd"; titleText.focus(); alert("You must enter some text for the title of your Ad."); return false; } titleText.style.backgroundColor = "#f0f0f0"; if(bodyText.value == ''){ bodyText.style.backgroundColor = "#fdd"; bodyText.focus(); alert("You must enter some text for the body of your Ad."); return false; } bodyText.style.backgroundColor = "#f0f0f0"; if(selectedpublication in maxchars){ var alltext = titleText.value + bodyText.value + footerText.value; if(alltext.length > maxchars[selectedpublication]){ titleText.style.backgroundColor = "#fdd"; bodyText.style.backgroundColor = "#fdd"; footerText.style.backgroundColor = "#fdd"; bodyText.focus(); alert("You have entered too much text. The '" + selectedpublication.replace(/\+/g, " ") + "' deal requires that you enter fewer than " + maxchars[selectedpublication] + " characters. If you have any questions, please ring our Classified Advertising Department on (03) 477-8000."); return false; } } titleText.style.backgroundColor = "#f0f0f0"; bodyText.style.backgroundColor = "#f0f0f0"; footerText.style.backgroundColor = "#f0f0f0"; if(selectedclass == ''){ alert('Please select a classification for your ad.'); return false; } var pubdates = []; // Build up a pubdates variable //dates = cal.getSelectedDates(); dates = get_cal_selected("#datepicker"); pubdates = []; for(j=0;j