var digits = "0123456789";

var phoneNumberDelimiters = "()- ";

var validWorldPhoneChars = phoneNumberDelimiters + "+";

var minDigitsInIPhoneNumber = 9;
var minDigitsInIPhoneNumber1 = 6;
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    
    for (i = 0; i < s.length; i++)
    {   
       
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    
    for (i = 0; i < s.length; i++)
    {   
        
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}



function changeblank(ctl)
{
var control=ctl;
document.getElementById(control).value="";
}


function checkInternationalPhone(strPhone)
{
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}


function checkInternationalPhone1(strPhone)
{
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber1);
}




function changecountrycode()
{

if((document.frm.name.value=="") && (document.frm.name.value!="Your Name"))
 {
 document.frm.name.value="Your Name";
 }
 
if((document.frm.email.value=="") && (document.frm.email.value!="Your Email"))
 {
 document.frm.email.value="Your Email";
 }


if((document.frm.countrycode1.value=="") && (document.frm.countrycode1.value!="Country Code"))
 {
      document.frm.countrycode1.size="12";
	  document.frm.countrycode1.maxlength="12";
	  document.frm.countrycode1.value="Country Code";
 }
if((document.frm.countrycode1.value!="") && (document.frm.countrycode1.value!="Country Code"))
 {
      document.frm.countrycode1.size="5";
	  document.frm.countrycode1.maxlength="5";
	  
 }
 
 
 
 if((document.frm.countrycode2.value=="") && (document.frm.countrycode2.value!="Country Code"))
 {
      document.frm.countrycode2.size="12";
	  document.frm.countrycode2.maxlength="12";
	  document.frm.countrycode2.value="Country Code";
 }
if((document.frm.countrycode2.value!="") && (document.frm.countrycode2.value!="Country Code"))
 {
      document.frm.countrycode2.size="5";
	  document.frm.countrycode2.maxlength="5";
	  
 }
 
 if((document.frm.stdcode.value=="") && (document.frm.stdcode.value!="STD Code"))
 {
      document.frm.stdcode.size="12";
	  document.frm.stdcode.maxlength="12";
	  document.frm.stdcode.value="STD Code";
 }
if((document.frm.stdcode.value!="") && (document.frm.stdcode.value!="STD Code"))
 {
      document.frm.stdcode.size="5";
	  document.frm.stdcode.maxlength="5";
	  
 }
 
 if((document.frm.telno.value=="") && (document.frm.email.value!="Telephone No."))
 {
 document.frm.telno.value="Telephone No.";
 }
 
 if((document.frm.mobno.value=="") && (document.frm.mobno.value!="Mobile No"))
 {
 document.frm.mobno.value="Mobile No";
 }
 
 if((document.frm.other.value=="") && (document.frm.email.value!="Other Qualification"))
 {
 document.frm.other.value="Other Qualification";
 }
 
 if((document.frm.secother.value=="") && (document.frm.secother.value!="2nd Other Qualification"))
 {
 document.frm.secother.value="2nd Other Qualification";
 }
 
 if((document.frm.description.value=="") && (document.frm.description.value!="Copy and Paste Resume"))
 {
 document.frm.description.value="Copy and Paste Resume";
 }
 
}






function showHide()       
 {    
     document.getElementById('sechighestQual').style.visibility= 'hidden';        
      if(document.frm.highestQual.value =="Others")  
     
	 {                
			document.getElementById('other').style.visibility = 'visible';   
	
	 }           
	  else
     { 
	 document.getElementById('other').style.visibility= 'hidden'; 
	  } 
       if(document.frm.sechighestQual.value =="Sec Others")  
     
	 {                
			document.getElementById('secother').style.visibility = 'visible';   
	
	 }           
	  else
     { 
	 document.getElementById('secother').style.visibility= 'hidden'; 
	  }
	  
	  document.frm.name.value="Your Name";
	  document.frm.email.value="Your Email";
	  document.frm.countrycode1.size="12";
	  document.frm.countrycode1.maxlength="12";
	  document.frm.countrycode1.value="Country Code";
	  document.frm.countrycode2.size="12";
	  document.frm.countrycode2.maxlength="12";
	  document.frm.countrycode2.value="Country Code";
	  document.frm.stdcode.size="12";
	  document.frm.stdcode.maxlength="12";
	  document.frm.stdcode.value="STD Code";
	  document.frm.telno.value="Telephone No.";
	  document.frm.mobno.value="Mobile No";
	  document.frm.description.value="Copy and Paste Resume";
	  document.frm.other.value="Other Qualification";
	  document.frm.secother.value="2nd Other Qualification";
	  
  }



function showsecql()
{
     document.getElementById('sechighestQual').style.visibility= 'visible';  
}

function changeDegree()
{
      if(document.frm.highestQual.value =="Others")  
     
	 {                
			document.getElementById('Other').style.visibility = 'visible';   
	
	 }           
	  else
     { 
	 document.getElementById('Other').style.visibility= 'hidden'; 
	  } 
       if(document.frm.sechighestQual.value =="Sec Others")  
     
	 {                
			document.getElementById('secOther').style.visibility = 'visible';   
	
	 }           
	  else
     { 
	 document.getElementById('secOther').style.visibility= 'hidden'; 
	  }
}


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){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

 		 return true					
	}


