function validFields(form)
	{
		var ctr=eval("document."+form);


			if(ctr.email.value=="")
			{
				alert("Email is required.");
				ctr.email.focus();
				return false;
			}
			if(echeck(ctr.email.value)==false)
			{
				ctr.email.value='';
				ctr.email.focus();
				return false;
			}
			if(ctr.code.value=="")
			{
				alert("Verify Code is required.");
				ctr.code.focus();
				return false;
			}
			return true;
}

/**
 *
 * @access public
 * @return void
 **/
function valid_email_form(form){
	var ctr=eval("document."+form);
	if(ctr.email.value=="" || ctr.email.value==null)
	{
		alert("Email is required");
		ctr.email.focus();
		return false;
	}
	if(echeck(ctr.email.value)==false)
	{
				ctr.email.value='';
				ctr.email.focus();
				return false;
	}
	if(ctr.vrcode.value=="" || ctr.vrcode.value==null)
	{
		alert("Please enter verification code");
		ctr.vrcode.focus();
		return false;
	}
	return true;
}

/**
 *
 * @access public
 * @return void
 **/
function valid_edit(){
	var doc=document.editad;

	if(doc.name.value=="" || doc.name.value==null)
	{
		alert("Name is required");
		doc.name.focus();
		return false;
	}
	if(doc.mail.value=="" || doc.mail.value==null)
	{
		alert("Email is required");
		doc.mail.focus();
		return false;
	}
	if(echeck(doc.mail.value)==false)
	{
		doc.mail.value='';
		doc.mail.focus();
		return false;
	}
	if(doc.phone.value=="" || doc.phone.value==null)
	{
		alert("Phone is required");
		doc.phone.focus();
		return false;
	}
	if(doc.subject.value==""  || doc.subject.value==null)
	{
		alert("Subject is required");
		doc.subject.focus();
		return false;
	}
	if(doc.message.value=="" || doc.message.value==null)
	{
		alert("Message is required");
		doc.message.focus();
		return false;
	}
	if(doc.vrcode.value=="" || doc.vrcode.value==null)
	{
		alert("Please enter verification code");
		doc.vrcode.focus();
		return false;
	}
	return true;
}

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
	}

