
// new redirect
function goToUrl(myForm){
    var zip=myForm.zip.value;
  
    if(zip.length!=5 | isNumeric(zip)==false){               
    window.alert("Please Enter 5 Digit ZipCode");
  }else{                
    var insurance=valButton(myForm.insurance);
    if(insurance==null){
      alert("Please select yes or no");
    }
    else{
    pageTracker. _trackPageview('/zip');
     // if(zip>=90001 & zip<=96162){
     // window.location = 'https://2autoinsurance.com/form.html?zip=' + zip + "&insured=" + insurance;
     // }else{
        window.location = 'http://2autoinsurance.com/results/?zip='+zip; 
// }
    }
  }
}

// validate
function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}

function isNumeric(strString)
    {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

 //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
// autotab
function autotab(a,b){if(a.getAttribute&&a.value.length==a.getAttribute("maxlength"))b.focus()}
