function validateEmail(fld)
{
	var my=fld.value;
	var attherate=my.indexOf("@");
	var lastattherate = my.lastIndexOf("@")
	var dotpos=my.lastIndexOf(".");
	var posspace = my.indexOf(" ");
	var totallen = my.length;
	
	if (attherate<=0 || dotpos<=0 || attherate > dotpos || (dotpos-attherate)<=1 || (dotpos == totallen-1) || posspace > -1 || attherate!=lastattherate)
		return false;
	else
		return true;
}

function validate()
{

	if(Trim(document.form1.Fullname.value) == "")
	{
		alert("Please enter your Name.");
		document.form1.Fullname.focus();
		return false;
	}
	if(Trim(document.form1.Email.value) == "")
	{
		alert("You must enter Email.");
		document.form1.Email.select();
		document.form1.Email.focus();
		return false;
	}

	if(!validateEmail(document.form1.Email))
	{
		alert("Please enter valid email address");
		document.form1.Email.select();
		document.form1.Email.focus();
		return false;		
	}
	if(Trim(document.form1.Phone.value) == "")
	{
		alert("You must enter Phone Number.");
		document.form1.Phone.select();
		document.form1.Phone.focus();
		return false;
	}
	if(Trim(document.form1.content.value) == "")
	{
		alert("You must enter Message.");
		document.form1.content.select();
		document.form1.content.focus();
		return false;
	}
	
	return true;
}
function Trim(myval)
{
	var chklen=myval.length; 
	var pos=0;
	mychar = myval.charAt(0);

	while(pos>=0 || lstpos >=0)
	{
		pos=myval.indexOf(" ");
		if (pos==0)
		{
			myval=myval.substring(1,chklen);
			chklen = myval.length;
			mychar = myval.charAt(0);
		}
		lstpos=myval.lastIndexOf(" ");

		if (lstpos==chklen-1)
		{	
			myval=myval.substring(0,chklen-1);
			chklen=myval.length;
			mychar = myval.charAt(chklen-1);
		}
		
		if(mychar!=" ")
			break;

	}
	return myval;			
}