﻿// 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 ChkSetp2()
      {
            
      }
    function   Onchange_Chk(obj)
    {
      var chk_SubconYes=document.getElementById (Prefix+"chk_SubconYes");
      var chk_SubconNo=document.getElementById (Prefix+"chk_SubconNo");
       var txtsubcon=document.getElementById (Prefix+"txtsubcon");
       if(obj.id==Prefix+"chk_SubconYes")
       {
         if(chk_SubconYes.checked ==true)
         {
       
         txtsubcon.disabled =false;
         chk_SubconYes.checked =true;
       chk_SubconNo .checked =false;
         }
         else
         {
           txtsubcon.disabled =true;
          chk_SubconYes.checked =false;
         chk_SubconNo .checked =true;
         }
       }
       else
       {
        if(obj.id==Prefix+"chk_SubconNo")
       {
         if(chk_SubconNo.checked ==true)
         {
          
          txtsubcon.disabled =true;
          chk_SubconNo.checked =true;
          chk_SubconYes.checked =false;
          }
          else
          {
          txtsubcon.disabled =false;
          chk_SubconNo.checked =false;
          chk_SubconYes.checked =true;
          }
       }
       }
    }
   function Click_Limit()
   {
    var ddllimit=document.getElementById (Prefix+"ddllimit");
      var ddlclassi_I=document.getElementById (Prefix+"ddlclassi_I");
    
   }
   function Chk_Premium_I()
   {
       var validated = Page_ClientValidate("VGSetp1");
               if (validated) {

                   var txtPhone1 = document.getElementById(Prefix + "txtPhone1");
                   var txtPhone2 = document.getElementById(Prefix + "txtPhone2");
                   var txtPhone3 = document.getElementById(Prefix + "txtPhone3");

                   var txtnPhone1 = document.getElementById(Prefix + "txtnPhone1");
                   var txtnPhone2 = document.getElementById(Prefix + "txtnPhone2");
                   var txtnPhone3 = document.getElementById(Prefix + "txtnPhone3");

                   var txtfax1 = document.getElementById(Prefix + "txtfax1");
                   var txtfax2 = document.getElementById(Prefix + "txtfax2");
                   var txtfax3 = document.getElementById(Prefix + "txtfax3");



                   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;
                   }

                   // phone night
                   if (txtnPhone1.value != "" && (txtnPhone2.value == "" || txtnPhone3.value == "")) {
                       alert("Phone no is not valid!all three fields are complusory");
                       txtnPhone1.focus();
                       return false;

                   }

                   if (txtnPhone2.value != "" && (txtnPhone1.value == "" || txtnPhone3.value == "")) {
                       alert("Phone no is not valid!all three fields are complusory");
                       txtnPhone1.focus();
                       return false;
                   }
                   if (txtnPhone3.value != "" && (txtnPhone1.value == "" || txtnPhone2.value == "")) {
                       alert("Phone no is not valid!all three fields are complusory");
                       txtnPhone1.focus();
                       return false;
                   }
                   //
                   //Fax

                   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;
                   }
                   var ddlState = document.getElementById(Prefix + "ddlState");
                   var hdnCity = document.getElementById(Prefix + "hdnCity");
                   var hdnState = document.getElementById(Prefix + "hdnState");

                   var ddlCity = document.getElementById(Prefix + "ddlCity");
                   hdnCity.value = ddlCity.value;
                   hdnState.value = ddlState.value;

               }
     
    
   
   }
    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 Chk_Premium_II()
   {
     var ddlclassi_II=document.getElementById (Prefix+"ddlclassi_II");
     var txtcode_II=document.getElementById (Prefix+"txtcode_II");
   
    var txtEmpPayroll_II=document.getElementById (Prefix+"txtEmpPayroll_II");
 
    
       var str;
     //str= contractotRating_I.GetTradecode(ddlclassi_II .value);
     //txtcode_II.value=str.value;
    
     if(ddlclassi_II.selectedIndex!=0)
     {
      
         txtEmpPayroll_II.disabled =false;
     }
     else
     {
     
       txtEmpPayroll_II.disabled =true;
     }
   }
   
   function Chk_NextButton()
   {
         var ddlclassi_I=document.getElementById (Prefix+"ddlclassi_I");
        var txtsubcon=document.getElementById (Prefix+"txtsubcon");
        var ddlPayrollOwner_I =document.getElementById (Prefix+"ddlPayrollOwner_I");
      
      
       var  ddl_ownerNo_I=document.getElementById (Prefix+"ddl_ownerNo_I");
       var Owner_I = ddlPayrollOwner_I.options[ddlPayrollOwner_I.selectedIndex].text;
     
  
      if(ddlclassi_I .selectedIndex ==0)
        {
           alert(" Must Select Trade Classification");
           ddlclassi_I.focus ();
           return false;
        }
        if(ddlPayrollOwner_I.selectedIndex ==0)
            {
                 alert("Must Select Payroll Owner for First Classification");
                 ddlPayrollOwner_I.focus ();
                 return false;
            }
            
        if(Owner_I.indexOf('Corporation') > -1 || Owner_I.indexOf('Partnership,LLC') > -1 )
         {
             if(ddl_ownerNo_I .value =="-1")
                {
                     alert("Must Select No of Active Owner");
                     ddl_ownerNo_I.focus ();
                     return false;
                 }
        }
        
        var ddlclassi_II=document.getElementById (Prefix+"ddlclassi_II");
        
        
    
      
     var chk_SubconYes=document.getElementById (Prefix+"chk_SubconYes");
     if(chk_SubconYes.checked==true)
        {
            if(txtsubcon.value ==null ||txtsubcon .value =="")
            {
               alert("Must Select Sub contractor Amount");
               txtsubcon.focus ();
               return false;
            }
        }
 
   }
    
   
    
    function SetActiveOwner(val)
    {
       var   ddlPayrollOwner_I =document.getElementById (Prefix+"ddlPayrollOwner_I");
    
      
       var  ddl_ownerNo_I=document.getElementById (Prefix+"ddl_ownerNo_I");
       var Owner_I = ddlPayrollOwner_I.options[ddlPayrollOwner_I.selectedIndex].text;
      
   
     if(val=='1')
     {
       if(Owner_I.indexOf('Corporation') >-1 || Owner_I.indexOf('Partnership,LLC') >-1 )
         {
               ddl_ownerNo_I.disabled=false ;
         }
         else
         {
             ddl_ownerNo_I.disabled = true; 
               ddl_ownerNo_I.selectedIndex=0;
         }
     }
     
    }
    // ConRating Step 3
    
       function Btn_Check()
   {
    var ddlIsContractTools=document.getElementById(Prefix+"ddlIsContractTools");
    var chkIsAgree=document.getElementById (Prefix+"chkIsAgree");
    var ddldead=document.getElementById (Prefix+"ddldead");
    var txthtools =document.getElementById (Prefix+"txthtools");
 
   if(ddlIsContractTools.selectedIndex==0)
    {
      alert("Must Select Hand Tool Coverage");
      ddlIsContractTools.focus();
      return false;
    }
   
   if(ddlIsContractTools.value=="Yes")
    {
       
     if(ddldead.selectedIndex==0)
     {
      alert("Must Select Deductible Amount");
      ddldead.focus();
     return false;
     }
    }
    if(chkIsAgree.checked !=true)
     {
       alert("IAgree Checkbox is unchecked"); 
        chkIsAgree.focus ();
        return false;
     }
   
     
     
   }
   
   