function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
        var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "description";
        var countBody = opt_countBody ? opt_countBody : "countBody";
        var maxSize = opt_maxSize ? opt_maxSize : 1024;

        var field = document.getElementById(countedTextBox);
        
        if (field && field.value.length >= maxSize) {
                field.value = field.value.substring(0, maxSize);
        }
        var txtField = document.getElementById(countBody);
                if (txtField)
				 {  
				 
               			    txtField.innerHTML = field.value.length;
                  }
}



               function validateOnSubmit( )
                 {
                    valid = true;
                    obj = document.frm.name;
                    if ((obj.value == "") || (obj.value == "Your Name"))
                    {
                       alert ( "Please Insert Name" );
                       obj.focus();
                       return false;
                    }
                    var emailID=document.frm.email;
	
	                if ((emailID.value==null)||(emailID.value=="" ) || (emailID.value == "Your Email"))
					{
		                      alert("Please Enter your Email ID");
		                      emailID.focus();
		                      return false;
	                }
	                if (echeck(emailID.value)==false)
					{
		                        emailID.value="";
		                        emailID.focus();
		                        return false;
	                }
                    
					
					
					// Declaring required variables
                   
					
					
					
					
					


	               var Phone=document.frm.telno;
				   var mobPhone=document.frm.mobno;
	
	               //if ((Phone.value==null)||(Phone.value==""))
				   // {
		           // alert("Please Enter your Phone Number");
		           //Phone.focus();
		           // return false;
	               //}
				   
				    if ((Phone.value!="Telephone No."))
				   {
				   
				   obj = document.frm.countrycode1;
                    if ((obj.value == "") || (obj.value == "Country Code"))
                    {
                       alert ( "Please Insert CountryCode For Tel No" );
                       obj.focus();
                       return false;
                    }
				   
				   
				   
				    obj5 = document.frm.stdcode;
                    if ((obj5.value == "") ||(obj5.value == "STD Code"))
                    {
                       alert ( "Please Insert STD Code For Telephone No" );
                       obj5.focus();
                       return false;
                    }
	               if (checkInternationalPhone1(Phone.value)==false)
				   {
				   
				    
		            alert("Please Enter a Valid Phone Number");
		            Phone.value="";
		            Phone.focus();
		            return false;
	               }
				   }
				   
				   
				   if(mobPhone.value!="Mobile No") 
                   {
				   
				    obj44 = document.frm.countrycode2;
                    if ((obj44.value == "") || (obj44.value == "Country Code"))
                    {
                       alert ( "Please Insert CountryCode For Mobile No" );
                       obj44.focus();
                       return false;
                    }
				   
				   
					if (checkInternationalPhone(mobPhone.value)==false)
				   {
				    
		            alert("Please Enter a Valid Mobile Number");
		            mobPhone.value="";
		            mobPhone.focus();
		            return false;
	               }
				   }
					
					if ((mobPhone.value=="Mobile No") &&  (Phone.value=="Telephone No."))
				   {
		           alert("Please Enter Atleast One Of Contact No.");
		           mobPhone.focus();
		           return false;
	               }

                   obj = document.frm.highestQual;
				   objsec = document.frm.sechighestQual;
				   objother = document.frm.other;
				   objsecother = document.frm.secother;
                    if (obj.value == "-1")
                    {
                       alert ( "Please Select Qualification" );
                       obj.focus();
                       return false;
                    } 
					
					 
	
					
					if (obj.value == "Others")
                    {
					   obj2 = document.frm.other;
					   if (obj2.value == "")
					   {
                       alert ( "Please Enter Other Qualification" );
                       obj2.focus();
                       return false;
					   }
                    } 
					
					
					 if ((obj.value == objsec.value) || (objother.value == obj.value) || (objother.value == objsec.value) || (objsec.value == objsecother.value) )
                    {
                       alert ( "Please Enter Two Different Qualification " );
                       obj.focus();
                       return false;
                    } 
					
					if((objother.value == objsecother.value) && objother.value !="" && objsecother.value!="")
					{
					   alert ( "Please Enter Two Different Other Qualification " );
                       obj.focus();
                       return false;
					}
					
					
					if (obj.value == "-1")
                    {
                       alert ( "Please Select Qualification" );
                       obj.focus();
                       return false;
                    } 
					
					
					obj = document.frm.designation;
                    if (obj.value == "-1")
                    {
                       alert ( "Please Select Apply Designation" );
                       obj.focus();
                       return false;
                    } 
                     
					 obj = document.frm.experience;
                    if (obj.value == "-1")
                    {
                       alert ( "Please Select Experience You Have" );
                       obj.focus();
                       return false;
                    }                   
                  
                   /*obj2 = document.getElementById('ctl00_ContentPlaceHolder1_txtValdate');
                   if (obj2.value == "")
                     {
                        alert ( "Please Insert The Validity Date" );
                        obj2.focus();
                        return false;
                     }
                     else
                   {
                   var re =/^(([1-9]|0[1-9]|[12][0-9]|3[01])[/]([1-9]|0[1-9]|1[012])[/](?:19|20)\d\d)$/;
            
                         if(!((obj2.value).match(re))) 
                           { 
                             alert('Invalid Date format: Please Enter Date In DD/MM/YYYY Format'); 
                             obj2.focus();
                             return false; 
                           }
                      
                   }*/
                   
                    
               
                 }
           
                
                function CheckIsFloat()
           {
		           var AsciiCode = event.keyCode;
                   if ((AsciiCode ==32))
                      {
                         alert ( "Sorry First Time space is not allowed !" );
                         
                      }
                   else
                   {
                        if((AsciiCode >= 0) && (AsciiCode < 46)||(AsciiCode > 46) && (AsciiCode < 48 )||(AsciiCode > 57) && (AsciiCode <= 127))
                        {
                            alert ( "Sorry this is not allowed !" );
                        }
                   
                   }
                   if ((AsciiCode < 48) || (AsciiCode > 57))
                      {
                         event.cancelBubble = true; 
                         event.returnValue = false; 
                      }   
		           if((AsciiCode == 46))
		              {
			             event.cancelBubble = false;
			             event.returnValue = true;
		              } 
          }       
      
