// JavaScript Document




function validateRegxGH()
{
	var erorxxx = 0;
	
			if(document.input1.name && document.input1.name.value == '' )
		{
			alert('please enter First name');
			document.input1.name.focus();
			erorxxx++;
			return false;
		}
		
		if(document.input1.lname && document.input1.lname.value == '' )
		{
			alert('please enter Last name');
			document.input1.lname.focus();
			erorxxx++;
			return false;
		}
	
	
		if(document.input1.usernamex && document.input1.usernamex.value == '')
		{
			
			alert('Please enter username');
			document.input1.usernamex.focus();
			erorxxx++;
			return false;
		}
	

		if(document.input1.passwordx && document.input1.passwordx.value == '' )
		{
			alert('please enter password');
			document.input1.passwordx.focus();
			erorxxx++;
			return false;
		}
	if(document.input1.email)
	{
		var eml = document.input1.email.value ;
		if(document.input1.email.value == '')
		{
			alert('please enter Email');
			document.input1.email.focus();
			erorxxx++;
			return false;
		}
		else
		{
			if (echeck(eml)==false)
			{
				alert('please enter a valid Email');
				document.input1.email.focus();
				erorxxx++;
				return false;
			}
		}
	}
	
			if(document.input1.address && document.input1.address.value == '' )
		{
			alert('please Enter Your Message');
			document.input1.address.focus();
			erorxxx++;
			return false;
		}
		
		if(document.input1.randomm && document.input1.randomm.value == '' )
		{
			alert('please enter Confirmation text to The Box below');
			document.input1.randomm.focus();
			erorxxx++;
			return false;
		}

	
	if(erorxxx < 1)
	{
	test();
	return true;
	
	}
		
	
	
	
}




function validateRec()
{
	var erorxxx = 0;

	if(document.rec.email)
	{
		var eml = document.rec.email.value ;
		if(document.rec.email.value == '')
		{
			alert('please enter Email');
			document.rec.email.focus();
			erorxxx++;
			return false;
		}
		else
		{
			if (echeck(eml)==false)
			{
				alert('please enter a valid Email');
				document.rec.email.focus();
				erorxxx++;
				return false;
			}
		}
	}
	

		

	
	if(erorxxx < 1)
	{
	return true;
	document.rec.submit();
	
	}
		
	
	
	
}


function validateRegx()
{
	var erorxxx = 0;
	
			if(document.input1.name && document.input1.name.value == '' )
		{
			alert('please enter First name');
			document.input1.name.focus();
			erorxxx++;
			return false;
		}
		
		if(document.input1.lname && document.input1.lname.value == '' )
		{
			alert('please enter Last name');
			document.input1.lname.focus();
			erorxxx++;
			return false;
		}
	
	
		if(document.input1.usernamex && document.input1.usernamex.value == '')
		{
			
			alert('Please enter username');
			document.input1.usernamex.focus();
			erorxxx++;
			return false;
		}
	

		if(document.input1.passwordx && document.input1.passwordx.value == '' )
		{
			alert('please enter password');
			document.input1.passwordx.focus();
			erorxxx++;
			return false;
		}
	if(document.input1.email)
	{
		var eml = document.input1.email.value ;
		if(document.input1.email.value == '')
		{
			alert('please enter Email');
			document.input1.email.focus();
			erorxxx++;
			return false;
		}
		else
		{
			if (echeck(eml)==false)
			{
				alert('please enter a valid Email');
				document.input1.email.focus();
				erorxxx++;
				return false;
			}
		}
	}
	
			if(document.input1.address && document.input1.address.value == '' )
		{
			alert('please Enter Your Message');
			document.input1.address.focus();
			erorxxx++;
			return false;
		}
		
		if(document.input1.randomm && document.input1.randomm.value == '' )
		{
			alert('please enter Confirmation text to The Box below');
			document.input1.randomm.focus();
			erorxxx++;
			return false;
		}

	
	if(erorxxx < 1)
	{
	test();
	return true;
	
	}
		
	
	
	
}



function validateRegx2()
{
	var erorxxx = 0;
		if(document.input1.usernamex && document.input1.usernamex.value == '')
		{
			
			alert('Please enter username');
			document.input1.usernamex.focus();
			erorxxx++;
			return false;
		}
	

		if(document.input1.passwordx && document.input1.passwordx.value == '' )
		{
			alert('please enter password');
			document.input1.passwordx.focus();
			erorxxx++;
			return false;
		}
	if(document.input1.email)
	{
		var eml = document.input1.email.value ;
		if(document.input1.email.value == '')
		{
			alert('please enter Email');
			document.input1.email.focus();
			erorxxx++;
			return false;
		}
		else
		{
			if (echeck(eml)==false)
			{
				alert('please enter a valid Email');
				document.input1.email.focus();
				erorxxx++;
				return false;
			}
		}
	}
	
		if(document.input1.name && document.input1.name.value == '' )
		{
			alert('please enter First name');
			document.input1.name.focus();
			erorxxx++;
			return false;
		}
		
		if(document.input1.lname && document.input1.lname.value == '' )
		{
			alert('please enter Last name');
			document.input1.lname.focus();
			erorxxx++;
			return false;
		}
	
	if(erorxxx < 1)
	{
	//test();	
	document.input1.submit();
	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){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}


