var emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
var phoneRe = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
var alphaExp = /^[a-zA-Z ]+$/;

function fnValidateForm()
{

 if(fnCheckvalidate("strname")||
	 document.getElementById("strname").value=="Name" ||
	 !alphaExp.test(document.getElementById("strname").value))
 	{
		alert("please enter valid name"); 
		document.getElementById("strname").focus();
		return;
     }

 else if(fnCheckvalidate("strno") || !phoneRe.test(document.getElementById("strno").value))
 	{
	 alert("please enter valid phone number");
	 document.getElementById("strno").focus();
	 return;
	 } 
 else if(fnCheckvalidate("stremail") || !emailpat.test(document.getElementById("stremail").value))
	{
	 alert("please enter valid E-mail"); 
	 document.getElementById("stremail").focus();
	 return;
	}
 else if(fnCheckvalidate("straddress"))
	{
	 alert("please enter address");
	 document.getElementById("straddress").focus();
	 return;
	 }
 else if(fnCheckvalidate("strnotes"))
	{
	 alert("please enter notes");
	 document.getElementById("strproject").focus();
	 return;
	 }
	else document.forms[0].submit();
} 

// Mailing Form Validation
function Validate_MailForm()
{

 if(fnCheckvalidate("strname")||
	 document.getElementById("strname").value==" Name" ||
	 !alphaExp.test(document.getElementById("strname").value))
 	{
		alert("please enter valid name"); 
		document.getElementById("strname").focus();
		return;
     }

 else if(fnCheckvalidate("stremail") || !emailpat.test(document.getElementById("stremail").value))
	{
	 alert("please enter valid E-mail"); 
	 document.getElementById("stremail").focus();
	 return;
	}
	else document.forms[0].submit();
} 

function fnCheckvalidate(srcid)
{
 if(document.getElementById(srcid).value.replace(/[\s]+$/g,"")==null ||
	 document.getElementById(srcid).value.replace(/[\s]+$/g,"").length==0) 
 return true;
 else return false;
} 

