function GenericBanner() { var baseurl = "http://www.designingonline.com/"; this.destinationLink = baseurl+"quote.html"; this.fontStyle = "Verdana"; this.fontColor = "black"; this.bannerWidth = "365px"; this.bannerHeight = ""; this.backgroundColor = "transparent"; this.backgroundImage = ""; this.borderColor = "black"; this.borderThickness = "1px"; this.titleText = "Start Your Project Today!"; this.titleColor = "orange"; this.titleSize = "22px"; this.selectSize = 6; this.questionColor = "purple"; this.questionServiceText = "Service Requested"; this.questionOwnerText = "Are you a home owner?"; this.questionZipText = "What is your zip?"; this.ctaBackground = "green"; this.ctaBorderColor = "black"; this.ctaBorderThickness = "1px"; this.ctaText = "Get Started"; this.ctaTextSize = "12px"; this.ctaTextColor = "white"; this.ctaAlign = "right"; this.sectionOneWidth = "185px"; this.sectionTwoWidth = ""; this.sectionThreeWidth = ""; this.preSelectedService = "CABINET_REFACING"; this.createBanner = function(){ document.write("

"+this.titleText+"

"+this.questionServiceText+"

"+this.questionOwnerText+"

Yes No

"+this.questionZipText+"

"); var serviceDropdownList = document.forms["generic"]["servicescheckbox"]; for (iLoop = 0; iLoop < serviceDropdownList.options.length; iLoop++){ if (serviceDropdownList.options[iLoop].value == this.preSelectedService){ serviceDropdownList.options[iLoop].selected = true; break; } } document.forms["generic"].onsubmit = this.validateBanner; return false; }; this.validateBanner = function(){ var message = document.getElementById("gmessage"); var zipPattern = /^[0-9]{5,}$/; var elements = document.forms["generic"].elements; for(var i = 0; i < elements.length; i++){ if(/(^| )required( |$)/.test(elements[i].className) && elements[i].value == ""){ elements[i].focus(); message.innerHTML = "Please select the "+elements[i].title; return false; } if (/(^| )validzip( |$)/.test(elements[i].className) && !zipPattern.test(elements[i].value)) { elements[i].focus(); message.innerHTML = "Please fill in a valid postal code"; return false; } } return true; }; } var generic = new GenericBanner(); generic.createBanner();