var mobile = false;

function BodyLoad()
{
	if (jsMobile == "y")
		mobile = true;

	if (!mobile)
		PcBodyLoad();
}

// following works - if needed
//$(function()
//{
//	$("#m_aReadMore").bind('tap', function(event, ui)
//	{
//		//$("#whichEvent p").replaceWith("<p>Event Triggered: Tap Hold</p>");
//		alert("tap");
//	})
//})

function DownloadEscript(action)
{
	if (document.theForm.email.value.length == 0)
	{
		alert("Please enter your email address");
		return;
	}
	if (!ValidEmail(document.theForm.email.value))
	{
		alert("Please enter a valid email address");
		return;
	}
	if (!ValidChars(document.theForm.email))
		return;

	document.theForm.action = "default.aspx?" + action;
	document.theForm.submit();
}

function ValidEmail(EmailValue)
{
	var len = EmailValue.length;
	if (len < 10)
		return false;
	var DotPos = EmailValue.indexOf(".");
	if (DotPos < 1 || DotPos > len - 3)	// dot must exist and have at least 2 chars after it
		return false;
	var comma = EmailValue.indexOf(",");
	if (comma != -1)
		return false;
	var AmpPos = EmailValue.indexOf("@");
	if (AmpPos < 2)	// @ must exist and have at least 2 chars before it
		return false;
	var LastAmpPos = EmailValue.lastIndexOf("@");
	if (LastAmpPos != AmpPos)	// can't have 2 @
		return false;
	if (EmailValue.indexOf("..") > 0)
		return false;

	return true;
}

function ValidChars(obj)
{
	return ValidCharsPlus(obj, "");
}

function ValidCharsPlus(obj, extraChars)
{
	if (obj.value.length == 0)
		return true;

	var validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '-!$%,.?@#():_";
	validChars += extraChars;
	var c, ix;

	for (ix = 0; ix < obj.value.length; ix++)
	{
		c = obj.value.charAt(ix);
		if (validChars.indexOf(c) == -1)
		{
			if (c == "\n" || c == "\r" || c == "\t")
			//	alert("Please do not press the ENTER or TAB keys when entering your text.");
			//else
				continue;
			alert("Please remove the following character from your entry: " + c);
			obj.focus();
			return false;
		}
	}

	return true;
}
