// JavaScript Document

function removeText(txt, el)
{
	el.onblur = function ()
	{
		addText(txt, this);
	}
	
	if (el.value==txt) el.value = '';
}

function addText(txt, el)
{
	if (!el.value)
	{
		el.value = txt;
	}
}

function clientLogin()
{
	document.frm_clientLogin.submit();
}

function joinMailingList()
{
	var chck = new Array();
	var i=0;
	var frm = document.frm_joinMailingList;
	chck[i] = checkText(frm.emailaddress.value, "Your Email Address must be entered"); i++;
	chck[i] = checkEmail(frm.emailaddress.value, "Your Email Address is incorrect"); i++;
	
	for (var j=0; j<chck.length; j++)
	{
		if (chck[j])
		{
			alert(msg);
			initMessage();
			return ;
		}
	}
	frm.submit();
}

function removeMailingList()
{
	var frm = document.frm_removeMailingList;
	frm.submit();
}

var msg;
initMessage();

function initMessage()
{
	msg='The Following Errors occurred:\n----------------------------------------------';
}

function checkEmail(val, thisMsg)
{
	if (val)
	{
		var strPattern = /^[A-Za-z0-9][A-Za-z\-_0-9\.]+@[A-Za-z\-_0-9\.]+\.[A-Za-z]{2,3}$/;
		if (!strPattern.test(val))
		{
			msg+='\n - '+thisMsg;
			return true;
		}
	}	
}

function checkText(val, thisMsg)
{
	if (!val)
	{
		msg+='\n - '+thisMsg;
	 	return true;
	}
	else return null;
}

function checkTextLength(val, minL, maxL, thisMsg)
{
	if ((val<minL)||(val>maxL))
	{
		msg+='\n - '+thisMsg;
	 	return true;
	}
	else return null;
}
