﻿// JScript File

var Prefix;

 function isNumberKey(evt)
  {
     var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

     return true;
  }
   function On_chk(e)
   {
      var txtCarrierName=document.getElementById (Prefix+"txtCarrierName");
    var txtClaimDesc=document.getElementById (Prefix+"txtClaimDesc");
      if(e.value=="rbtnIsInsuredYes")
      {
       
       txtCarrierName .disabled=false;
      }
     if(e.value=="rbtnIsInsuredNo")
      {
     txtCarrierName .value="";
      txtCarrierName .disabled=true;
      }
      if(e.value=="rbtnPriorClaimsYes")
      {
      txtClaimDesc.disabled=false;
      }
      if(e.value=="rbtnPriorClaimsNo")
      {
          txtClaimDesc.value="";
          txtClaimDesc.disabled=true;
          
      }
      
   }
   
   function Chk_Field()
   {

   var txtYourName=document.getElementById (Prefix+"txtYourName");
     var txtEmail=document.getElementById (Prefix+"txtEMail");
     var txtPhone1=document.getElementById (Prefix+"txtPhone1");
     var txtPhone2=document.getElementById (Prefix+"txtPhone2");
     var txtPhone3=document.getElementById (Prefix+"txtPhone3");
     var txtfax1=document.getElementById (Prefix+"txtfax1");
     var txtfax2=document.getElementById (Prefix+"txtfax2");
     var txtfax3=document.getElementById (Prefix+"txtfax3");
     var isAgree=document.getElementById (Prefix+"isAgree");
   var ddlstate=document.getElementById (Prefix+"ddlstate");
   var ddlInsuranceType=document.getElementById (Prefix+"ddlInsuranceType");
     
        
      if(txtYourName.value =="" ||txtYourName.value==null)
        {
           alert("Your Name field Can't be empty");
           txtYourName.focus ();
           return false;
        }
     
      if(ddlstate.selectedIndex==0)
    {
       alert("Must Select State");
       ddlstate.focus ();
       return false;
    }
     
      if(txtEmail.value =="" ||txtEmail.value==null)
    {
       alert("Email field Can't be empty");
       txtEmail.focus ();
       return false;
    }
    else
    {
     var bool= echeck(txtEmail.value);
     if(bool==0)
     {
         alert("Invalid E-mail ID");
         txtEmail.value ="";     
         txtEmail.focus ();
         return false;
      }
    }
 
    var strState='<%#strstate%>';
    
    if(strState!="")
    {
       if(ddlInsuranceType.selectedIndex==0)
       {
           alert("must Select Insurance Type");
           ddlInsuranceType.focus ();
            return false;
       }
    }
     if(txtPhone1.value !="" &&(txtPhone2.value ==""||txtPhone3.value ==""))
     {
       alert("Phone no is not valid!all three fields are complusory");
       txtPhone1.focus ();
       return false;
        
     }
      if(txtPhone2.value !="" &&(txtPhone1.value ==""||txtPhone3.value ==""))
     {
         alert("Phone no is not valid!all three fields are complusory");
     txtPhone1.focus ();
       return false;
     }
      if(txtPhone3.value !="" &&(txtPhone1.value ==""||txtPhone2.value ==""))
     {
        alert("Phone no is not valid!all three fields are complusory");
        txtPhone1.focus ();
       return false;
     }
  if(txtfax1.value !="" &&(txtfax2.value ==""||txtfax3.value ==""))
     {
       alert("Fax no is not valid!all three fields are complusory");
       txtfax1.focus ();
       return false;
     }
  if(txtfax2.value !="" &&(txtfax1.value ==""||txtfax3.value ==""))
     {
       alert("Fax no is not valid!all three fields are complusory");
         txtfax1.focus ();
       return false;
     }
     if(txtfax3.value !="" &&(txtfax1.value ==""||txtfax2.value ==""))
     {
        alert("Fax no is not valid!all three fields are complusory");
         txtfax1.focus ();
       return false;
     }
     if(isAgree.checked !=true)
     {
       alert("ISAgree Checkbox is unchecked"); 
        return false;
     }
   
  return true;
  }
   
     
  function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  
		   return 0;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   
		    
		   return 0;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   
		   return 0;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		   return 0;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   
		   return 0;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		   return 0;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		   return 0;
		 }

 		 return 1;					
	} 
     
 
   function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
   
    