// 0) && (mmloaded > 0)) { build_makes(document.inventory_form) if (MakeIndex) { document.inventory_form.feature_includes_make.options[MakeIndex].selected = true; set_models(document.inventory_form,MakeIndex); document.inventory_form.feature_includes_model.options[ModelIndex].selected = true; } document.inventory_form.zip.value=CookieZip; document.power_search_form.zip.value=CookieZip; clearInterval(initInterval); } } function validateQuickSearch(f) { var errors = 0; var exp = new Date(); var oneYearFromNow = exp.getTime() + (365 * 24 * 60 * 60 * 1000); exp.setTime(oneYearFromNow); if (f.zip) { var zip = f.zip.value; var validzip = /[0-9]{5}/; var validzipresult = zip.match(validzip); if (f.zip.value == "") { errors = errors + 1; alert("Please enter a ZIP code."); f.zip.focus(); return false; } else if (!validzipresult) { errors = errors + 1; alert("You must enter a zip code. Please use '30303' as the default."); f.zip.focus(); return false; } } if (f.feature_includes_make.selectedIndex <= 0) { errors = errors + 1; alert("Please select a Make."); f.feature_includes_make.focus(); return false; } if (f.feature_includes_model.selectedIndex <= 0) { errors = errors + 1; alert("Please select a Model."); f.feature_includes_model.focus(); return false; } if (errors < 1) { MakeIndex = f.feature_includes_make.selectedIndex; ModelIndex = f.feature_includes_model.selectedIndex; zip = f.zip.value; document.cookie = "MakeIndex="+MakeIndex+";expires=" + exp.toGMTString(); document.cookie = "ModelIndex="+ModelIndex+";expires=" + exp.toGMTString(); document.cookie = "zip="+zip+";expires=" + exp.toGMTString(); f.submit(); } } function getCookieData(label) { var labelLen = label.length; var cLen = document.cookie.length; var i = 0; while (i < cLen) { var j = i + labelLen; if (document.cookie.substring(i,j) == label) { var cEnd = document.cookie.indexOf(";",j); if (cEnd == -1) { cEnd = document.cookie.length; } var k = j+1; return unescape(document.cookie.substring(k,cEnd)); } i++; } return ""; } function validatePowerSearch(f) { var errors = 0; var error_txt = ''; if (f.zip) { var zip = f.zip.value; var validzip = /[0-9]{5}/; var validzipresult = zip.match(validzip); if (f.zip.value == "") { errors = errors + 1; error_txt += "Please enter a ZIP code.\n"; f.zip.focus(); } else if (!validzipresult) { errors = errors + 1; error_txt += "You must enter a zip code. Please use '30303' as the default.\n"; f.zip.focus(); } } if ((f.max_year.options[f.max_year.selectedIndex].value > 0) && (f.min_year.options[f.min_year.selectedIndex].value > f.max_year.options[f.max_year.selectedIndex].value)) { errors = errors + 1; error_txt += "End Year is less than Start Year.\n"; } if ((f.max_mileage.options[f.max_mileage.selectedIndex].value > 0) && (f.min_mileage.options[f.min_mileage.selectedIndex].value > f.max_mileage.options[f.max_mileage.selectedIndex].value)) { errors = errors + 1; if (f.min_mileage.options[f.min_mileage.selectedIndex].value != "75000") { error_txt += "Max Mileage is less than Min Mileage.\n"; } } if ((parseInt(f.max_price.options[f.max_price.selectedIndex].value) > 0) && (parseInt(f.min_price.options[f.min_price.selectedIndex].value) > parseInt(f.max_price.options[f.max_price.selectedIndex].value))) { errors = errors + 1; error_txt += "Max Price ("+ f.max_price.options[f.max_price.selectedIndex].value +") is less than Min Price ("+ f.min_price.options[f.min_price.selectedIndex].value +").\n"; } if (errors < 1) { f.submit(); } else { alert(error_txt); return false; } f.make_tmp.value=''; f.model_tmp.value=''; } function validateDealerSearchByZip(f) { var errors = 0; var error_txt = ''; if (f.zip) { var zip = f.zip.value; var validzip = /[0-9]{5}/; var validzipresult = zip.match(validzip); if (f.zip.value == "") { errors = errors + 1; error_txt += "Please enter a ZIP code.\n"; f.zip.focus(); } else if (!validzipresult) { errors = errors + 1; error_txt += "You must enter a zip code. Please use '30303' as the default.\n"; f.zip.focus(); } } if (errors < 1) { f.submit(); } else { alert(error_txt); return false; } } function validateDealerSearchById(f) { var errors = 0; var error_txt = ''; if (f.dealer_id) { if (f.dealer_id.value == "") { errors = errors + 1; error_txt += "Please select a dealer.\n"; } } if (errors < 1) { f.submit(); } else { alert(error_txt); return false; } } function showId(a) { if (document.getElementById) { document.getElementById(a).className = 'show'; } else { return false; } } function hideId(a) { if (document.getElementById) { document.getElementById(a).className = 'hide'; } else { return false; } } function showTags(a) { if (document.getElementsByTagName) { var tagArr = document.getElementsByTagName(a); for (var iCounter=0; iCounter 0) { for(i in Makes[Num]) { if(Makes[Num][i] == 'All') { model_all = 1; } f.feature_includes_model.options[f.feature_includes_model.length] = new Option(Makes[Num][i],Makesv[Num][i]); } if(model_all == 1) { lcnt = Makes[Num].length+1; } else { lcnt = Makes[Num].length; } f.feature_includes_model.options[0].selected="true"; f.feature_includes_model.length=lcnt; } } function build_makes_tmp(f,x) { //used for power search f.make_tmp.length=0; f.make_tmp.options[0] = new Option("=== Select a Make ===",""); for (i=1; i 0) { for(i in Makes[Num]) { if(Makes[Num][i] == 'All') { model_all = 1; } f.model_tmp.options[f.model_tmp.length] = new Option(Makes[Num][i],Makesv[Num][i]); } if(model_all == 1) { lcnt = Makes[Num].length+1; } else { lcnt = Makes[Num].length; } f.model_tmp.options[0].selected="true"; f.model_tmp.length=lcnt; } } var vcount=0; //used for power search addVehicle function function addVehicle(i,j) { //used for power search //initialize our variables var a=document.inventory_form.make_tmp.options[i].value; var b=document.inventory_form.model_tmp.options[j].text; var c=document.inventory_form.model_tmp.options[j].value; var check_vehiclelist_item=a + " - " + b; var new_vehiclelist_item=vcount+1 + ". " + a + " - " + b; var duplicate_item=0; //if the maximum number of vehicles hasn't been reached... if (vcount < 6) { //check to make sure this is not a duplicate vehicle for (var k=0; k < document.inventory_form.vehiclelist.length; k++) { var vehiclelist_item=document.inventory_form.vehiclelist.options[k].text.split(". "); if (check_vehiclelist_item == vehiclelist_item[1]) { duplicate_item++; } } //if it's not a duplicate vehicle... if (duplicate_item < 1) { //add the make to our list document.inventory_form.feature_includes_make.value=document.inventory_form.feature_includes_make.value+","+a; //if it's a particular model... if (c) { //add the model to our list document.inventory_form.feature_includes_model.value=document.inventory_form.feature_includes_model.value+","+c; } //otherwise the default is all models so no need to add it else { } //show the user's selection to the user document.inventory_form.vehiclelist.options[vcount].text=new_vehiclelist_item; //increment our list counter vcount++; } } else { alert('Six is the maximum number of vehicles you can search for at once.'); } } //end function function imposeMaxLength(Object,MaxLen) { return (Object.value.length <= MaxLen); } function validateContactInfo(f) { emailRegExp = new RegExp("@.*\.[a-z]{3}", "gi"); for (var i = 0; i < f.elements.length; i++) { if (f.elements[i].type == 'text') { if (f.elements[i].value == '' ) { alert("These fields are required: \nFirst Name\nLast Name\nPreferred Contact\nEmail\nPhone"); return false; } } } if (!isValidEmail(f.cf_email.value)) { window.alert("Please enter a valid email address."); f.cf_email.focus(); return false; } return true; } // Use this version for testing purposes function validateContactInfoB(f) { emailRegExp = new RegExp("@.*\.[a-z]{3}", "gi"); // Check to see if name field is blank if (f.formfield.value == "") { alert("These fields are required: \nName\nEmail or Phone Number"); return false; } // Check to see if phone field is blank - if so it checks to see if email field is blank if (f.formfield4.value == "") { if (f.cf_email.value == "" ) { alert("These fields are required: \nName\nEmail or Phone Number"); return false; } // Validate Email Address if (!isValidEmail(f.cf_email.value)) { window.alert("Please enter a valid email address."); f.cf_email.focus(); return false; } return true; } // Check to see if email field is blank - if so it checks to see if phone field is blank if (f.cf_email.value == "") { if (f.formfield4.value == "" ) { alert("These fields are required: \nName\nEmail or Phone Number"); return false; } } } function isValidEmail(str) { // check that regular expressions are supported var bSupported = 0; if (window.RegExp) { var tempStr = "a"; var tempReg = new RegExp(tempStr); if (tempReg.test(tempStr)) { bSupported = 1; } } if (!bSupported) { return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); } var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)"); var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"); return (!r1.test(str) && r2.test(str)); } function disableElement(e) { e.disabled=true; e.readonly=true; } function enableElement(e) { e.disabled=false; e.readonly=false; } function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //]]>