//validation for login
function checkform(){
	var Invalid=" ";
	var frm = document.form1;
	
	
	if(frm.fname.value==""){
		alert("Please enter your first name");
		frm.fname.focus();
		return false;
	}
	else {
		
		if(!hasWhiteSpace(frm.fname.value))
 {
	 document.frm.fname.value="";
			document.frm.fname.focus();
  return false;
   }
	}
	if(frm.call_name.value==""){
		alert("Please enter your Name");
		frm.call_name.focus();
		return false;
	}
	else {
		
		if(!hasWhiteSpace(frm.call_name.value))
 {
	 document.frm.call_name.value="";
			document.frm.call_name.focus();
  return false;
   }
	}
	/*if(frm.lname.value==""){
		alert("Please enter your last name");
		frm.lname.focus();
		return false;
	}
	else {
		if(!hasWhiteSpace(frm.lname.value))
 {
	 document.frm.lname.value="";
			document.frm.lname.focus();
  return false;
   }
	}*/

if(frm.email.value==""){
		alert("Please enter your email id");
		frm.email.focus();
		return false;
	}
else {
		if(!hasWhiteSpace(frm.email.value))
 {
	 document.frm.email.value="";
			document.frm.email.focus();
	 
  return false;
   }
	
if (frm.email.value.indexOf(Invalid) > -1)
 {
alert("Sorry, spaces are not allowed.");
frm.email.value="";
frm.email.focus();
return false;
}

	var str = frm.email.value;
	if(!emailCheck(str)){
		frm.email.focus();
		return false;
	}
}

if(frm.call_email.value==""){
		alert("Please enter your email id");
		frm.call_email.focus();
		return false;
	}
else {
		if(!hasWhiteSpace(frm.call_email.value))
 {
	 document.frm.call_email.value="";
			document.frm.call_email.focus();
	 
  return false;
   }
	
if (frm.call_email.value.indexOf(Invalid) > -1)
 {
alert("Sorry, spaces are not allowed.");
frm.call_email.value="";
frm.call_email.focus();
return false;
}

	var str = frm.call_email.value;
	if(!emailCheck(str)){
		frm.call_email.focus();
		return false;
	}
}
 

    if(frm.call_phone.value==""){
		alert("Please enter your phone no");
		frm.call_phone.focus();
		return false;
	}
	else {
		if(isNaN(frm.call_phone.value)|| frm.call_phone.value.indexOf(" ")!=-1)
		  {
              alert("Enter only numeric value");
			  frm.call_phone.focus();
			  return false; 
		  }
		 var len1= parseInt(frm.call_phone.value.length); 
        if (len1!=10)
		   {    
                alert("Enter 10 digits number");
			    frm.call_phone.focus();
				return false;
           }
		   
		if(!hasWhiteSpace(frm.call_phone.value))
            {
	     document.frm.call_phone.value="";
		 document.frm.call_phone.focus();
         return false;
            }
		   

   }
  /* if(frm.phone2.value==""){
		alert("Please enter your phone no");
		frm.phone2.focus();
		return false;
	}
	else {
		if(isNaN(frm.phone2.value)|| frm.phone2.value.indexOf(" ")!=-1)
		  {
              alert("Enter numeric value");
							frm.phone2.focus();
			  return false; 
		  }
		 var len1= parseInt(frm.phone2.value.length); 
        if (len1!=3)
		   {    
		       
                alert("Enter 3 digits number");
			frm.phone2.focus();
				return false;
           }

   }
	 if(frm.phone3.value==""){
		alert("Please enter your phone no");
		frm.phone3.focus();
		return false;
	}
	else {
		if(isNaN(frm.phone3.value)|| frm.phone3.value.indexOf(" ")!=-1)
		  {
              alert("Enter numeric value");
							frm.phone3.focus();
			  return false; 
		  }
		 var len1= parseInt(frm.phone3.value.length); 
        if (len1!=4)
		   {    
		       
                alert("Enter 4 digits number");
			frm.phone3.focus();
				return false;
           }

   }*/
	/*if(frm.comments.value==""){
		alert("Please type your comments");
		frm.comments.focus();
		return false;
	}
	else {
		if(!hasWhiteSpace(frm.comments.value))
 {
	  document.frm.comments.value="";
			document.frm.comments.focus();
  return false;
   }
	}
*/

if(frm.security_code_sub.value==""){
		alert("Please enter security code as shown in graphic");
		frm.security_code_sub.focus();
		return false;
	}

	
}
function hasWhiteSpace(s)
      {
     reWhiteSpace = new RegExp(/^\s+$/);
           // Check for white space
           if (reWhiteSpace.test(s)) {
                alert("Sorry, Spaces are not allowed");
                return false;
           }
      return true;
      } 

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 = "";    // Search through string's characters one by one.
		  // If character is not a whitespace, append to returnString. 
		  for (i = 0; i < s.length; i++)
		  {           // Check that current character isn't whitespace. 
		  var c = s.charAt(i);
		  if (c != " ") returnString += c; 
	      } 
		  return returnString;
	   }
 function stripCharsInBag(s, bag){ 
	     var i;
		 var returnString = "";    // Search through string's characters one by one.    // If character is not in bag, append to returnString.  
		for (i = 0; i < s.length; i++) 
		 {           // Check that current character isn't whitespace. 
		 var c = s.charAt(i);
		 if (bag.indexOf(c) == -1) returnString += c; 
		 }    return returnString;
	}
	
	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);
	}
//validation for email
function emailCheck(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("Enter the valid e-mail id !")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){           
            alert("Enter the valid e-mail id")
		    return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Enter the valid e-mail id");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			alert("Enter the valid e-mail id");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert("Enter the valid e-mail id");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Enter the valid e-mail id");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Enter the valid e-mail id !");
		    return false;
		 }
 		 return true					
}

function jump()
{
    if(document.form1.phone1.value.length==3)
    {
        document.form1.phone2.focus();
    }
} 
function jump1()
{
    if(document.form1.phone2.value.length==3)
    {
        document.form1.phone3.focus();
    }
} 