function roundToPennies(n)
{
 pennies = n * 100;

 pennies = Math.round(pennies);

 strPennies = "" + pennies;
 len = strPennies.length;

 return strPennies.substring(0, len - 2) + "." + strPennies.substring(len - 2, len);
}


   function chk_ddlIsContractTools()
   {
      var ddlIsContractTools=document.getElementById (Prefix+"ddlIsContractTools");
     var txthtools=document.getElementById (Prefix+"txthtools");
     var ddldead=document.getElementById (Prefix+"ddldead");
  
     if(ddlIsContractTools.value=="Yes")
     {
    
      txthtools.disabled =false;
      ddldead.disabled=false;
      }
    if(ddlIsContractTools.value=="No")
      {
      txthtools.value="";
      txthtools.disabled =true;
      ddldead.selectedIndex=0;
      ddldead.disabled=true;
     }
     
   }
   function Chk_Htools()
   {
   var ddlIsContractTools=document.getElementById (Prefix+"ddlIsContractTools");
   var txthtools=document.getElementById (Prefix+"txthtools");
    var ddldead=document.getElementById (Prefix+"ddldead");  
      if(ddlIsContractTools.selectedIndex!=0)
      {
         if(txthtools .value =="" ||txthtools.value ==null)
        {
          alert("Hand Tools Coverage Field can't be empty");
         txthtools.focus ();
         ddldead.selectedIndex=0;
         return false;
         }
        
      }
   }
   
    
    
    
    

