var viewFormXMLHttp = createXMLHTTPObject(); function viewResultHandler(xmlHttpObject, viewid, responseHandler) { //alert('viewid='+viewid+',status='+xmlHttpObject.readyState+', response='+xmlHttpObject.responseText); if (xmlHttpObject.readyState == 4) { var responseData = xmlHttpObject.responseText.Trim(); if (!isControlPage(responseData)) { var container = getObject(viewid); if (container) { if (container.tagName == 'SELECT') { populateSelect(container, responseData); } else if (container.tagName == 'INPUT') { container.value=responseData; } else { container.innerHTML = responseData; } } if (responseHandler && responseHandler != viewResultHandler) { responseHandler.call(null, responseData); } } } } function viewLoad(params, viewid, responseHandler, loaderid) { params = (params) ? params : ""; viewid = (viewid) ? viewid : "subviewcontainer"; viewResponseHandler = function() { viewResultHandler(viewFormXMLHttp, viewid, responseHandler); }; xmlHttpLoadData(viewFormXMLHttp, '/common/loadview.jsp?'+params, viewResponseHandler, loaderid); } function viewFormSubmit(form, u, viewid, responseHandler, loaderid) { viewid = (viewid) ? viewid : "subviewcontainer"; viewResponseHandler = function() { viewResultHandler(viewFormXMLHttp, viewid, responseHandler); }; formSubmitAsync(viewFormXMLHttp, form, '/common/loadview.jsp?u='+u, viewResponseHandler, loaderid); } function viewFormSubmitIframe(form, u, viewid, responseHandler, loaderid) { if (isFormValid(form)) { viewid = (viewid) ? viewid : "subviewcontainer"; viewResponseHandler = function(response) { completeFormSubmitIframeCallback(response, viewid, responseHandler); } iframeSubmit(form, {'onStart' : startFormSubmitIframeCallback, 'onComplete' : viewResponseHandler }); formSubmit(form, '/common/loadview.jsp?u='+u, loaderid); } } function paymentFormSubmit(url, forwardButton) { var form = getObject('paymentForm'); if (isFormValid(form)) { forwardButton = (forwardButton) ? forwardButton : getObject('forward_button'); forwardButton.value = "Please wait..."; forwardButton.disabled=true; viewFormSubmit(form, url); } } function isScheduleDateActive(dateString, prefix) { prefix = (prefix != undefined) ? prefix : ""; var datesInput = getObject('schedulestartdate' + prefix); var startDate = datesInput ? parseDateYYYYMMDD(trimString(datesInput.value)) : null; datesInput = getObject('scheduleenddate' + prefix); var endDate = datesInput ? parseDateYYYYMMDD(trimString(datesInput.value)) : null; var date = parseDateYYYYMMDD(trimString(dateString)); return ((!startDate || date.getTime() >= startDate.getTime()) && (!endDate || date.getTime() <= endDate.getTime()) && !isDateInSchedule(dateString, prefix)); } function isDateInSchedule(dateString, prefix) { var inSchedule = false; var datesInput = getObject('reservedscheduledates' + prefix); if (datesInput) { var reservedScheduleDates = datesInput.value; var sections = reservedScheduleDates.split(","); for (var i = 0; !inSchedule && i < sections.length; i++) { var str = trimString(sections[i]); if (str != '') { inSchedule = dateString.indexOf(str) != -1; } //alert("reservedScheduleDates="+reservedScheduleDates+", dateString="+dateString+", str="+str+", inSchedule="+inSchedule); } } return inSchedule; } function createIframe(c) { var n = Math.floor(Math.random() * 99999); var d = document.createElement('DIV'); d.innerHTML = ""; document.body.appendChild(d); var i = document.getElementById(n); if (c && typeof(c.onComplete) == 'function') { i.onComplete = c.onComplete; } return n; } function createIframeForm(f, name) { f.setAttribute('target', name); } function iframeSubmit(f, c) { createIframeForm(f, createIframe(c)); if (c && typeof(c.onStart) == 'function') { return c.onStart(); } else { return true; } } function iframeLoaded(id) { var i = document.getElementById(id); if (i.contentDocument) { var d = i.contentDocument; } else if (i.contentWindow) { var d = i.contentWindow.document; } else { var d = window.frames[id].document; } if (d.location.href == "about:blank") { return; } if (typeof(i.onComplete) == 'function') { i.onComplete(d.body.innerHTML); } } function startFormSubmitIframeCallback() { alert('startFormSubmitIframeCallback: '); return true; } function completeFormSubmitIframeCallback(response, viewid, responseHandler) { alert('completeFormSubmitIframeCallback: response=' + response + ', viewid=' + viewid +', responseHandler='+responseHandler); if (!isControlPage(response)) { var container = getObject(viewid); if (container) { container.innerHTML = response; } if (responseHandler && responseHandler != completeFormSubmitIframeCallback) { // && response.indexOf('http') == 0) { responseHandler.call(null, response); } } } function redirectResponse(url) { if (url) { document.location = url; } } /**************************************** * ADSPACE MANAGEMENT * ****************************************/ function adSourceTypeChanged(adSourceType) { if (!adSourceType) { return; } if (adSourceType == 'local') { toggleObjects('filecreativecontainer', null); toggleObjects('altfilecreativecontainer', null); toggleObjects(null, 'adtmplcontainer'); toggleObjects('clicktargetcontainer'); toggleObjects('clicktargettip'); toggleObjects('richmediafile', null, 'block'); toggleObjects('imagefile', null, 'block'); toggleObjects('richmediatip', null); toggleObjects('imagetip', null); getObject('adrmdurl').disabled = false; getObject('adimgurl').disabled = false; getObject('adclicktgt').disabled = false; } else if (adSourceType == 'config') { toggleObjects(null, 'richmediafile', 'block'); toggleObjects(null, 'imagefile', 'block'); toggleObjects(null, 'filecreativecontainer'); toggleObjects(null, 'altfilecreativecontainer'); toggleObjects('adtmplcontainer', null); toggleObjects('clicktargetcontainer'); toggleObjects('clicktargettip'); toggleObjects(null, 'richmediatip'); toggleObjects(null, 'imagetip'); getObject('adrmdurl').disabled = true; getObject('adimgurl').disabled = true; if (getObject('adtmplparams')) { getObject('adtmplparams').disabled = false; } } } function adFormatChanged(adFormatCode) { if (adFormatCode != '') { var adID = getObject('adid').value; var addimensions = getObject('addimensions').value; var isTextAd = (adFormatCode == 'text' || adFormatCode == 'shorttext' || adFormatCode == 'textlink'); var adWidth = getObject('adwidth').value; var adHeight = getObject('adheight').value; if (isTextAd) { toggleObjects(null, 'addimensioncontainer'); //if (getObject('addimension')) { getObject('addimension').disabled = true; } //if (getObject('adwidth')) { getObject('adwidth').disabled = true; } //if (getObject('adheight')) { getObject('adheight').disabled = true; } } else { toggleObjects('addimensioncontainer'); //if (getObject('addimension')) { getObject('addimension').disabled = false; } //if (getObject('adwidth')) { getObject('adwidth').disabled = false; } //if (getObject('adheight')) { getObject('adheight').disabled = false; } } if (adFormatCode == 'flashtemplate') { getObject('adctype').value = 2; } if (getObject('creativeprofilecontainer')) { getObject('creativeprofilecontainer').style.display = 'none'; } if (getObject('creativetargetingcontainer')) { getObject('creativetargetingcontainer').style.display = 'none'; } if (getObject('creativesubmitcontainer')) { getObject('creativesubmitcontainer').style.display = 'none'; } if (getObject('creativebudgetcontainer')) { getObject('creativebudgetcontainer').style.display = 'none'; } if (getObject('creativepaymentcontainer')) { getObject('creativepaymentcontainer').style.display = 'none'; } document.swfUploaders = null; viewLoad('u=store.campaigns.setup.creatives.' + adFormatCode + '&adid='+adID + '&adwidth='+adWidth + '&adheight='+adHeight + '&addimensions='+addimensions, 'creativedatacontainer', creativeFormLoaded, 'creativedatacontainer'); } } function creativeFormLoaded() { if (getObject('creativeprofilecontainer')) { getObject('creativeprofilecontainer').style.display = 'block'; } if (getObject('creativetargetingcontainer')) { getObject('creativetargetingcontainer').style.display = 'block'; } if (getObject('creativesubmitcontainer')) { getObject('creativesubmitcontainer').style.display = 'block'; } if (getObject('creativebudgetcontainer')) { getObject('creativebudgetcontainer').style.display = 'block'; } if (getObject('creativepaymentcontainer')) { getObject('creativepaymentcontainer').style.display = 'block'; } autoAllocateBudget(0, 1); resetSWFUploader(); } function resetSWFUploader() { var spanElements = document.documentElement.getElementsByTagName("SPAN"); for (var i = 0; i < spanElements.length; i++) { var offset = spanElements[i].id ? spanElements[i].id.indexOf('_PlaceHolder') : -1; if (offset > 0) { createSWFUploader(spanElements[i].id.substring(0, offset), getSWFUploaderFileInfo( spanElements[i].getAttribute("format"), spanElements[i].getAttribute("maxsize"), spanElements[i].getAttribute("maxwidth"), spanElements[i].getAttribute("maxheight") )); } } } function uploadTemplateParameters() { var n = Math.floor(Math.random() * 99999); var d = document.createElement('div'); d.innerHTML = "
"; d.style.display = "none"; document.body.appendChild(d); var form = getObject(n); viewResponseHandler = function() { viewResultHandler(viewFormXMLHttp, 'adtmplparamsurl', templateAdChanged); }; formSubmitAsync(viewFormXMLHttp, form, 'http://cdn.trafficspaces.com/uploads/postdataupload.php', viewResponseHandler, '-'); } function templateAdChanged() { if (document.richMediaAdChangedIframe) { var richMediaURL = getObject('adtmplurl'); var clickTag = getObject('adclicktgt'); var paramPropsURL = getObject('adtmplparamsurl'); document.richMediaAdChangedIframe( richMediaURL ? richMediaURL.value : "", "", clickTag ? clickTag.value : "", paramPropsURL ? paramPropsURL.value : "" ); } resetSWFUploader(); } function richMediaAdChanged() { if (document.richMediaAdChangedIframe) { var richMediaURL = getObject('adrmdurl'); var fallbackImageURL = getObject('adimgurl'); var clickTag = getObject('adclicktgt'); var paramPropsURL = getObject('adcaption'); var enc = encodeURIComponent||escape; document.richMediaAdChangedIframe( richMediaURL ? richMediaURL.value : "", fallbackImageURL ? fallbackImageURL.value : "", clickTag ? enc(clickTag.value) : "", paramPropsURL ? enc(paramPropsURL.value) : "" ); } } function avAdChanged(isVideo) { //alert('avAdChanged: document.avAdChangedIframe='+document.avAdChangedIframe+', url='+getObject('adrmdurl').value+', isVideo='+isVideo); if (document.avAdChangedIframe) { var avURL = getObject('adrmdurl'); var fallbackImageURL = getObject('adimgurl'); var clickTag = getObject('adclicktgt'); var enc = encodeURIComponent||escape; document.avAdChangedIframe( avURL ? avURL.value : "", fallbackImageURL ? fallbackImageURL.value : "", clickTag ? enc(clickTag.value) : "", isVideo ); } } function videoAdChanged() { avAdChanged(true); } function audioAdChanged() { avAdChanged(false); } function imageAdChanged() { if (document.imageAdChangedIframe) { var imageURL = getObject('adimgurl'); var targetURL = getObject('adclicktgt'); var title = getObject('adname'); document.imageAdChangedIframe( imageURL ? imageURL.value : "", targetURL ? targetURL.value : "", title ? title.value : "" ); } } function textAdChanged() { if (document.textAdChangedIframe) { var textAdTitle = getObject('adtitle'); var textAdCaption = getObject('adcaption'); var targetURL = getObject('adclicktgt'); var imageURL = getObject('adtxtimgurl'); document.textAdChangedIframe( textAdTitle ? textAdTitle.value : "", textAdCaption ? textAdCaption.value : "", targetURL ? targetURL.value : "", imageURL ? imageURL.value : "" ); } } function getSWFUploaderFileInfo(fileFormat, maxSize, maxWidth, maxHeight) { if (fileFormat == 'json') { return {"format": fileFormat, "maxsize": maxSize, "types": "*.json", "desc" : "JSON files"}; } else if (fileFormat == 'image') { return {"format": fileFormat, "maxsize": maxSize, "maxwidth": maxWidth, "maxheight": maxHeight, "types": "*.jpg;*.gif;*.png", "desc" : "JPEG, GIF, or PNG files"}; } else if (fileFormat == 'flash') { return {"format": fileFormat, "maxsize": maxSize, "types": "*.swf", "desc" : "SWF files"}; } else if (fileFormat == 'video') { return {"format": fileFormat, "maxsize": maxSize, "types": "*.mp4;*.m4v;*.ogv;*.webm;*.flv", "desc" : "Video files (MPEG4 H.264, Theora, WebM, Flash Video)"}; } else if (fileFormat == 'audio') { return {"format": fileFormat, "maxsize": maxSize, "types": "*.mp3;*.oga;*.ogg;", "desc" : "Audio files (MP3, Theora)"}; } else { return {"format": fileFormat, "maxsize": maxSize, "types": "*.*", "desc" : "All files"}; } } function createSWFUploader(uploaderID, fileInfo) { if (!document.swfUploaders) { document.swfUploaders = []; } document.swfUploaders[uploaderID] = new SWFUpload({ flash_url : "http://cdn.trafficspaces.com/scripts/swfupload/swfupload.swf", upload_url: "http://cdn.trafficspaces.com/uploads/" + (fileInfo.format == "image" ? "imageupload.php" : "dataupload.php"), post_params: {"maxwidth" : (fileInfo.maxwidth ? fileInfo.maxwidth : ""), "maxheight" : (fileInfo.maxheight ? fileInfo.maxheight : "")}, file_size_limit : (fileInfo.maxsize ? fileInfo.maxsize : "10 MB"), file_types : fileInfo.types, file_types_description : fileInfo.desc, file_upload_limit : 100, file_queue_limit : 0, custom_settings : { progress_target : uploaderID + "_Progress", success_preview_target : uploaderID + "_Preview", success_message_target : uploaderID, cancelButtonId : "btnCancel" }, debug: false, // Button settings button_image_url: "http://cdn.trafficspaces.com/images/icons/upload_file.png", button_width: "100", button_height: "30", button_placeholder_id: uploaderID + "_PlaceHolder", button_text: 'Upload', button_text_style: ".theFont { text-decoration: underline; font-size: 16; }", button_text_left_padding:35, button_text_top_padding: 5, button_action : SWFUpload.BUTTON_ACTION.SELECT_FILE, button_disabled : false, button_cursor : SWFUpload.CURSOR.HAND, button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT, // The event handler functions are defined in handlers.js file_dialog_complete_handler : fileDialogComplete, //upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete//, //queue_complete_handler : queueComplete // Queue plugin event }); } function adDimensionChanged(dimensionCode, updateTemplate) { var offset = dimensionCode.indexOf('x'); var width = offset > 0 ? dimensionCode.substring(0, offset) : 0; var height = offset > 0 ? dimensionCode.substring(offset + 1, dimensionCode.length) : 0; getObject('adwidth').value = width; getObject('adheight').value = height; var dimensions = (width != "" && height && height != "") ? ("^" + width + "x" + height + "$") : getObject('addimensions').value; var tmpl = getObject('adtmplid'); if (updateTemplate && tmpl) { var tmplID = tmpl.value; viewLoad('u=ads.templates.list&adtmplid=' + tmplID + '&addimensions=' + dimensions, 'adtmplid', null, 'adtmplid'); changeAdTemplateSize(width, height); } } function changeAdTemplateSize(width, height) { var tmplBase = getObject('adtmplbase'); if (width && height && tmplBase) { tmplBase.style.width = width; tmplBase.style.height = height; var adTemplate = getObject('adtmpl'); adTemplate.style.width = width; adTemplate.style.height = height; adTemplate.style.maxHeight = height; adTemplate = getObject('adtmplembed'); adTemplate.style.width = width; adTemplate.style.height = height; adTemplate.style.maxHeight = height; } } function adTemplateChanged(templateID, adID, isCompact, showTemplates, showTemplatePreview) { var width = getObject('adwidth').value; var height = getObject('adheight').value; //var dimensions = (width != "" && height && height != "") ? ("^" + width + "x" + height + "$") : getObject('addimensions').value; var dimensions = (width != "" && height && height != "") ? (width + "x" + height) : getObject('addimensions').value; viewLoad('u=ads.templates&adtmplid='+templateID+'&adid='+adID+'&compact='+isCompact+'&showtemplates='+showTemplates+'&showtemplatepreview='+showTemplatePreview+'&addimensions='+dimensions, 'adtmplcontainer', templateAdChanged); } function addAdTemplateParameter(isImage) { var parameterTable = getObject('parametertable'); var tblBody = getObject('parametertablebody') var emptyRow = getObject('emptyparameterrow'); if (emptyRow != null) { emptyRow.style.display = "none"; } var numRows = parameterTable.getElementsByTagName("TR").length; var tblRow = document.createElement("TR"); tblRow.className='tblrow'; var tblCell = document.createElement("TD"); tblCell.className = "tblcell"; tblCell.style.width = "100px"; tblCell.innerHTML = ""; tblRow.appendChild(tblCell); tblCell = document.createElement("TD"); tblCell.className = "tblcell"; if (isImage) { var randId = "rand_" + Math.round(Math.random()*2147483647); var imageHTML = ""; imageHTML += ""; imageHTML += "
"; imageHTML += ""; imageHTML += "
"; tblCell.innerHTML = imageHTML; } else { tblCell.innerHTML = ""; } tblRow.appendChild(tblCell); tblCell = document.createElement("TD"); tblCell.className = "ctblcell"; tblCell.style.padding = "0px 5px"; tblCell.innerHTML = ""; tblRow.appendChild(tblCell); tblBody.appendChild(tblRow); if (isImage) { creativeFormLoaded(); } } function combineAdTemplateParameters(canEncode, separator) { separator = separator ? separator : "\n"; var paramProps = ""; var parameterTable = getObject('parametertable'); if (parameterTable) { var enc = encodeURIComponent||escape; var rows = parameterTable.getElementsByTagName("TR"); for (var i = 0; i < rows.length; i++) { var inputs = rows[i].getElementsByTagName("INPUT"); if (inputs.length > 1) { var paramKey = inputs[0].value; var paramValue = ""; if (inputs[1].type == 'text' || inputs[1].type == 'hidden') { paramValue = canEncode ? enc(inputs[1].value.replace(/&/gm, '%26')) : inputs[1].value; } if (paramKey != '' && paramValue != '') { paramProps += paramKey + '=' + paramValue + separator; } } } } return paramProps; } function geoTargetChangeCallback(value) { getObject('geotarget_activesearchvalue').value=value; } function researchGeoTargetChangeCallback(value) { } function showStateGeographics(adspID, countryCode) { document.location = '/analytics/geographics/state/?adspid='+adspID+'&geotarget='+countryCode; } function showCityGeographics(adspID, stateCode, stateName) { document.location = '/analytics/geographics/state/?adspid='+adspID+'&geotarget='+stateCode+'&geotargetname='+stateName; } function addCoordTarget() { if (isFormValid(getObject('adDeliveryPlanForm'))) { var coordTargetSelect = getObject('coord_target_tmpselect'); var location = getObject('coord_location').value; var longitude = getObject('coord_longitude').value; var latitude = getObject('coord_latitude').value; var radius = getObject('coord_radius').value; var radiusUnit = getObject('coord_radius_unit').value; //alert("location="+location+", longitude="+longitude+", latitude="+latitude+", radius="+radius+", radiusUnit="+radiusUnit); if (location && longitude && latitude && radius && radiusUnit) { var radiusUnitOpt = findOption(getObject('coord_radius_unit'), radiusUnit); var key = longitude + "," + latitude + "," + radius + "," + radiusUnit; var displayText = location.replace("(", "").replace(")", "") + " (" + radius + " " + radiusUnitOpt.innerHTML + ")"; //alert("displayText="+displayText); replaceOption(coordTargetSelect, key, displayText); } } } function removeCoordTarget() { removeSelectedOptions(getObject('coord_target_tmpselect')); } function onCoordTargetSelect() { var coordTargetSelect = getObject('coord_target_tmpselect'); var selectedOpt = getSelectedOption(coordTargetSelect); var keyParts = selectedOpt ? selectedOpt.value.split(",") : null; if (keyParts && keyParts.length == 4) { getObject('coord_longitude').value = keyParts[0]; getObject('coord_latitude').value = keyParts[1]; getObject('coord_radius').value = keyParts[2]; getObject('coord_radius_unit').value = keyParts[3]; var displayText = selectedOpt.innerHTML; var displayParts = displayText ? displayText.split("(") : null; if (displayParts && displayParts.length == 2) { getObject('coord_location').value = displayParts[0].Trim(); return true; } } return false; } function onCoordTargetChange(type) { if (type == 'none') { toggleObjects(null, 'coord_targetdatacontainer'); getObject('coord_location').setAttribute("validate", ""); getObject('coord_longitude').setAttribute("validate", ""); getObject('coord_latitude').setAttribute("validate", ""); getObject('coord_radius').setAttribute("validate", ""); getObject('coord_radius_unit').setAttribute("validate", ""); } else { toggleObjects('coord_targetdatacontainer', null); getObject('coord_location').setAttribute("validate", "isValid"); getObject('coord_longitude').setAttribute("validate", "isValid"); getObject('coord_latitude').setAttribute("validate", "isValid"); getObject('coord_radius').setAttribute("validate", "isValid"); getObject('coord_radius_unit').setAttribute("validate", "isValid"); } } function addGeoTarget() { var geoTargetSelect = getObject('geotarget_tmpselect'); if (getObject('geotarget_cczone').checked) { var ccSelect = getObject('cc'); var ccList = getObject('cczone').value.split(','); for (var i = 0; i < ccList.length; i++) { var ccOpt = findOption(ccSelect, ccList[i]); if (ccOpt != null) { replaceOption(geoTargetSelect, ccOpt.value, ccOpt.innerHTML); } } } else if (getObject('geotarget_location').checked) { var ccOpt = getSelectedOption(getObject('cc')); var stateOpt = getSelectedOption(getObject('state')); var cityOpt = getSelectedOption(getObject('city')); var col_Opts; var geoMode; if (cityOpt && cityOpt.value != '' && cityOpt.value != '-1') { col_Opts = getObject('city').options; geoMode = 2; } else if (stateOpt && stateOpt.value != '' && stateOpt.value != '-1') { col_Opts = getObject('state').options; geoMode = 1; } else if (ccOpt && ccOpt.value != '' && ccOpt.value != '-1') { col_Opts = getObject('cc').options; geoMode = 0; } for (var i = 0; i < col_Opts.length; i++) { var opt = col_Opts[i]; if (opt.selected) { if (geoMode == 2) { replaceOption(geoTargetSelect, opt.value, opt.innerHTML + ", " + stateOpt.innerHTML + ", " + ccOpt.innerHTML); } else if (geoMode == 1) { replaceOption(geoTargetSelect, opt.value, opt.innerHTML + ", " + ccOpt.innerHTML); } else if (geoMode == 0) { replaceOption(geoTargetSelect, opt.value, opt.innerHTML); } } } } } function removeGeoTarget() { removeSelectedOptions(getObject('geotarget_tmpselect')); } function onGeoChange(geotype, geoChangeCallback) { var cc = getObject('cc').value; var state = getObject('state').value; if (geotype == 'cc') { if (cc && cc != '-1') { viewLoad('u=search.tools.states&cc=' + cc, 'state', geoChangeCallback, 'state'); } else { populateSelect(getObject('state'), ""); if (geoChangeCallback) { geoChangeCallback.call(null); }; } populateSelect(getObject('city'), ""); } else if (geotype == 'state') { if (state && state != '-1') { viewLoad('u=search.tools.cities&state=' + state, 'city', geoChangeCallback, 'city'); } populateSelect(getObject('city'), ""); } } function onGeoTargetChange(type) { if (type == 'none') { toggleObjects(null, 'geotargetcontainer'); toggleObjects(null, 'geotargetdatacontainer'); toggleObjects(null, 'geotargetaddremovecontainer'); toggleObjects(null, 'geotarget_tmpselect'); } else { toggleObjects('geotargetcontainer', null); toggleObjects('geotargetdatacontainer', null); toggleObjects('geotargetaddremovecontainer', null); toggleObjects('geotarget_tmpselect'); if (type == 'cczone') { toggleObjects('geotargetcczonecontainer', 'geotargetlocationcontainer'); } else if (type == 'location') { toggleObjects('geotargetlocationcontainer', 'geotargetcczonecontainer'); } } } function renderChart(chartId, width, height) { var chartContainer = getObject(chartId); var dataURL = null; var enc = encodeURIComponent||escape; if (chartContainer && (dataURL = chartContainer.getAttribute("data"))) { swfobject.embedSWF("/flash/ofc/ofc.swf", chartId, width, height, "9.0.0", "expressInstall.swf", {"data-file": enc(dataURL)}, {"allowscriptaccess":"true", "allownetworking":"true"}); } } function addToCart(adSpaceID) { var form = getObject('addToCartForm'); if (form) { var adSpaceIDInput = getObject('adsporder'); adSpaceIDInput.value = adSpaceID; viewFormSubmit(form, 'advertise.cart.manager', 'addtocart_'+adSpaceID); } } function enforceInputLength(input, maxlength, output) { var text = input.value; if (text && text.length > maxlength) { input.value = text.substring(0, maxlength); } getObject(output).innerHTML = maxlength - text.length; } function onAdDeliveryPlanChanged(returnVal) { var editableINPUT = getObject('_editable'); var showPlansINPUT = getObject('_showplans'); viewLoad('u=ads.targeting&addpid='+(returnVal ? returnVal : "") + '&editable=' + (editableINPUT ? editableINPUT.value : false) + '&showplans=' + (showPlansINPUT ? showPlansINPUT.value : false), 'targetingsummarycontainer'); } function showAdDeliveryPlan(target, width, height) { var planINPUT = getObject('addpid'); var planID = planINPUT ? planINPUT.value : '170f1e66'; showPopWin('/ads/targeting/popup/?target='+target+'&addpid='+planID, width ? width : 550, height ? height : 350, onAdDeliveryPlanChanged); } function showAdRealmResources(target) { showPopWin('/ads/resources/popup/?target='+target, 700, 300); } function onAdBundleComponentChanged(returnVal) { if (returnVal) { viewLoad('u=setup.ads.bundles', 'subviewcontainer'); } } function showAdBundleComponent(adBundleComponentID, adBundleID) { adBundleComponentID = (adBundleComponentID != undefined) ? adBundleComponentID : ""; adBundleID = (adBundleID != undefined) ? adBundleID : ""; showPopWin('/setup/ads/bundles/popup/?adbundlecompid='+adBundleComponentID+'&adbundleid='+adBundleID, 600, 300, onAdBundleComponentChanged); } function onCouponChanged(returnVal) { if (returnVal) { viewLoad('u=setup.payments.coupons', 'subviewcontainer'); } } function showCoupon(couponCode) { couponCode = (couponCode != undefined) ? couponCode : ""; showPopWin('/setup/payments/coupons/popup/?cpncode='+couponCode, 600, 500, onCouponChanged); } function onUserRoleChanged(returnVal) { if (returnVal) { viewLoad('u=setup.users.community', 'subviewcontainer'); } } function showUserRole(username) { username = (username != undefined) ? username : ""; showPopWin('/setup/users/community/roles/popup/?username='+username, 600, 260, onUserRoleChanged); } function onEventHandlerChanged(returnVal) { if (returnVal) { viewLoad('u=setup.integrations.apps', 'subviewcontainer'); } } function showEventHandler(eventHandlerCode, eventHandlerID) { showPopWin('/setup/integrations/apps/popup/?eventhcode='+eventHandlerCode+'&eventhid='+eventHandlerID, 520, 460, onEventHandlerChanged); } function onAdReviewAccepted(returnVal) { if (returnVal) { changeAdStatus(true, returnVal); } } function onAdReviewRejected(returnVal) { if (returnVal) { changeAdStatus(false, returnVal); } } function showAdReviewNotes(isAccept) { showPopWin('/setup/ads/review/popup/?isaccept='+isAccept, 600, 350, (isAccept ? onAdReviewAccepted : onAdReviewRejected)); } function onOrderPreferencesChanged(returnVal) { if (returnVal) { var parts = returnVal.split(","); var index = parts[0]; getObject("adspctrctexpdate"+index).value = parts[1]; getObject("adspctrctdlybgt"+index).value = parts[2]; } } function showOrderPreferences(index, isReadOnly) { var adspid = getObject("adsp"+index).value; var totalBudget = expandDouble(getObject("adspgross"+index).innerHTML); var dailyBudget = getObject("adspctrctdlybgt"+index).value; var expirationDate = getObject("adspctrctexpdate"+index).value; showPopWin('/store/cart/budget/popup/?idx='+index+'&adspid='+adspid+'&adspctrctttlbgt='+totalBudget+'&adspctrctdlybgt='+dailyBudget+'&adspctrctexpdate='+expirationDate+'&isreadonly='+isReadOnly, 600, 330, onOrderPreferencesChanged); } function showTransactionDetail(txID) { txID = (txID != undefined) ? txID : ""; showPopWin('/store/earnings/transactions/popup/?txid='+txID, 600, 420, null); } /**************************************** * ADSPACE CONTEXT * ****************************************/ function adspaceContextFormSubmit(form, u) { var selectedChannels = exportCheckboxesValues('adspcat_check', form, 1, 3); if (selectedChannels) { getObject('channel').value = selectedChannels; } else { alert("Please select between 1 and 3 channels for the adspace"); return; } /* var selectedContentTags = getObject('adspcnttags_text').value.replace(/[\f\n\r]/gm, ','); getObject('adspcnttags').value = selectedContentTags; var selectedExclusionTags = getObject('adspexcltags_text').value.replace(/[\f\n\r]/gm, ','); getObject('adspexcltags').value = selectedExclusionTags; */ viewFormSubmit(form, u); } function credentialsFormSubmit(form, u, mode) { if (mode == 0) { getObject('pw').setAttribute("validate", "isValid"); getObject('pw1').setAttribute("validate", "isValid"); getObject('pw2').setAttribute("validate", "isValid"); getObject('sq').setAttribute("validate", ""); getObject('sa').setAttribute("validate", ""); getObject('sq').value = ""; getObject('sa').value = ""; } else if (mode == 1) { getObject('pw').setAttribute("validate", ""); getObject('pw1').setAttribute("validate", ""); getObject('pw2').setAttribute("validate", ""); getObject('pw').value = ""; getObject('pw1').value = ""; getObject('pw1').value = ""; getObject('sq').setAttribute("validate", "isValid"); getObject('sa').setAttribute("validate", "isValid"); } else { return false; } viewFormSubmit(form, u); } /**************************************** * ADSPACE PRICING * ****************************************/ var MAX_BUDGET = 100000000.0; function adjustBudget(index, size, incrementalBudget) { adjustCart(index, size, incrementalBudget, 0.0); } function adjustBidPrice(index, size, incrementalBidPrice) { adjustCart(index, size, 0.0, incrementalBidPrice); } function adjustCart(index, size, incrementalBudget, incrementalBidPrice) { var adSpace = getObject("adsp"+index); var budgetINPUT = getObject("adspbudget"+index); var bidPriceINPUT = getObject("adspbid"+index); if (!adSpace || !budgetINPUT || !bidPriceINPUT) { return; } incrementalBudget = incrementalBudget ? expandDouble(incrementalBudget, 2) : 0.0; incrementalBidPrice = incrementalBidPrice ? expandDouble(incrementalBidPrice, 2) : 0.0; var adspaceMinBudget = expandDouble(adSpace.getAttribute("minbudget"), 2); var adspaceBudget = (budgetINPUT.value != '') ? expandDouble(budgetINPUT.value, 2) : adspaceMinBudget; //alert("adspaceMinBudget="+adspaceMinBudget+", incrementalBudget="+incrementalBudget+", adspaceBudget="+adspaceBudget); budgetINPUT.value = formatDouble(Math.min(Math.max(adspaceBudget + incrementalBudget, adspaceMinBudget), MAX_BUDGET), 2); var adspaceMinPrice = expandDouble(adSpace.getAttribute("price"), 2); var adspaceBidPrice = (bidPriceINPUT.value != '') ? expandDouble(bidPriceINPUT.value, 2) : adspaceMinPrice; bidPriceINPUT.value = expandDouble(Math.min(Math.max(adspaceBidPrice + incrementalBidPrice, adspaceMinPrice), MAX_BUDGET), 2); //alert("adspaceBidPrice="+adspaceBidPrice+", adspaceMinPrice="+adspaceMinPrice+", incrementalBidPrice="+incrementalBidPrice+", bidPriceINPUT.value="+bidPriceINPUT.value); autoAllocateBudget(index, size); } function autoAllocateBudget(index, size) { var adSpace = getObject("adsp"+index); var budgetINPUT = getObject("adspbudget"+index); var bidPriceINPUT = getObject("adspbid"+index); if (!adSpace || !budgetINPUT || !bidPriceINPUT) { return; } var adspaceBudget = expandDouble(budgetINPUT.value); var adspaceBidPrice = expandDouble(bidPriceINPUT.value); var adspacePrice = expandDouble(adSpace.getAttribute("price")); var adspaceModel = expandDouble(adSpace.getAttribute("model")); var adspaceMinVol = expandDouble(adSpace.getAttribute("minvol")); var adspaceIncrVol = expandDouble(adSpace.getAttribute("incrvol")); var adspaceGrossPrice = 0.0; var adspaceDiscount = 0.0; var adspaceDiscVol = adSpace.getAttribute("discvols"); var adspaceDiscRates = adSpace.getAttribute("discrates"); var aggregate = getAggregate(adspaceModel); if (adspaceBidPrice > 0) { var adspaceVolume = 0.0; var discountRate = 0.0; //adspaceVolume = Math.floor(adspaceBudget / adspaceBidPrice * aggregate); adspaceVolume = Math.round(adspaceBudget / adspaceBidPrice * aggregate); adspaceVolume = Math.min(Math.max(adspaceVolume, 0.0), Number.MAX_VALUE); if (adspaceVolume >= adspaceMinVol) { adspaceVolume = adspaceMinVol + (Math.floor((adspaceVolume - adspaceMinVol) / adspaceIncrVol) * adspaceIncrVol); var discountVolumes = adspaceDiscVol ? adspaceDiscVol.split(",") : null; var discountRates = adspaceDiscRates ? adspaceDiscRates.split(",") : null; if (discountVolumes != null && discountRates != null && discountVolumes.length == discountRates.length) { for (var j = 0; j < discountVolumes.length; j++) { if (adspaceVolume >= expandDouble(discountVolumes[j])) { discountRate = expandDouble(discountRates[j]) / 100.0; } else { break; } } } } else { adspaceVolume = 0; } adspaceGrossPrice = adspaceBidPrice * adspaceVolume / aggregate; adspaceDiscount = adspaceGrossPrice * discountRate; } else { adspaceVolume = 0; adspaceBudget = 0.0; } var adspaceGrossPriceSPAN = getObject("adspgross"+index); var adspaceVolumeSPAN = getObject("adspvol"+index); var adspaceDiscountSPAN = getObject("adspdisc"+index); var adspaceNetPriceSPAN = getObject("adspnet"+index); if (adspaceGrossPriceSPAN) { adspaceGrossPriceSPAN.innerHTML = formatDouble(adspaceGrossPrice, 2); } if (adspaceVolumeSPAN) { adspaceVolumeSPAN.innerHTML = formatDouble(adspaceVolume); } if (adspaceDiscountSPAN) { adspaceDiscountSPAN.innerHTML = formatDouble(adspaceDiscount, 2); } if (adspaceNetPriceSPAN) { adspaceNetPriceSPAN.innerHTML = formatDouble(adspaceGrossPrice - adspaceDiscount, 2); adspaceNetPriceSPAN.style.fontWeight = (adspaceGrossPrice > 0) ? "bold" : "normal"; } var totalNet = calculateAllocatedBudget(size, true); try { toggleBillingInfo(totalNet > 0.0); } catch (e) {} } function calculateAllocatedBudget(size) { var totalGross = 0.0; var totalVolumeDiscount = 0.0; var totalCouponDiscount = 0.0; var totalNet = 0.0; var totalHits = 0; var orderMap = ""; var coupon = getObject('coupon'); var couponType = coupon != null ? coupon.getAttribute('cpnisabs') : undefined; var couponRef = coupon != null ? coupon.getAttribute('cpnref') : undefined; var couponBase = coupon != null ? coupon.getAttribute('cpnbase') : undefined; var couponValue = coupon != null ? coupon.getAttribute('cpndiscval') : undefined; for (var i = 0; i < size; i++) { var adSpace = getObject("adsp"+i); if (!adSpace) { continue; } var adspid = adSpace.value; var adspBudget = expandDouble(getObject("adspbudget"+i).value, 2); var adspBidPrice = expandDouble(getObject("adspbid"+i).value, 2); var volume = expandDouble(getObject("adspvol"+i).innerHTML); var startDate = getObject("fromdate"+i).value; var model = adSpace.getAttribute("model"); var grossPrice = expandDouble(getObject("adspgross"+i).innerHTML, 2); var volumeDiscount = expandDouble(getObject("adspdisc"+i).innerHTML, 2); var netPrice = expandDouble(getObject("adspnet"+i).innerHTML, 2); var isCouponRef = adSpace.getAttribute("iscpnref") == 'true' || (couponRef && couponRef == adspid); if (coupon && isCouponRef && expandDouble(couponBase, 2) <= netPrice) { totalCouponDiscount += (couponType == 'true') ? expandDouble(couponValue, 2) : (expandDouble(couponValue, 2) / 100.0 * netPrice); } totalGross += (volume > 0) ? grossPrice : 0.0; totalVolumeDiscount += (volume > 0) ? volumeDiscount : 0.0; totalNet += (volume > 0) ? netPrice : 0.0; var averageHits = expandDouble(adSpace.getAttribute("hits")); var averageUnits = expandDouble(adSpace.getAttribute("units")); var monthlyReach = expandDouble(getObject("monthlyreach").value); var expirationDate = getObject("adspctrctexpdate"+i).value; expirationDate = expirationDate.length != 10 ? "-" : expirationDate; var dailyBudget = expandDouble(getObject("adspctrctdlybgt"+i).value, 2); orderMap += adspid + "," + adspBudget + "," + adspBidPrice + "," + startDate + "," + expirationDate + "," + dailyBudget + "\n"; var a = averageHits; if (getAggregate(model) != 0 && averageUnits != 0) { averageHits = ((volume / averageUnits) * averageHits); } else { averageHits = volume; } totalHits += averageHits; } if (size > 0) { getObject("cartorders").value = orderMap; if (coupon && !couponRef && expandDouble(couponBase, 2) <= totalNet) { totalCouponDiscount = (couponType == 'true') ? expandDouble(couponValue, 2) : (expandDouble(couponValue, 2) / 100.0 * totalNet); } totalNet = Math.max(0, totalNet - totalCouponDiscount); var totalDiscount = totalGross - totalNet; if (getObject("totalhitsheader")) { getObject("totalhitsheader").innerHTML = formatDouble(totalHits, 0); } if (getObject("shareofreachheader")) { getObject("shareofreachheader").innerHTML = formatDouble(totalHits / monthlyReach * 100.0, 2); } if (getObject("totalgrossheader")) { getObject("totalgrossheader").innerHTML = formatDouble(totalGross, 2); } if (getObject("totalvoldiscountheader")) { getObject("totalvoldiscountheader").innerHTML = formatDouble(totalVolumeDiscount, 2); } if (getObject("totalnetheader")) { getObject("totalnetheader").innerHTML = formatDouble(totalNet, 2); } if (getObject("totalcoupondiscount")) { getObject("totalcoupondiscount").innerHTML = (totalCouponDiscount > 0 ? "-": "")+"$"+formatDouble(totalCouponDiscount, 2); } if (getObject("totaldiscount")) { getObject("totaldiscount").innerHTML = (totalDiscount > 0 ? "-": "")+"$"+formatDouble(totalDiscount, 2); } if (getObject("totalnet")) { getObject("totalnet").innerHTML = "$"+formatDouble(totalNet, 2); } var avgECPM = 0.0; if (totalNet > 0 && totalHits > 0) { avgECPM = totalNet / (totalHits / 1000); } if (getObject("avgecpmheader")) { getObject("avgecpmheader").innerHTML = formatDouble(avgECPM, 2); } } return totalNet; } function getAggregate(model) { switch (model) { case 1 : return 1; case 2 : return 1; case 3 : return 100; case 4 : return 1; case 0 : return 1000; default: return undefined; } } /**************************************** * ADSPACE TRADING * ****************************************/ function onTradeOrderTypeChange(orderType) { if (!orderType || orderType == "") { toggleObjects(null, 'tradeparamscontainer', 'block'); } else { toggleObjects('tradeparamscontainer', null, 'block'); if (orderType == 1) { toggleObjects('placebidparamscontainer', 'quickbuyparamscontainer', 'block'); getObject('price_placebid').disabled = false; getObject('volume_placebid').disabled = false; getObject('budget_quickbuy').disabled = true; getObject('price_quickbuy').disabled = true; getObject('volume_quickbuy').disabled = true; } else if (orderType == 0) { toggleObjects('quickbuyparamscontainer', 'placebidparamscontainer', 'block'); getObject('price_placebid').disabled = true; getObject('volume_placebid').disabled = true; getObject('budget_quickbuy').disabled = false; getObject('price_quickbuy').disabled = false; getObject('volume_quickbuy').disabled = false; } } } /**************************************** * ADSPACE TRADING * ****************************************/ function onTaxFormWizardChange(mode) { var taxStatus =0; var submitButton = getObject('submitbutton'); submitButton.disabled = true; switch (mode) { case 1: toggleObjects('stage1', 'stage2'); /* Show all forms */ break; case 2: toggleObjects('stage2', 'stage1'); break; case 3: taxStatus=1; submitButton.disabled = false; break; case 4: taxStatus=2; submitButton.disabled = false; break; case 5: taxStatus=3; submitButton.disabled = false; break; case 6: taxStatus=4; submitButton.disabled = false; break; case 7: taxStatus=5; submitButton.disabled = false; break; case 8: taxStatus=6; submitButton.disabled = false; break; case 9: taxStatus=7; submitButton.disabled = false; break; case 10: toggleObjects(null, 'stage3'); taxStatus=2; submitButton.disabled = false; break; case 11: toggleObjects('stage3'); break; case 12: toggleObjects('stage5', 'stage4'); break; case 13: toggleObjects('stage4'); break; case 14: toggleObjects('stage5'); break; case 15: toggleObjects(null, 'stage5'); taxStatus=1; submitButton.disabled = false; break; case 16: toggleObjects('stage6'); break; case 17:toggleObjects(null, 'stage6'); taxStatus=7; submitButton.disabled = false; break; case 18:toggleObjects(null, 'stage6'); taxStatus=5; submitButton.disabled = false; break; case 19:toggleObjects(null, 'stage6'); taxStatus=6; submitButton.disabled = false; break; case 20:toggleObjects('stage6'); taxStatus=3; submitButton.disabled = false; break; case 21:toggleObjects('stage6'); taxStatus=4; submitButton.disabled = false; break; } getObject('taxstatus').value = taxStatus; } function changeAdStatus(isAccept, comments) { var cmd = ''; var confirmMessage = ''; var adIDList = exportCheckboxesValues('adidlist', getObject('trackerForm')); if (adIDList == '') { alert('Please select one or more ads'); return; } if (isAccept) { cmd = '020c15310103196b17361d30382c6666'; confirmMessage = 'Are you sure you want to accept the selected ads?'; } else { cmd = '38360d2a010c156b17361d30382c6666'; confirmMessage = 'Are you sure you want to reject the selected ads?'; } if (confirm(confirmMessage)) { getObject('controlForm_cmd').value = cmd; getObject('adidlist').value = adIDList; getObject('desc').value = (comments ? comments : ""); getObject('controlForm').submit(); } } function changeAdSpaceContractStatus(statusCode, contractID) { var cmd = ''; var confirmMessage = ''; var contractIDList = (contractID) ? contractID : exportCheckboxesValues('adspctrctidlist', getObject('trackerForm')); if (contractIDList == '') { alert('Please select one or more ad campaigns'); return; } switch (statusCode) { case 0: cmd = '381c23333e086e330113152c020c15370369152d39350922020c156b382c6666'; confirmMessage = 'Are you sure you want to start the selected ad campaigns?'; break; case 1: cmd = '381c1d6a38690e2e020c0921381c1d31010d623139696e6b38361d313f131666'; confirmMessage = 'Are you sure you want to pause the selected ad campaigns?'; break; case 2: cmd = '3868092d38186e330113152c020c15370369152d39350922020c156b382c6666'; confirmMessage = 'Are you sure you want to stop the selected ad campaigns permanently?'; break; case 3: cmd = '020311313a1c376901086e330113152c020c15370369152d39350922020c156b382c6666'; confirmMessage = 'Are you sure you want to archive the stopped ad campaigns?'; break; default: return false; } if (confirm(confirmMessage)) { getObject('controlForm_cmd').value= cmd; getObject('adspctrctidlist').value = contractIDList; getObject('controlForm').submit(); } } function toggleSelfServiceSMTP(isEnabled, useSystemSMTPServer) { if (isEnabled && !useSystemSMTPServer) { toggleObjects('smtpservercontainer', null); } else { toggleObjects(null, 'smtpservercontainer'); } getObject('host').disabled = !isEnabled || useSystemSMTPServer; getObject('port').disabled = !isEnabled || useSystemSMTPServer; getObject('username').disabled = !isEnabled || useSystemSMTPServer; getObject('password').disabled = !isEnabled || useSystemSMTPServer; getObject('email').disabled = !isEnabled || useSystemSMTPServer; } function showPaymentMethod(method) { if (method == 2) { getObject('cardinfocontainer').style.display = "none"; getObject('addressinfocontainer').style.display = "none"; toggleObjects('paypal_jump_button', 'forward_button'); } else if (method == 0) { getObject('cardinfocontainer').style.display = "block"; getObject('addressinfocontainer').style.display = "block"; toggleObjects('forward_button', 'paypal_jump_button'); } } function onSearchTagActivate(preservePageNum) { var query = ""; var searchTagInput = getObject('searchtags'); if (searchTagInput.value && searchTagInput.value != "" && searchTagInput.value != "") { query += "&tag="+ searchTagInput.value.replace(/ /,','); } var searchTargetSelect = getObject('searchtarget'); if (searchTargetSelect.value && searchTargetSelect.value != "" && searchTargetSelect.value != -1) { var searchTargetValueSelect = getObject('searchtargetvalue'); if (searchTargetSelect.value == 'adspcat' || (searchTargetValueSelect.value && searchTargetValueSelect.value != "" && searchTargetValueSelect.value != -1)) { if (searchTargetSelect.value != "state" && searchTargetSelect.value != "city") { query += "&activevalue="+searchTargetValueSelect.value + "&"+searchTargetSelect.value+"="+searchTargetValueSelect.value; } else { query += buildGeoTargetQuery(searchTargetValueSelect.value); } query += "&searchmode=" + searchTargetSelect.value; } } var layoutModeInput = getObject('layoutmode'); if (layoutModeInput.value) { query += "&layoutmode=" + layoutModeInput.value; } if (query != "") { if (typeof XMLHttpRequest != 'undefined') { // if ECMA version of object is available try { //netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); //netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); //xmlhttp = new XMLHttpRequest(); // instantiate it } catch (err) { alert("Error initializing XMLHttpRequest.\n"+err); // show error } } doSearch("c=38690d333836153417361d303868193302690d21" + query + (preservePageNum ? "" : "&pagenum=1")); } else { alert("Please use the search tool to define your target audience"); } } function onLayoutModeChange(layoutMode) { getObject('layoutmode').value = layoutMode; switch (layoutMode) { case 0: getObject('viewbutton0').src = "http://cdn.trafficspaces.com/images/icons/viewbutton0_active.gif"; getObject('viewbutton1').src = "http://cdn.trafficspaces.com/images/icons/viewbutton1.gif"; break; case 1: getObject('viewbutton0').src = "http://cdn.trafficspaces.com/images/icons/viewbutton0.gif"; getObject('viewbutton1').src = "http://cdn.trafficspaces.com/images/icons/viewbutton1_active.gif"; break; } //onSearchTagActivate(true); } function onTargetSelectChange(value) { var searchTargetValueSelect = getObject("searchtargetvalue"); searchTargetValueSelect.value = ''; var activeSearchContainer1 = getObject("activesearchcontainer1"); var activeSearchContainer2 = getObject("activesearchcontainer2"); var searchButton = getObject("searchbutton"); if (!value || value == '') { activeSearchContainer1.style.display = "none"; activeSearchContainer2.style.display = "none"; searchButton.className = "searchbuttoncontainer"; } else if (value == 'state' || value == 'city') { activeSearchContainer1.style.display = "none"; activeSearchContainer2.style.display = "inline"; searchButton.className = "searchbuttoncontainer2"; if (value == 'state') { setupActiveSearch("/webdata/tools/search/activesearch/state/search.jsp?activeoutput=json&", "activesearchinput", onSearchValueChange); } else { setupActiveSearch("/webdata/tools/search/activesearch/city/search.jsp?activeoutput=json&", "activesearchinput", onSearchValueChange); } var activeSearchInput = getObject("activesearchinput"); activeSearchInput.value = ""; } else { activeSearchContainer1.style.display = "inline"; activeSearchContainer2.style.display = "none"; searchButton.className = "searchbuttoncontainer2"; getObject("searchModesearchwidget").value = value; getObject("searchCachesearchwidget").value = value != 'adspcat'; getObject('searchtargetvalue').value=""; activeSearchsearchwidget(); } } function onSearchValueChange(value) { getObject('searchtargetvalue').value=value; onSearchTagActivate() } function buildGeoTargetQuery(value) { var query = ""; var parts = value.split("/"); var params = new Array("cc", "state", "city"); for (var i = 0; i < parts.length && i < 3; i++) { query += "&" + params[i] + "=" + parts[i]; } query += "&activevalue="+value; query += "&searchlabel="+encodeURIComponent(getObject('activesearchinput').value); return query; } function setupActiveSearch(script, input, callback) { var options_xml = { script:"", varname:"activequery", json:true, timeout:20000, minchars:3, maxheight:30, offsety:-9 }; options_xml.script = script; return new AutoSuggest(input, options_xml, callback); } function colorPaletteCallback(hexColor, colorTarget){ if (colorTarget) { getObject(colorTarget+'hex').value=hexColor; getObject(colorTarget+'colorbox').style.backgroundColor='#'+hexColor; themeDataChanged(); } } function themeDataChanged() { //if (frames['previewad'].themeDataChanged) { if (document.themeDataChangedIframe) { //frames['previewad'].themeDataChanged( document.themeDataChangedIframe( getObject('adwidth').value, getObject('adheight').value, getObject('adspthmbgimg').value, getObject('bgrepeat').value, getObject('backgroundhex').value, getObject('borderhex').value, getObject('titlehex').value, getObject('texthex').value, getObject('urlhex').value, getObject('adspthmfontfamily').value, getObject('topmargin').value, getObject('leftmargin').value, getObject('showimage').checked ); } } function adRealmColorPaletteCallback(hexColor, colorTarget){ if (colorTarget) { getObject(colorTarget+'hex').value=hexColor; getObject(colorTarget+'colorbox').style.backgroundColor='#'+hexColor; adRealmThemeDataChanged(); } } var previewWindow = null; function adRealmThemeDataChanged() { //if (frames['previewdirect'].themeDataChanged) { //if (document.themeDataChangedIframe) { //frames['previewdirect'].themeDataChanged( //document.themeDataChangedIframe( adRealmThemeDataChangedInternal( getObject('logo').value, getObject('fontfamily').value, getObject('prifgcolorhex').value, getObject('pribgcolorhex').value, getObject('secfgcolorhex').value, getObject('secbgcolorhex').value, getObject('terfgcolorhex').value, getObject('terbgcolorhex').value, getObject('linkfgcolorhex').value, getObject('linkhoverfgcolorhex').value, getObject('textcolorhex').value, getObject('bordercolorhex').value, getObject('bodybgimage').value, getObject('bodybgcolorhex').value, getObject('bodybgrepeat').value, getObject('contentbgimage').value, getObject('contentbgcolorhex').value, getObject('contentbgrepeat').value, getObject('contentbordercolorhex').value, getObject('contenttransp').value ); //} } var adRealmThemes = new Array( {logo : "http://cdn.trafficspaces.com/images/themes/classic/logo.png", fontFamily : "Trebuchet MS, Trebuchet", primaryForegroundColor : "FFFFFF", primaryBackgroundColor : "8D8D8D", secondaryForegroundColor : "3D3D3D", secondaryBackgroundColor : "F8F8F8", tertiaryForegroundColor : "8D8D8D", tertiaryBackgroundColor : "EFFBFF", headerLinkForegroundColor : "6D6D6D", headerLinkBackgroundColor : "", headerLinkHoverForegroundColor : "355A89", headerLinkHoverBackgroundColor : "EFFBFF", linkForegroundColor : "6D6D6D", linkHoverForegroundColor : "355A89", textColor : "6D6D6D", borderColor : "BFBFBF", backgroundImage : "", backgroundColor : "FFFFFF", backgroundRepeat : 0, contentBackgroundImage : "http://cdn.trafficspaces.com/images/section_gradient.jpg", contentBackgroundColor : "FFFFFF", contentBackgroundRepeat : 1, contentBorderColor : "BFBFBF", contentTransparency : "1.0"}, {logo : "http://cdn.trafficspaces.com/images/themes/pronet/logo.gif", fontFamily : "Trebuchet MS, Trebuchet", primaryForegroundColor : "D9D9D9", primaryBackgroundColor : "546149", secondaryForegroundColor : "546149", secondaryBackgroundColor : "FFFFFF", tertiaryForegroundColor : "4B5742", tertiaryBackgroundColor : "DFEBF6", headerLinkForegroundColor : "D9D9D9", headerLinkBackgroundColor : "", headerLinkHoverForegroundColor : "FFFFFF", headerLinkHoverBackgroundColor : "4B5742", linkForegroundColor : "546149", linkHoverForegroundColor : "000000", textColor: "000000", borderColor : "4F5945", backgroundImage : "http://cdn.trafficspaces.com/images/themes/pronet/bg.gif", backgroundColor : "768568", backgroundRepeat : 1, contentBackgroundImage : "", contentBackgroundColor : "F6F6F6", contentBackgroundRepeat : 0, contentBorderColor : "4F5945", contentTransparency : "1.0"}, {logo : "http://cdn.trafficspaces.com/images/themes/faveup/logo.gif", fontFamily : "Arial, Helvetica", primaryForegroundColor : "FFFFFF", primaryBackgroundColor : "1E1E1E", secondaryForegroundColor : "FFFFFF", secondaryBackgroundColor : "3E3E3E", tertiaryForegroundColor : "FFFFFF", tertiaryBackgroundColor : "C13A00", headerLinkForegroundColor : "5E5E5E", headerLinkBackgroundColor : "000000", headerLinkHoverForegroundColor : "FFFFFF", headerLinkHoverBackgroundColor : "000000", linkForegroundColor : "5E5E5E", linkHoverForegroundColor : "FFFFFF", textColor: "EEEEEE", borderColor : "5E5E5E", backgroundImage : "", backgroundColor : "000000", backgroundRepeat : 1, contentBackgroundImage : "", contentBackgroundColor : "1E1E1E", contentBackgroundRepeat : 0, contentBorderColor : "5E5E5E", contentTransparency : "1.0"}, {logo : "http://cdn.trafficspaces.com/images/themes/facebook/logo.gif", fontFamily : "Arial, Helvetica", primaryForegroundColor : "FFFFFF", primaryBackgroundColor : "3B5998", secondaryForegroundColor : "3B5998", secondaryBackgroundColor : "FFFFFF", tertiaryForegroundColor : "3B5998", tertiaryBackgroundColor : "DFE4EE", headerLinkForegroundColor : "AFBCBD", headerLinkBackgroundColor : "", headerLinkHoverForegroundColor : "FFFFFF", headerLinkHoverBackgroundColor : "", linkForegroundColor : "3B5998", linkHoverForegroundColor : "3B5998", textColor: "000000", borderColor : "B7B7B7", backgroundImage : "http://cdn.trafficspaces.com/images/themes/facebook/bg.gif", backgroundColor : "CFD6E6", backgroundRepeat : 1, contentBackgroundImage : "", contentBackgroundColor : "F7F7F7", contentBackgroundRepeat : 0, contentBorderColor : "B7B7B7", contentTransparency : "1.0"}, {logo : "http://cdn.trafficspaces.com/images/themes/mixx/logo.gif", fontFamily : "Trebuchet MS, Trebuchet", primaryForegroundColor : "FFFFFF", primaryBackgroundColor : "CD321D", secondaryForegroundColor : "CD321D", secondaryBackgroundColor : "EFFBFF", tertiaryForegroundColor : "E6F7FF", tertiaryBackgroundColor : "007195", headerLinkForegroundColor : "007195", headerLinkBackgroundColor : "", headerLinkHoverForegroundColor : "CD321D", headerLinkHoverBackgroundColor : "", linkForegroundColor : "007195", linkHoverForegroundColor : "CD321D", textColor: "007195", borderColor : "007195", backgroundImage : "http://cdn.trafficspaces.com/images/themes/mixx/bg.gif", backgroundColor : "FFFFFF", backgroundRepeat : 1, contentBackgroundImage : "", contentBackgroundColor : "FFFBDE", contentBackgroundRepeat : 0, contentBorderColor : "CD321D", contentTransparency : "1.0"}, {logo : "http://cdn.trafficspaces.com/images/themes/scrapbook/logo.gif", fontFamily : "Arial, Helvetica", primaryForegroundColor : "FFFFFF", primaryBackgroundColor : "C89D1D", secondaryForegroundColor : "4E3D18", secondaryBackgroundColor : "FFFFFF", tertiaryForegroundColor : "FFFFFF", tertiaryBackgroundColor : "6195A5", headerLinkForegroundColor : "C89D1D", headerLinkBackgroundColor : "", headerLinkHoverForegroundColor : "6195A5", headerLinkHoverBackgroundColor : "", linkForegroundColor : "6195A5", linkHoverForegroundColor : "6195A5", textColor: "4E3D18", borderColor : "C89D1D", backgroundImage : "", backgroundColor : "F5FFA0", backgroundRepeat : 0, contentBackgroundImage : "", contentBackgroundColor : "F8FFB9", contentBackgroundRepeat : 0, contentBorderColor : "C89D1D", contentTransparency : "1.0"} ); function changeRealmTheme(index) { if (index >= 0 && index < adRealmThemes.length) { getObject('logo').value = adRealmThemes[index].logo; getObject('fontfamily').value = adRealmThemes[index].fontFamily; getObject('prifgcolorhex').value = adRealmThemes[index].primaryForegroundColor; getObject('pribgcolorhex').value = adRealmThemes[index].primaryBackgroundColor != "" ? adRealmThemes[index].primaryBackgroundColor : ""; getObject('secfgcolorhex').value = adRealmThemes[index].secondaryForegroundColor; getObject('secbgcolorhex').value = adRealmThemes[index].secondaryBackgroundColor != "" ? adRealmThemes[index].secondaryBackgroundColor : ""; getObject('terfgcolorhex').value = adRealmThemes[index].tertiaryForegroundColor; getObject('terbgcolorhex').value = adRealmThemes[index].tertiaryBackgroundColor != "" ? adRealmThemes[index].tertiaryBackgroundColor : ""; getObject('linkfgcolorhex').value = adRealmThemes[index].linkForegroundColor; getObject('linkhoverfgcolorhex').value = adRealmThemes[index].linkHoverForegroundColor; getObject('textcolorhex').value = adRealmThemes[index].textColor; getObject('bordercolorhex').value = adRealmThemes[index].borderColor; getObject('bodybgimage').value = adRealmThemes[index].backgroundImage; getObject('bodybgcolorhex').value = adRealmThemes[index].backgroundColor != "" ? adRealmThemes[index].backgroundColor : ""; getObject('bodybgrepeat').value = adRealmThemes[index].backgroundRepeat; getObject('contentbgimage').value = adRealmThemes[index].contentBackgroundImage; getObject('contentbgcolorhex').value = adRealmThemes[index].contentBackgroundColor != "" ? adRealmThemes[index].contentBackgroundColor : ""; getObject('contentbgrepeat').value = adRealmThemes[index].contentBackgroundRepeat; getObject('contentbordercolorhex').value = adRealmThemes[index].contentBorderColor; getObject('contenttransp').value = adRealmThemes[index].contentTransparency; getObject('prifgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].primaryForegroundColor != "" ? adRealmThemes[index].primaryForegroundColor : "FFFFFF"); getObject('pribgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].primaryBackgroundColor != "" ? adRealmThemes[index].primaryBackgroundColor : "FFFFFF"); getObject('secfgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].secondaryForegroundColor != "" ? adRealmThemes[index].secondaryForegroundColor : "FFFFFF"); getObject('secbgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].secondaryBackgroundColor != "" ? adRealmThemes[index].secondaryBackgroundColor : "FFFFFF"); getObject('terfgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].tertiaryForegroundColor != "" ? adRealmThemes[index].tertiaryForegroundColor : "FFFFFF"); getObject('terbgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].tertiaryBackgroundColor != "" ? adRealmThemes[index].tertiaryBackgroundColor : "FFFFFF"); getObject('linkfgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].linkForegroundColor != "" ? adRealmThemes[index].linkForegroundColor : "FFFFFF"); getObject('linkhoverfgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].linkHoverForegroundColor != "" ? adRealmThemes[index].linkHoverForegroundColor : "FFFFFF"); getObject('textcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].textColor != "" ? adRealmThemes[index].textColor : "FFFFFF"); getObject('bordercolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].borderColor != "" ? adRealmThemes[index].borderColor : "FFFFFF"); getObject('bodybgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].backgroundColor != "" ? adRealmThemes[index].backgroundColor : "FFFFFF"); getObject('contentbgcolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].contentBackgroundColor != "" ? adRealmThemes[index].contentBackgroundColor : "FFFFFF"); getObject('contentbordercolorcolorbox').style.backgroundColor = "#" + (adRealmThemes[index].contentBorderColor != "" ? adRealmThemes[index].contentBorderColor : "FFFFFF"); adRealmThemeDataChanged(); } } function showColorPalette(colorTarget, callback) { if (document.showColorPaletteIframe) { //alert(colorTarget + ', ' + callback); var hexColor = getObject(colorTarget+'hex').value; if (hexColor && hexColor.length == 6) { getObject(colorTarget+'colorbox').style.backgroundColor='#'+hexColor; } window.colorChanged = (callback) ? callback : colorPaletteCallback; document.showColorPaletteIframe(hexColor, colorTarget); } } function applyStyle(parentElement, tag, className, fgColor, bgColor, fgHoverColor, bgHoverColor) { var childNodes = (tag) ? parentElement.getElementsByTagName(tag) : parentElement.childNodes; //alert('parentElement='+parentElement.id+', tag='+tag+', className='+className+', childNodes.length='+childNodes.length); for (var i = 0; i < childNodes.length; i++) { var node = childNodes[i]; //alert(node.className + ', ' + node.onmouseover); if (node.className == className) { node.style.color = (fgColor) ? fgColor : node.style.color; node.style.backgroundColor = (bgColor) ? bgColor : "transparent"; //alert(node.className + ', ' + node.onmouseover + ', ' + node.style.color + ', ' + node.style.backgroundColor); if (fgHoverColor) node.onmouseover = "this.style.color = '#" + fgHoverColor + "'"; if (bgHoverColor) node.onmouseover += "this.style.backgroundColor = '#" + bgHoverColor + "'"; } } } function adRealmThemeDataChangedInternal( logoURL, fontFamily, primaryFgColor, primaryBgColor, secondaryFgColor, secondaryBgColor, tertiaryFgColor, tertiaryBgColor, linkFgColor, linkHoverFgColor, textColor, borderColor, bodyBgImage, bodyBgColor, bodyBgRepeat, contentBgImage, contentBgColor, contentBgRepeat, contentBorderColor, contentTransparency) { var logoIMG = getObject('mainlogo'); if (logoURL) { logoIMG.style.display = "inline"; logoIMG.src = logoURL; } else { logoIMG.style.display = "none"; } var body = getObject('body'); body.style.fontFamily = fontFamily; var primaryMenu = getObject('primary'); applyStyle(primaryMenu, "a", "activemenu", primaryFgColor, primaryBgColor); applyStyle(primaryMenu, "a", "", secondaryFgColor, secondaryBgColor); var secondaryMenu = getObject('secondary'); secondaryMenu.style.backgroundColor = primaryBgColor; applyStyle(secondaryMenu, "a", "activelink", tertiaryFgColor, tertiaryBgColor); applyStyle(secondaryMenu, "a", "", primaryFgColor, primaryBgColor); applyStyle(body, "input", "button", secondaryFgColor, secondaryBgColor); var themeSamples = getObject('themesamples_data'); applyStyle(themeSamples, "b", "rdcr2", secondaryFgColor, secondaryBgColor); applyStyle(themeSamples, "b", "rdcr3", secondaryFgColor, secondaryBgColor); applyStyle(themeSamples, "b", "rdcr4", secondaryFgColor, secondaryBgColor); applyStyle(themeSamples, "em", "softer", secondaryFgColor, secondaryBgColor); applyStyle(themeSamples, "div", "rdcrcontent", secondaryFgColor, secondaryBgColor); applyStyle(body, "div", "toolbar", textColor); body.style.color = textColor; body.style.backgroundImage = "url('" + bodyBgImage + "')"; body.style.backgroundColor = bodyBgColor; body.style.backgroundRepeat = (bodyBgRepeat == 0) ? "no-repeat" : ((bodyBgRepeat == 1) ? "repeat-x" : ((bodyBgRepeat == 2) ? "repeat-y" : "repeat")); var contentPane = getObject('contentpane'); contentPane.style.backgroundImage = "url('" + contentBgImage + "')"; contentPane.style.backgroundColor = contentBgColor; contentPane.style.backgroundRepeat = (contentBgRepeat == 0) ? "no-repeat" : ((contentBgRepeat == 1) ? "repeat-x" : ((contentBgRepeat == 2) ? "repeat-y" : "repeat")); contentPane.style.borderWidth = "1px"; contentPane.style.borderStyle = "solid"; contentPane.style.borderColor = contentBorderColor; if (true || contentPane.style.filter) { //alert('filter=' + contentPane.style.filter + ', ' + contentTransparency); contentPane.style.filter = "Alpha(opacity=" + (contentTransparency * 100.0) + ")"; } if (contentPane.style.opacity) { alert('opacity=' + contentPane.style.opacity + ', ' + contentTransparency); contentPane.style.opacity = contentTransparency; } }