onerror = handleErr; function handleErr(d, c, a) { createCookie("JS_ERROR", "||m" + d + "||l" + a + "||b" + navigator.appName + "||v" + navigator.userAgent + "||u" + c) } function createCookie(d, f, e, g) { var c = new Date(); c.setTime(c.getTime() + (100 * 24 * 60 * 60 * 1000)); var a = "; expires=" + c.toGMTString(); document.cookie = d + "=" + escape(f) + a + "; path=/" } function getSuffix(a) { suffix = a.name.replace(/^(Entry_|Entry)/ig, ""); if (suffix && suffix.length) { suffix = "_" + suffix } else { suffix = "" } return suffix } function getDocRoot() { if (typeof act_get_json_location == "undefined") { return "/" } else { return act_get_json_location } } function checkForm(a) { suffix = getSuffix(a); if (document.getElementById("ZIP_CODE_t" + suffix)) { document.getElementById("ZIP_CODE_t" + suffix).style.color = "" } if (document.getElementById("ZIP_CODE_tt" + suffix)) { document.getElementById("ZIP_CODE_tt" + suffix).style.color = "" } if (a.ZIP_CODE && (a.ZIP_CODE.value.length != 5 || !isFinite(a.ZIP_CODE.value))) { alert("Zip Code: has not been entered."); if (document.getElementById("ZIP_CODE_t" + suffix)) { document.getElementById("ZIP_CODE_t" + suffix).style.color = "red" } if (document.getElementById("ZIP_CODE_tt" + suffix)) { document.getElementById("ZIP_CODE_tt" + suffix).style.color = "red" } a.ZIP_CODE.focus(); return false } if (document.getElementById("A_1_YEAR_t" + suffix)) { document.getElementById("A_1_YEAR_t" + suffix).style.color = "" } if (document.getElementById("A_1_YEAR_tt" + suffix)) { document.getElementById("A_1_YEAR_tt" + suffix).style.color = "" } if (a.A_1_YEAR && (a.A_1_YEAR.options[a.A_1_YEAR.selectedIndex].value.length != 4 || !isFinite(a.A_1_YEAR.options[a.A_1_YEAR.selectedIndex].value))) { alert("Year: has not been selected."); if (document.getElementById("A_1_YEAR_t" + suffix)) { document.getElementById("A_1_YEAR_t" + suffix).style.color = "red" } if (document.getElementById("A_1_YEAR_tt" + suffix)) { document.getElementById("A_1_YEAR_tt" + suffix).style.color = "red" } a.A_1_YEAR.focus(); return false } choose_list = "A_1_MANUFACTURER|A_1_MODEL|A_1_SUBMODEL|OWN_OR_RENT|PROPERTY_TYPE|PRODUCT_TYPE"; choose_list = choose_list.split("|"); for (x = 0; x < choose_list.length; x++) { choose = choose_list[x]; if (document.getElementById(choose + "_t" + suffix)) { document.getElementById(choose + "_t" + suffix).style.color = "" } if (document.getElementById(choose + "_tt" + suffix)) { document.getElementById(choose + "_tt" + suffix).style.color = "" } if (a[choose] && a[choose].options && a[choose].options[a[choose].selectedIndex].value == "Choose") { choose_name = choose.replace(/A_1_/ig, "").replace(/_/g, " "); alert(choose_name + ": has not been selected."); if (document.getElementById(choose + "_t" + suffix)) { document.getElementById(choose + "_t" + suffix).style.color = "red" } if (document.getElementById(choose + "_tt" + suffix)) { document.getElementById(choose + "_tt" + suffix).style.color = "red" } a[choose].focus(); return false } } if (a.HAS_INSURANCE) { thisOption = -1; for (c = a.HAS_INSURANCE.length - 1; c > -1; c--) { if (a.HAS_INSURANCE[c].checked) { thisOption = c } } if (document.getElementById("HAS_INSURANCE_t" + suffix)) { document.getElementById("HAS_INSURANCE_t" + suffix).style.color = "" } if (document.getElementById("HAS_INSURANCE_tt" + suffix)) { document.getElementById("HAS_INSURANCE_tt" + suffix).style.color = "" } if (thisOption == -1) { alert("Do you currently have insurance coverage? has not been selected."); if (document.getElementById("HAS_INSURANCE_t" + suffix)) { document.getElementById("HAS_INSURANCE_t" + suffix).style.color = "red" } if (document.getElementById("HAS_INSURANCE_tt" + suffix)) { document.getElementById("HAS_INSURANCE_tt" + suffix).style.color = "red" } return false } } if (a.OWN_OR_RENT) { rentflag = a.OWN_OR_RENT.options[a.OWN_OR_RENT.selectedIndex].value; if (thisOption == 1 && rentflag == "OWN") { thisOption = -1; for (c = a.NEW_HOME.length - 1; c > -1; c--) { if (a.NEW_HOME[c].checked) { thisOption = c } } if (document.getElementById("NEW_HOME_t" + suffix)) { document.getElementById("NEW_HOME_t" + suffix).style.color = "" } if (document.getElementById("NEW_HOME_tt" + suffix)) { document.getElementById("NEW_HOME_tt" + suffix).style.color = "" } if (thisOption == -1) { alert("Is this policy for a newly purchased home? has not been selected."); if (document.getElementById("NEW_HOME_t" + suffix)) { document.getElementById("NEW_HOME_t" + suffix).style.color = "red" } if (document.getElementById("NEW_HOME_tt" + suffix)) { document.getElementById("NEW_HOME_tt" + suffix).style.color = "red" } if (document.getElementById("newhome_question" + suffix)) { document.getElementById("newhome_question" + suffix).style.display = "block" } return false } } } choose_list = "FIRST_NAME,0|LAST_NAME,0|CompanyName,0|Website,0|PRIMARY_PHONE_AREA,2|PRIMARY_PHONE_PREFIX,2|PRIMARY_PHONE_SUFFIX,3|EMAIL,4|STATE,0,|COUNTY,0|zip_code,4|COMPANY,0|HEARD_VIA,0|details,0"; choose_list = choose_list.split("|"); for (x = 0; x < choose_list.length; x++) { choose = choose_list[x].split(","); choose_length = choose[1]; choose = choose[0]; if (document.getElementById(choose + "_t" + suffix)) { document.getElementById(choose + "_t" + suffix).style.color = "" } if (document.getElementById(choose + "_tt" + suffix)) { document.getElementById(choose + "_tt" + suffix).style.color = "" } if (a[choose] && a[choose].type != "hidden" && a[choose].value.length <= choose_length) { choose_name = choose.replace(/A_1_/ig, "").replace(/_/g, " "); alert(choose_name + ": has not been entered."); if (document.getElementById(choose + "_t" + suffix)) { document.getElementById(choose + "_t" + suffix).style.color = "red" } if (document.getElementById(choose + "_tt" + suffix)) { document.getElementById(choose + "_tt" + suffix).style.color = "red" } a[choose].focus(); return false } } if (a.EMAIL && !validateEmail(a.EMAIL.value)) { alert("Valid Email has not been entered."); a.EMAIL.focus(); return false } if (a.lead_type) { found_lead_type = ""; for (var c = 0; c < a.lead_type.length; c++) { if (a.lead_type[c].checked) { found_lead_type = a.lead_type[c].value } } if (found_lead_type == "") { alert("What types of leads are you looking for has not been answered."); return false } } if (a.action && (a.action == "none.cfm" || a.action.search("none.cfm") != -1)) { a.action = getDocRoot() + "index.cfm" } if (typeof(setBool) != "undefined") { setBool() } return true } function validateEmail(a) { rex = true; if (window.RegExp) { st = "a"; ex = new RegExp(st); if (st.match(ex)) { r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)"); r2 = new RegExp("^([a-zA-Z0-9]|\\.|\\-|\\_)+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"); b = (!r1.test(a) && r2.test(a)) } else { rex = false } } else { rex = false } if (!rex) { b = (a.indexOf("@") > 0 && a.indexOf(".") > 0 && a != "" && a != "enter e-mail") } return (b) } var doProduct = function(a) { if (a.PRODUCT_TYPE) { ptype = a.PRODUCT_TYPE.value; if (ptype == "HOME") { a.openaction.value = "home" } else { if (ptype == "AUTO") { a.openaction.value = "auto" } } if (ptype == "RENTERS") { a.openaction.value = "renters" } } }; function numeralsOnly(c) { c = (c) ? c : event; var a = (c.charCode) ? c.charCode : ((c.keyCode) ? c.keyCode : ((c.which) ? c.which : 0)); var d = c.target ? c.target.id : c.srcElement.id; if (a > 31 && (a < 48 || a > 57)) { if (document.getElementById && document.getElementById("canadian_message") && "ZIP_CODE_f" == d) { document.getElementById("canadian_message").style.display = "" } return false } else { if (document.getElementById && document.getElementById("canadian_message") && "ZIP_CODE_f" == d) { document.getElementById("canadian_message").style.display = "none" } } return true } function changePropType(a) { flag = a.OWN_OR_RENT.value; pdrop = a.PROPERTY_TYPE; pdrop.options[0] = new Option("Select one", "Choose"); if (flag == "OWN") { pdrop.options.length = 1; pdrop.options[0] = new Option("Select one", "Choose"); pdrop.options[1] = new Option("Single-Family Home", "SINGLE_FAMLY"); pdrop.options[2] = new Option("Condo", "CONDO"); pdrop.options[3] = new Option("Town Home", "TOWNHOME"); pdrop.options[4] = new Option("Mobile Home", "MOBILE") } if (flag == "RENT") { pdrop.options.length = 1; pdrop.options[0] = new Option("Select one", "Choose"); pdrop.options[1] = new Option("Single-Family Home", "SINGLE_FAMLY"); pdrop.options[2] = new Option("Apartment", "APARTMENT"); pdrop.options[3] = new Option("Town Home", "TOWNHOME"); pdrop.options[4] = new Option("Mobile Home", "MOBILE"); if (document.getElementById("newhome_question" + suffix)) { document.getElementById("newhome_question" + suffix).style.display = "none" } } a.PROPERTY_TYPE.value = "Choose" } function askNewHome(a) { suffix = getSuffix(a); if (document.getElementById("newhome_question" + suffix)) { document.getElementById("newhome_question" + suffix).style.display = "none" } rentflag = a.OWN_OR_RENT.options[a.OWN_OR_RENT.selectedIndex].value; newflag = ""; for (i = a.HAS_INSURANCE.length - 1; i > -1; i--) { if (a.HAS_INSURANCE[i].checked) { newflag = a.HAS_INSURANCE[i].value } } if (newflag == "NO" && rentflag == "OWN") { if (document.getElementById("newhome_question" + suffix)) { document.getElementById("newhome_question" + suffix).style.display = "block" } } } function yearDrop(c, g) { drop = c[g]; if (drop) { var f = new Date(); theYear = f.getFullYear(); years = new Array(2 + theYear - 1982); for (var a = 0; a < years.length; a++) { var e = document.createElement("OPTION"); e.value = theYear - a + 1; e.innerHTML = theYear - a + 1; drop.appendChild(e) } } } var whoRef = function(a) { if (a.HEARD_VIA.value == "Referral") { document.getElementById("whoRe").style.display = "block" } else { document.getElementById("whoRe").style.display = "none" } }; var removeGroupsFromDrop = function(a) { var c = document.getElementById(a); for (var d = 0; d < c.childNodes.length; d++) { if (c.childNodes[d].tagName == "OPTGROUP") { c.removeChild(c.childNodes[d]) } } }; var clearDrop = function(a) { var e = document.getElementById(a); removeGroupsFromDrop(a); while (e.options.length > 0) { e.options[0] = null } var d = document.createElement("OPTION"); d.value = "Choose"; d.innerHTML = "Select one"; e.appendChild(d); var c = document.createElement("OPTGROUP"); switch (a.split("_")[2]) { case "MANUFACTURER": c.label = "Select Model Year to Continue"; break; case "MODEL": c.label = "Select Make to Continue"; break; case "SUBMODEL": c.label = "Select Model to Continue"; break } e.appendChild(c) }; var responseSuccessJson = function(o) { results = o.responseText; eval("results = " + results); drop = document.getElementById(o.argument[0]); clearDrop(o.argument[0]); removeGroupsFromDrop(o.argument[0]); for (var x = 0; x < results.data.length; x++) { var oOption = document.createElement("OPTION"); oOption.value = results.data[x].value; oOption.innerHTML = results.data[x].name; drop.appendChild(oOption) } }; var responseFailureJson = function(a) { alert("Failure JSON " + a.argument[0]) }; function doAUTO(a, c) { id_val = document.getElementById(a).value; suffix = getSuffix(c); cleanID = a.replace(/(YEAR_f|MANUFACTURER_f|MODEL_f|SUBMODEL_f)/i, "CLEAN"); goYearID = cleanID.replace(/CLEAN/, "YEAR_f"); goMakeID = cleanID.replace(/CLEAN/, "MANUFACTURER_f"); goModelID = cleanID.replace(/CLEAN/, "MODEL_f"); goSubModelD = cleanID.replace(/CLEAN/, "SUBMODEL_f"); if (a == goYearID) { clearDrop(goMakeID); clearDrop(goModelID); clearDrop(goSubModelD); field = "MANUFACTURER"; arg = goMakeID } if (a == goMakeID) { clearDrop(goModelID); clearDrop(goSubModelD); field = "model"; arg = goModelID } if (a == goModelID) { clearDrop(goSubModelD); field = "submodel"; arg = goSubModelD } if (!id_val || id_val == "" || id_val == "Choose") { return } var e = { success: responseSuccessJson, failure: responseFailureJson, argument: [arg, field] }; goYear = document.getElementById(goYearID).options[document.getElementById(goYearID).selectedIndex].value; goMake = document.getElementById(goMakeID).options[document.getElementById(goMakeID).selectedIndex].value; goModel = document.getElementById(goModelID).options[document.getElementById(goModelID).selectedIndex].value; go2url = getDocRoot() + "act_get_json.cfm?field=" + field + "&MODEL=" + escape(goModel) + "&YEAR=" + escape(goYear) + "&MANUFACTURER=" + escape(goMake); var d = YAHOO.util.Connect.asyncRequest("get", go2url, e, null) } function doGEO(ZIPCode, func) { var callback = { success: function(o) { results = o.responseText; eval("results = " + results); func(results) }, failure: function() { alert("failed") } }; go2url = getDocRoot() + "act_get_json.cfm?field=GEO&ZIP_CODE=" + escape(ZIPCode); var cObj = YAHOO.util.Connect.asyncRequest("get", go2url, callback, null) } function getCookie(a) { if (document.cookie.length > 0) { c_start = document.cookie.indexOf(a + "="); if (c_start != -1) { c_start = c_start + a.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) { c_end = document.cookie.length } return unescape(document.cookie.substring(c_start, c_end)) } } return "" };
