// JavaScript Document
function SubmitForm()
{
	var flag=true;
	if(document.form_login.txtUsername.value=="" & flag==true)
	{
		alert("Name cannot be blank");
		document.form_login.txtUsername.focus();
		flag=false;
	}	
	
	if(document.form_login.txtPass.value=="" & flag==true)
	{
		alert("Password cannot be blank");
		document.form_login.txtPass.focus();
		flag=false;
	}
	if( flag==true)
	{
		document.form_login.submit();
	}
	
	
	
}
function SubmitForm2()
{
	var flag=true;
	if(trim(document.form2.txtName.value)=="" & flag==true)
	{
		alert("Name cannot be blank");
		document.form2.txtName.value="";
		document.form2.txtName.focus();
		flag=false;
	}	
		if(trim(document.form2.txtCompany.value)=="" & flag==true)
	{
		alert("Company Name cannot be blank");
		document.form2.txtCompany.value="";
		document.form2.txtCompany.focus();
		flag=false;
	}	
	if(document.form2.txtCountry.value=="" & flag==true)
	{
		alert("Country Name cannot be blank");
		document.form2.txtCountry.focus();
		flag=false;
	}	
		if(document.form2.txtPhone.value=="" & flag==true)
	{
		alert("Phone Number cannot be blank");
		document.form2.txtPhone.focus();
		flag=false;
	}	
	if(flag==true & document.form2.txtPhone!="" )
	{
		if(checkNumeric(document.form2.txtPhone.value,'-,.')==false)
		{
			alert("Invalid Telephone");
			document.form2.txtPhone.focus();
			document.form2.txtPhone.value="";
			flag=false;
		}
	}
		if(trim(document.form2.txtEmail.value)=="" & flag==true)
		{
		alert("Email cannot be blank");
		document.form2.txtEmail.value="";
		document.form2.txtEmail.focus();
		flag=false;
	}	
	if(flag==true & trim(document.form2.txtEmail.value)!="")
	{
		if(echeck(trim(document.form2.txtEmail.value))==false  )
		{
			document.form2.txtEmail.focus();
			document.form2.txtEmail.value="";
			flag=false;
		}
	}
	if( flag==true)
	{
		document.form2.submit();
	}
	
	
	
}
function SubmitForm3()
{
	var flag=true;
	if(trim(document.form3.txtName.value)=="" & flag==true)
	{
		alert("Name cannot be blank");
		document.form3.txtName.focus();
		document.form3.txtName.value="";
		
		flag=false;
	}	
		if(trim(document.form3.txtCompany.value)=="" & flag==true)
	{
		alert("Company Name cannot be blank");
		document.form3.txtCompany.value="";
		document.form3.txtCompany.focus();
		flag=false;
	}	
	if(document.form3.txtCountry.value=="" & flag==true)
	{
		alert("Country Name cannot be blank");
		document.form3.txtCountry.focus();
		flag=false;
	}	
		if(document.form3.txtPhone.value=="" & flag==true)
	{
		alert("Phone Number cannot be blank");
		document.form3.txtPhone.focus();
		flag=false;
	}
	if(flag==true & document.form3.txtPhone!="" )
	{
		if(checkNumeric(document.form3.txtPhone.value,'-,.')==false)
		{
			alert("Invalid Telephone");
			document.form3.txtPhone.focus();
			document.form3.txtPhone.value="";
			flag=false;
		}
	}
	if(trim(document.form3.txtEmail.value)=="" & flag==true)
		{
		alert("Email cannot be blank");
		document.form3.txtEmail.value="";
		document.form3.txtEmail.focus();
		flag=false;
	}
	if(flag==true & document.form3.txtEmail.value!="")
	{
		if(echeck(trim(document.form3.txtEmail.value))==false  )
		{
			document.form3.txtEmail.focus();
			document.form3.txtEmail.value="";
			flag=false;
		}
	}
	if( flag==true)
	{
		document.form3.submit();
	}
	
	
	
}

function checkNumeric(strString,extraChar)
{
   var strValidChars = "0123456789";
   strValidChars=strValidChars+extraChar;
   var strChar;
   var blnResult = true;
  // if ((strString.length == '0') || (strString.length > '15') || (strString.length < '7'))  return false;

   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) blnResult = false;
      }
   return blnResult;
}


//NEW EMAIL CHECK

var testresults
function echeck(str){
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
alert("Please input a valid email address!")
testresults=false
}
return (testresults)
}



function checkbae(){
if (document.layers||document.getElementById||document.all)
return checkemail()
else
return true
}

function onKeyPressCheck(e)
{
	var key = window.event ? e.keyCode : e.which;
	if (key==13)
	{
	    this.SubmitForm();
	}
}


