// Contact Us Validation: English version

// Funnction to check email
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 checkall to check form fields
function checkall(form)
{
	// Check Name field
	  if ( (document.form.name.value == "") || (document.form.name.value == " ") )
	  {
			alert ("Please Enter the Name");
			document.form.name.focus();
			return false;
	  }
	
	// Check Job Title field
	  if ( (document.form.jobTitle.value == "") || (document.form.jobTitle.value == " ") )
	  {
			alert ("Please Enter the Job Title");
			document.form.jobTitle.focus();
			return false;
	  }

	// Check Company field
	  if ( (document.form.company.value == "") || (document.form.company.value == " ") )
	  {
			alert ("Please Enter the Company");
			document.form.company.focus();
			return false;
	  }

	// Check Country field
	  if ( (document.form.country.value == 0) )
	  {
			alert ("Please Select the Country");
			document.form.country.focus();
			return false;
	  }
	
	// Check Email field
	  if ( (document.form.email.value == "") || (!echeck(document.form.email.value)) )
	  {
			alert ("Please Enter the Email");
			document.form.email.focus();
			return(false);
	  }

	// Check Telephone field
	  if ( (document.form.telephone.value == "") || (document.form.telephone.value == " ") )
	  {
			alert ("Please Enter the Telephone");
			document.form.telephone.focus();
			return false;
	  }

	// Check Subject field
	  if ( (document.form.subject.value == "") || (document.form.subject.value == " ") )
	  {
			alert ("Please Enter the Subject");
			document.form.subject.focus();
			return false;
	  }

	// Check Comments field
	  if ( (document.form.comments.value == "") || (document.form.comments.value == " ") )
	  {
			alert ("Please Enter the Comments");
			document.form.comments.focus();
			return false;
	  }


}