// JavaScript Document
function valid1()
{
//		alert("From valid1");
//		alert(document.frm.txtname.value);
		if(document.frm.txtname.value=="")
		{
//			alert("valid1");
			document.frm.txterror.value="* can't left blank";
//			frm.txtname.focus();
			return false;
		}
			document.frm.txterror.value="";
			return true;
}


function valid2()
	{
		if(valid1()==true)
		{
			if(document.frm.txtemail.value=="")
			{msg("can't left blank");return false;	}
			document.frm.txterror2.value="";
			return true;
		}
			
	}
	
function valid3()
{
		if(document.frm.txtmsg.value=="")
		{document.frm.txterror3.value="*can't left blank";return false;}
		document.frm.txterror3.value="";
		return true;
}


function chk()
{
//alert("ok");
			if(valid1()==true)
			{
			if(document.frm.txtname.value.length>0)
			{
				var i,a;
				i=document.frm.txtname.value;
				for(j=0;j<i.length;j++)
				{
					a=i.charAt(j);
					if(a=="." || a=="-" || a=="," || a=="[" ||a=="]"||a=="!"||a=="#"||a=="$"||a=="%"||a=="^"||a=="&"||a=="*"||a=="@")
					{
						document.frm.txterror.value="* simbol not allow";document.frm.txtname.focus();return false;
					}	
					if(a=='0'||a=='1'||a=='2'||a=='3'||a=='4'||a=='5'||a=='6'||a=='7'||a=='8'||a=='9')
					{
						document.frm.txterror.value="* number not allow";document.frm.txtname.focus();return false;
					}
				}
				document.frm.txterror.value="";
			return true;
			}

			
			}
return true;
}

function chk2()
{			
//			valid1();
//			if(frm.txtemail.value=="")
//			{msg("can't left blank");return false;	}
			
			//check valid email
			if(valid1()==true)
			{
			var str=document.frm.txtemail.value;
			var at='@';var dot='.';var lat=str.indexOf(at);var lstr=str.length;var ldot=str.indexOf(dot);
			var lastdot=str.lastIndexOf(dot);var stlen=str.split("@");
			if(stlen[0].length<3){msg("Invalid EmailID");document.frm.txtemail.focus();return false;}
			if(str.substring(lat+2,lat+3)==dot){msg("Invalid EmailID");document.frm.txtemail.focus();return false;}
			if(str.indexOf(at)==-1){msg("Invalid E-mail ID");document.frm.txtemail.focus();return false;}
			if(lstr==lastdot+1){msg("Invalid E-mail ID");document.frm.txtemail.focus();return false;}
			if(str.indexOf(at)==-1||str.indexOf(at)===0||str.indexOf(at)==lstr){msg("Invalid E-mail ID");document.frm.txtemail.focus();return false;}
			if(str.indexOf(dot)==-1||str.indexOf(dot)===0||str.indexOf(dot)==lstr){msg("Invalid E-mail ID");document.frm.txtemail.focus();return false;}
			if(str.indexOf(at,(lat+1))!=-1){msg("Invalid E-mail ID");document.frm.txtemail.focus();return false;}
			if(str.substring(lat-1,lat)==dot||str.substring(lat+1,lat+2)==dot){msg("Invalid E-mail ID");document.frm.txtemail.focus();return false;}
			if(str.indexOf(dot,(lat+2))==-1){msg("Invalid E-mail ID");document.frm.txtemail.focus();return false;}
			if(str.indexOf(" ")!=-1){msg("Invalid E-mail ID");document.frm.txtemail.focus();return false;}
			document.frm.txterror2.value="";
			return true;
			}
			
}

function main()
{
//		alert("main");
//		alert(valid1());
			if((valid1()==true) && (valid2()==true) && (chk2()==true))
			{
//					alert("main");
				if(document.frm.txtmsg.value=="")
				{document.frm.txterror3.value="*can't left blank";return false;}
				document.frm.txterror3.value="";
				return true; 
				
			}	
			
			return false;
			
}

function chk3()
{
			if(valid1()==true && valid2()==true && chk2()==true)
			{
				return true;
			}	
			return false;
}


function msg(str)
{
		document.frm.txterror2.value="*"+str;
}