﻿// JScript File

var Prefix;
function Chk_Field()
{
        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 validated = Page_ClientValidate("VGAuto");
       if(validated)
              {
             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;
             }
               var hdnCity=document.getElementById (Prefix+"hdnCity");
               var hdnState=document.getElementById (Prefix+"hdnState");
             
               var ddlCity=document.getElementById (Prefix+"ddlCity");
               var ddlState=document.getElementById (Prefix+"ddlState");
                hdnCity.value=ddlCity.value;
               hdnState.value=ddlState.value;
        } 
      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;
      }
   
   