

/*function validateEmail(email)
{
	
	// This function is used to validate a given e-mail 
	// address for the proper syntax
	
	if (email == ""){
		return false;
	}
	badStuff = ";:/,' \"\\";
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (email.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	posOfAtSign = email.indexOf("@",1)
	if (posOfAtSign == -1){
		return false;
	}
	if (email.indexOf("@",posOfAtSign+1) != -1){
		return false;
	}
	posOfPeriod = email.indexOf(".", posOfAtSign)
	if (posOfPeriod == -1){
		return false;
	}
	if (posOfPeriod+2 > email.length){
		return false;
	}
	return true
}*/


function validateEmail(email)
{
	var testresults

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(email))
		
		testresults=true
	else
	{
		testresults=false
	}
	return (testresults)
}

	
	
function newuser2_validation()

{
	
	//alert("alert");
	
	if(document.frmalert.email.value == "")
	{
		alert("Please enter email address");
		document.frmalert.email.focus();
		return false;
	}
	
	var email=document.frmalert.email.value;
	var check=validateEmail(email);
	if(!check)
	{
		alert("Please enter valid email address !");
		document.frmalert.email.focus();
		return false;
	}
	
		
	if(document.frmalert.fname.value == "")
		{
		alert("Please enter first name");
		document.frmalert.fname.focus();
		return false;
		}
		
	if(document.frmalert.sname.value == "")
		{
		alert("Please enter sur name");
		document.frmalert.sname.focus();
		return false;
		}
		
	if(document.frmalert.company.value == "")
		{
		alert("Please enter company");
		document.frmalert.company.focus();
		return false;
		}
	
	if(document.frmalert.country.value == "")
		{
		alert("Please enter valid country");
		document.frmalert.country.focus();
		return false;
		}	
		
	if(document.frmalert.country.value == "")
		{
		alert("Please enter valid country");
		document.frmalert.country.focus();
		return false;
		}
	if(document.frmalert.country.value == "")
		{
		alert("Please enter valid country");
		document.frmalert.country.focus();
		return false;
		}		
		
}
	
function newuser_validation()

{
 	
	if(document.frmmail.txt_email.value == "")
	{
		alert("Please enter email address");
		document.frmmail.txt_email.focus();
		return false;
	}
	else if(!validateEmail(document.frmmail.txt_email.value))
	{
		alert("Please enter email address in proper format");
		document.frmmail.txt_email.focus();
		return false;
	}
	else
	{
		return confirm('Are you sure want to unsubscribe from Frontera Resources emil alert?');
	}
}		
