// JavaScript Document
function trim(str) 
{
        return str.replace(/^\s+|\s+$/g,"");
}
function checkForm(form) 
{ 
	var sname=trim(document.forms["form_mail"]["name"].value);
	var sphone=trim(document.forms["form_mail"]["phone"].value);
	var smsg=trim(document.forms["form_mail"]["msg"].value);
	
	if(sname=="")
	{
		alert("Name can not be blank");
		document.forms["form_mail"]["name"].focus();
		return false;
	}
	else
	{
		if(sphone=="")
		{
		alert("Phone can not be blank");
		document.forms["form_mail"]["phone"].focus();
		return false;
		}
		else
		{
				var x=trim(document.forms["form_mail"]["email"].value);
				if(x!="")
				{
					var atpos=x.indexOf("@");
					var dotpos=x.lastIndexOf(".");
					if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
				  	{
		  					alert("Not a valid e-mail address");
						  	return false;
				  	}
				}
	  			else
				{
		 	 		if(smsg=="")
					{
						alert("Please Enter Some Message !");
						document.forms["form_mail"]["msg"].focus();
						return false;
					}
					else
					{
						return true;
					}
	  			}

		}
	}

} 
