$(document).ready(function(){var a=[{image:"img_sfca_heroJessica.jpg",alt:"Fast, helpful service right in your neighbourhood."},{image:"img_sfca_heroJessicaAgents.jpg",alt:"Our agents keep you out of a State of Regret."},{image:"img_sfca_heroJessicaRegrets.jpg",alt:"Goodbye, regret. Hello, State Farm."}],b=Math.floor(Math.random()*a.length);$("#staticHero div").html('<img src="_homepage/_images/homepage/images/'+a[b].image+'" width="728" height="277" alt="'+a[b].alt+'" />');$("#userID").inputHint();$("#password").inputHint();$("#sAgentZip").inputHint();$("#searchBox").searchBox();$("#hotTabZone").tabify({hideClass:"hidden",orientation:"vertical",handler:"click"});$("input:radio").razorRadioButton({defaultClass:"styledRadioButton",checkedClass:"on",disabledClass:"disabled",hideClass:"hidden",labelFocusClass:"focus"});$("input:checkbox").razorCheckBox({styledCheckboxClass:"styledCheckBox",checkedClass:"on",disabledClass:"disabled",hideClass:"hidden",focusClass:"focus"});$("#onlineSecurity").click(function(d){d.preventDefault();$("#modalOnlineSecurity").modal({close:false,focus:false,persist:true});$("#onlineSecurityHdr").attr({tabIndex:"0"}).focus()});if($.browser.mozilla){$("ccForm").attr("autocomplete","off")}document.getElementById("autoRadio").checked;var c=$("#primaryNav");$("li",c).mouseover(function(){$(this).addClass("sfhover")}).mouseout(function(){$(this).removeClass("sfhover")});$("a",c).focus(function(){$(this).parents("li").addClass("sfhover")}).blur(function(){$(this).parents("li").removeClass("sfhover")})});$(document).ready(function(){setupControls()});function setupControls(){$("input:radio").addClass("radio");$("input:radio").wrap('<div class="radio"></div>');$("input:radio").change(updateControls);updateControls()}function updateControls(){$("input:radio").parent().removeClass("checked");$("input:radio:checked").parent().addClass("checked")}if(window.addEventListener){window.addEventListener("load",checkError,false);window.addEventListener("unload",resetFld,false)}else{if(window.attachEvent){window.attachEvent("onload",checkError);window.attachEvent("onunload",resetFld)}else{if(document.getElementById){window.onload=checkError;window.onunload=resetFld}}}$(document).ready(function(){setupControls()});function setupControls(){$("input:radio").addClass("radio");$("input:radio").wrap('<div class="radio"></div>');$("input:radio").change(updateControls);updateControls()}function updateControls(){$("input:radio").parent().removeClass("checked");$("input:radio:checked").parent().addClass("checked")}function checkError(){var a="";if(a=="true"){if(document.getElementById("errMsgCnt").value==""){document.getElementById("errMsgCnt").value="true";document.getElementById("rateQuoteZipErrorMsg").style.display="block"}}}function resetFld(){document.getElementById("rateQuoteZipErrorMsg").style.display="none"}function trackQuoteForm(){var c=document.getElementById("sType");var d=c.selectedIndex;var e=c.options[d].text;var f=document.getElementById("sZip").value;var b="/HP_QForm/";var a="?quoteZip="+f+"&quoteType="+e;dcsMultiTrack("DCS.dcsuri",b,"DCSext.dcsqry",a,"WT.ti","Quote Form Submission")}function isValidateZip(){var g=document.getElementById("getRateQuoteForm").instate.value;var f=/(^\d{5}$)/;var e=/^([abceghjklmnprstvxyABCEGHJKLMNPRSTVXY][0-9][abceghjklmnprstvwxyzABCEGHJKLMNPRSTVWXYZ])\s*([0-9][abceghjklmnprstvwxyzABCEGHJKLMNPRSTVWXYZ][0-9])$/;var d,c;g=Ltrim(g);g=Rtrim(g);document.getElementById("getRateQuoteForm").instate.value=g;d=f.test(g);c=e.test(g);if(d||c){if(c){g=g.toUpperCase();g=g.replace(/\s+/g,"");document.getElementById("getRateQuoteForm").instate.value=g}return true}else{document.getElementById("rateQuoteZipErrorMsg").style.display="block";document.getElementById("rateQuoteZipErrorMsg").innerText="Please enter a valid Postal Code";document.getElementById("rateQuoteZipErrorMsg").style.position="absolute";var a,b;a=document.getElementById("getRateQuoteForm").instate.offsetLeft;b=document.getElementById("getRateQuoteForm").instate.offsetTop;return false}}function Ltrim(a){return a.replace(/^\s*/,"")}function Rtrim(a){return a.replace(/\s*$/,"")}function doSubmit(){if(location.href.indexOf("index")>0){if(document.getElementById("rateQuoteZipErrorMsg").style.display=="none"){dcsMultiTrack("DCS.dcsuri","/HP_Quote.clk","WT.ti","Home Page Quote Click")}}if((document.getElementById("getRateQuoteForm").instate.value=="Postal Code")||(document.getElementById("getRateQuoteForm").instate.value=="")){switch(document.getElementById("getRateQuoteForm").quotetype.value){case"ARQ":document.getElementById("rateQuoteZipErrorMsg").style.display="inline";document.getElementById("rateQuoteZipErrorMsg").innerText="Please enter your Postal Code";document.getElementById("rateQuoteZipErrorMsg").style.position="absolute";return false;break;case"HOW":document.getElementById("rateQuoteZipErrorMsg").style.display="inline";document.getElementById("rateQuoteZipErrorMsg").innerText="Please enter your Postal Code";document.getElementById("rateQuoteZipErrorMsg").style.position="absolute";return false;break;case"CRQ":document.getElementById("rateQuoteZipErrorMsg").style.display="inline";document.getElementById("rateQuoteZipErrorMsg").innerText="Please enter your Postal Code";document.getElementById("rateQuoteZipErrorMsg").style.position="absolute";return false;break;case"RRQ":document.getElementById("rateQuoteZipErrorMsg").style.display="inline";document.getElementById("rateQuoteZipErrorMsg").innerText="Please enter your Postal Code";document.getElementById("rateQuoteZipErrorMsg").style.position="absolute";return false;break;case"LRQ":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/quote/life.htm";break;case"HRQ":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/apps/hrq_health/health_welcome.asp";break;case"DSB":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/disability/disability.asp";break;case"LTCRQ":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/apps/hrq/welcomeltc_01.asp";break;case"BURQ":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/business/business.asp";break;case"BRQ":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/boat/boat.asp";break;case"other":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/other/other.asp";break;default:document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/other/other.asp";break}}else{switch(document.getElementById("getRateQuoteForm").quotetype.value){case"ARQ":if(!(isValidateZip())){return false}else{document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/apps/InsuranceApp/S1AppSelector.asp?appname=ARQ";document.getElementById("getRateQuoteForm").method="POST";document.getElementById("getRateQuoteForm").submit()}break;case"HOW":if(!(isValidateZip())){return false}else{document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/apps/InsuranceApp/S1AppSelector.asp?appname=HOW";document.getElementById("getRateQuoteForm").method="POST";document.getElementById("getRateQuoteForm").submit()}break;case"CRQ":if(!(isValidateZip())){return false}else{document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/apps/InsuranceApp/S1AppSelector.asp?appname=CRQ";document.getElementById("getRateQuoteForm").method="POST";document.getElementById("getRateQuoteForm").submit()}break;case"RRQ":if(!(isValidateZip())){return false}else{document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/apps/InsuranceApp/S1AppSelector.asp?appname=RRQ";document.getElementById("getRateQuoteForm").method="POST";document.getElementById("getRateQuoteForm").submit()}break;case"LRQ":document.getElementById("getRateQuoteForm").action="https://online.statefarm.com/apps/lrq3/lrq.asp";break;case"HRQ":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/apps/hrq_health/health_welcome.asp";break;case"DSB":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/disability/disability.asp";break;case"LTCRQ":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/apps/hrq/welcomeltc_01.asp";break;case"BURQ":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/business/business.asp";break;case"BRQ":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/boat/boat.asp";break;case"other":document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/other/other.asp";break;default:document.getElementById("getRateQuoteForm").action="http://www.statefarm.com/insurance/other/other.asp";break}}}var running=true;var interval=4000;var nextViewIndex=-1;function spiffAutoScroll(){if(running){var d=document.getElementById("hotSpiffTabs");if(d==null){return}var b=d.getElementsByTagName("a");for(var e=0;e<b.length;e++){if(nextViewIndex>=0){if(nextViewIndex==e){var a=b[e].id;b[e].className="active";var c=a.replace("tab","zone");document.getElementById(c).className="visible"}else{var a=b[e].id;b[e].className="non-active";var c=a.replace("tab","zone");document.getElementById(c).className="hidden"}}if(nextViewIndex==-1&&((b.length-1)==e)){nextViewIndex=0}}nextViewIndex++;if(nextViewIndex>(b.length-1)){nextViewIndex=0}setTimeout("spiffAutoScroll();",interval)}}function showhide(a){if((document.getElementById(a)[document.getElementById(a).selectedIndex].value)=="other"){document.getElementById("sZip").style.display="none"}else{if((document.getElementById(a)[document.getElementById(a).selectedIndex].value)=="LRQ"){document.getElementById("sZip").style.display="none"}else{if((document.getElementById(a)[document.getElementById(a).selectedIndex].value)=="HRQ"){document.getElementById("sZip").style.display="none"}else{if((document.getElementById(a)[document.getElementById(a).selectedIndex].value)=="LTCRQ"){document.getElementById("sZip").style.display="none"}else{document.getElementById("sZip").style.display="inline"}}}}}function flashTagCall(a){myVar=a;if(myVar=="Service"){dcsMultiTrack("DCS.dcsuri","/HP_Flash/Service/","WT.ti","Service Flash View")}if(myVar=="Convenience"){dcsMultiTrack("DCS.dcsuri","/HP_Flash/Convenience/","WT.ti","Convenience Flash View")}if(myVar=="Savings"){dcsMultiTrack("DCS.dcsuri","/HP_Flash/Savings/","WT.ti","Savings Flash View")}if(myVar=="Relationships"){dcsMultiTrack("DCS.dcsuri","/HP_Flash/Relationships/","WT.ti","Relationships Flash View")}}window.onload=function(){var p=document.body.getElementsByTagName("a");for(var k=0;k<p.length;k++){if(p[k].rel=="newWindow"){p[k].target="_blank"}}spiffAutoScroll();var d=document.getElementById("emergencyShade");var c=document.getElementById("closeEmergency");if(d!=null){c.onclick=function(){d.style.display="none"};setTimeout("document.getElementById('emergencyShade').style.display='block';",2000)}document.body.onmousedown=function(){if(document.getElementById("rateQuoteZipErrorMsg").style.display!="none"){document.getElementById("rateQuoteZipErrorMsg").style.display="none"}if((document.getElementById("fAgentZipError")!=null)&&(document.getElementById("fAgentZipError").style.display!="none")){document.getElementById("fAgentZipError").style.display="none"}};var j=document.getElementById("hotSpiffTabs");if(j!=null){var r=j.getElementsByTagName("a");var q=r.length;for(var k=0;k<r.length;k++){r[k].onclick=function(){running=false;var i=this.id;this.className="active";var t=i.replace("tab","zone");document.getElementById(t).className="visible";for(var w=0;w<q;w++){if(r[w].id!=i){r[w].className="visible";var u=r[w].id;var v=u.replace("tab","zone");document.getElementById(v).className="hidden"}}return false}}}function m(){if(window.attachEvent){document.getElementById("searchInput").attachEvent("onfocus",o);document.getElementById("searchInput").attachEvent("onblur",n)}else{if(window.addEventListener){document.getElementById("searchInput").addEventListener("focus",o,true);document.getElementById("searchInput").addEventListener("blur",n,true)}}}function o(){document.getElementById("searchBox").style.backgroundPosition="-3px -65px"}function n(){document.getElementById("searchBox").style.backgroundPosition="-3px 0px"}function s(){$("#primaryNav ul li ul").find("*").attr("tabindex","-1")}var l=document.getElementById("searchBtn");if(l!=null){l.onclick=function(){var i=document.getElementById("searchInput");var t=document.getElementById("searchBox");dcsMultiTrack("WT.oss",i.value);t.submit()}}var f=document.getElementById("btnAgentSearch");var h=document.getElementById("fAgentZipError");var g=document.getElementById("sAgentZip");var e=document.getElementById("findAgentForm");if(f!=null){f.onclick=function(){if(g.value.length<5||g.value=="Postal Code"){h.style.display="block";return false}else{h.style.display="none";e.submit()}}}var b=document.getElementById("btnReportSml");var a=document.getElementById("claimZoneErr");if(b!=null){b.onclick=function(){var t=document.getElementById("sState");var i=document.getElementById("ccEmergencyMod");if(t.value==""){a.style.display="block";return false}else{a.style.display="none";i.submit()}}}function m(){if(window.attachEvent){document.getElementById("searchInput").attachEvent("onfocus",o);document.getElementById("searchInput").attachEvent("onblur",n)}else{if(window.addEventListener){document.getElementById("searchInput").addEventListener("focus",o,true);document.getElementById("searchInput").addEventListener("blur",n,true)}}}function o(){document.getElementById("searchBox").style.backgroundPosition="-660px -283px"}function n(){document.getElementById("searchBox").style.backgroundPosition="-660px -219px"}function s(){$("#primaryNav ul li ul").find("*").attr("tabindex","-1")}};function CollectDeviceInfoAndRePostToLoginService(){document.getElementById("LoginScreen").pm_fp.value=add_deviceprint();if(document.getElementById("LoginScreen").remCustID.checked==true){setCookie("W0082393.UserId",document.getElementById("LoginScreen").userID.value);setCookie("W0082393.RememberUserId ","True")}else{setCookie("W0082393.UserId","");setCookie("W0082393.RememberUserId ","False")}}function setCookie(c,f){var a=new Date();a.setFullYear(2099);var e=a.toGMTString();var b=c;var d=f;the_cookie=d+";expires="+e+";path=/;domain=.statefarm.ca";document.cookie=b+"="+the_cookie}function isCookie(){if($.cookie("W0124911_INTERNETPROFILE")){return($.cookie("W0124911_INTERNETPROFILE"))}}function emailValidation(a){if(a==""||a=="Email Address"||(a.indexOf("@")==-1||a.lastIndexOf(".")==-1)){return false}return true}function getAQuote(){$("#continueRateQuote").attr("id","getRateQuote");$("#getRateQuote").css("display","block");$("#applicationName").css("display","block");$("#applicationName option[value='Auto']").attr("selected","selected");$(".appSelectAuto").show();$("#continueQuote").show();$(".appSelectLife").hide();$("#email").hide();$("#startNewQuote").hide()}function continueQuote(){$("#getRateQuote").attr("id","continueRateQuote");$("#applicationName").hide();$("#postalCode").hide();$("#email").show();$("#continueQuote").hide();$("#startNewQuote").show()}function startNewQuoteLink(){if($.cookie("W0124911_INTERNETPROFILE")){$.cookie("W0124911_INTERNETPROFILE",null)}getAQuote()}function continueQuoteLink(){continueQuote()}$(document).ready(function(){if(isCookie()){continueQuote()}else{getAQuote()}$(document).click(function(){$(".errorMsg").hide()});$("#postalCode").click(function(){$("#postalCode").val("")});$("#email").click(function(){$("#email").val("")});$("#applicationName").change(function(){$(".appSelect").hide();$("#continueQuote").hide();$("#startNewQuote").hide();$(".appSelect"+$("#applicationName").val()).show();if($("#applicationName").val()=="Auto"){$("#startNewQuote").hide();$("#continueQuote").show()}});$("#getRateQuoteForm").submit(function(){if($("#continueRateQuote").css("display")=="block"){var a=$("#email").val();if(!emailValidation(a)){showErrorMessage("Please enter a valid email address");return false}else{quoteURL=$("#emailOnline2").val()+"/apps/retrieve/launch.do?email="+a+"&WT.mc_id=HomePage"}}else{switch($("#applicationName").val()){case"Life":if(!stateValidation($("#states").val())){showErrorMessage("Please select a province from dropdown");return false}else{quoteURL=$("#appSelector_servlet").val()+"?applicationName=Life&state="+$("#states").val();break}default:$("#postalCode").val($("#postalCode").val().replace(/\s+/g,"").toUpperCase());if(!simpleValidation($("#postalCode").val())){showErrorMessage("Please enter a Postal Code");return false}else{var b=$("#appSelector_rest").val()+"?applicationName="+$("#applicationName").val()+"&postalCode="+$("#postalCode").val()+"&callback=?";jQuery.getJSON(b,zipResponse);errorTimer=setTimeout("showErrorMessage('Please try again later')",4000);return false}}}submitForm(quoteURL);return false})});function zipResponse(a){clearTimeout(errorTimer);if((a!=null)&&(a.result=="true")){var b=$("#path2online2").val()+""+a.redirect;submitForm(b)}else{showErrorMessage("Please enter a valid Postal Code")}}function submitForm(a){$("#getRateQuoteForm").unbind("submit");$("#getRateQuoteForm").attr("action",a);if(dcsMultiTrack!=null){trackQuoteForm()}$("#getRateQuoteForm").submit()}function simpleValidation(a){if((a=="")||(a=="POSTALCODE")){return false}return true}var errorTimer;function showErrorMessage(a){clearTimeout(errorTimer);$("#rateQuoteZipErrorMsg").html(a);$("#rateQuoteZipErrorMsg").show()}function trackQuoteForm(b){var c=$("#applicationName").val();var d=$("#postalCode").val();var a="?quoteZip="+d+"&amp;appName="+c+"&amp;currentUrl="+document.location.href;dcsMultiTrack("DCS.dcsuri",b,"DCSext.dcsqry",a,"WT.ti","Quote Form Submission")}function submitClaimsForm(){var b=document.getElementById("sState");var a=document.getElementById("claimZoneErr");if(b.value==""){a.style.display="block";return false}return true}function stateValidation(a){if(a=="Select a Province"){return false}return true};
