function emailCheck(a)
{
	var b=/^(.+)@(.+)$/;
	var c="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var d="\[^\\s"+c+"\]";
	var e="(\"[^\"]*\")";
	var f=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var g=d+'+';var h="("+g+"|"+e+")";
	var j=new RegExp("^"+h+"(\\."+h+")*$");
	var k=new RegExp("^"+g+"(\\."+g+")*$");
	var l=a.match(b);
	if(l==null)
	{
	return false}var m=l[1];
	var n=l[2];
	if(m.match(j)==null)
	{
		return false;
	}
	var o=n.match(f);
	if(o!=null)
	{
		for(var i=1;i<=4;i++)
		{
			if(o[i]>255)
			{
				return false;
			}
		}
		return true;
	}
	var p=n.match(k);
	if(p==null)
	{
		return false;
	}
	var q=new RegExp(g,"g");
	var r=n.match(q);
	var s=r.length; 
	if(r[r.length-1].length<2||r[r.length-1].length>3&&r[r.length-1]!='coop')
	{
		return false;
	}
	if(s<2)
	{
		var t="This address is missing a hostname!";
		return false;
	}
	return true;
}
	
function checkFormSubmit(a)
{
	var b=null;
	if(a=='top')
	{
		b=document.getElementById('txtemailtop');
		if(emailCheck(b.value))
		{
			if(document.all)
			{
				document.getElementById('errorTop').innerText="";
			}
			else
			{
				document.getElementById('errorTop').textContent="";
			}
			return true;
		}
		else
		{
			if(document.all)
			{
				document.getElementById('errorTop').innerText="Invalid email address.";
			}
			else
			{	
				document.getElementById('errorTop').textContent="Invalid email address.";
			}
			return false;
		}
	}
	else
	{
		b=document.getElementById('txtemailbtm');
		if(emailCheck(b.value))
		{
			if(document.all)
			{
				document.getElementById('errorBtm').innerText="";
			}
			else
			{
				document.getElementById('errorBtm').textContent="";
			}
			return true;
		}
		else
		{	
			if(document.all)
			{
				document.getElementById('errorBtm').innerText="Invalid email address.";
			}
			else
			{
				document.getElementById('errorBtm').textContent="Invalid email address.";
			}
			return false;
		}
	}
}
	
function checkFormClick(a)
{
	if(checkFormSubmit(a))
	{
		var b=null;
		if(a=='top')
		{
			b=document.getElementById('txtemailtop');
			var c="";
			if(document.getElementById('signUpUseg') != null)
			{
				c=document.getElementById('signUpUseg').value;
			}
			if(c!="")
			{
				document.frmEmailClubTop.action=baseUrl+'SubscriptionLandingPage.aspx?email='+b.value+'&useg='+c;
			}
			else
			{
				document.frmEmailClubTop.action=baseUrl+'SubscriptionLandingPage.aspx?email='+b.value;
			}
		}
		else
		{
			b=document.getElementById('txtemailbtm');
			var c="";
			if(document.getElementById('signUpUseg') != null)
			{
				c=document.getElementById('signUpUseg').value;
			}
			if(c!="")
			{
				document.frmEmailClubBtm.action=baseUrl+'SubscriptionLandingPage.aspx?email='+b.value+'&useg='+c;
			}
			else
			{
				document.frmEmailClubBtm.action=baseUrl+'SubscriptionLandingPage.aspx?email='+b.value;
			}
		}
		return true;
	}
	else
	{
		return false;
	}
}
function RegistrationFormClick()
{ 
	var a="";
	if(document.getElementById('registrantUseg') != null)
	{
		a=document.getElementById('registrantUseg').value;
	}
	if(a!="")
	{
		document.aspnetForm.action=baseUrl+'CustomerRegistration.aspx?useg='+a;
	}
	else
	{
		document.aspnetForm.action=baseUrl+'CustomerRegistration.aspx';
	}
	return true;
}
