

function emailvalidation(field, alertbox) {
	var goodEmail = field.val().match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
	
	apos=field.val().indexOf("@");
	dotpos=field.val().lastIndexOf(".");
	lastpos=field.val().length-1;
	
	var badEmail = (apos<1 || dotpos-apos<2 || lastpos-dotpos<2)
	
	if (goodEmail && !badEmail) {
		return true;
	}
	else {
		alert(alertbox);
		field.focus();
		field.select();
		return false;
   }
}

function emptyvalidation(entered, alertbox)
{
	with (entered)
	{
		if (value==null || value=="")
			{if (alertbox!="") {alert(alertbox);} return false;}
		else {return true;}
	}
}

function formvalidation(email)
{
	if (emailvalidation(email,"Please enter your valid email address")==false) {email.focus(); return false;};
}
