<!--
//document.Events.SearchCity.focus();

function checkEmail(obj)
{
	var fieldList;
    
	fieldList = document.getElementsByTagName("input");

    for(var i = 0; i < fieldList.length; i++)
    {
    	if(fieldList[i].name == "Receive-Email-Address" || fieldList[i].name == "Remove-Email-Address")
        {
        	sub = validateEmail(fieldList[i]);
            if(!sub)
            {
            	return false;
            }
        }
    }
    return true;
    
}

function validateEmail(emailField)
{
	var	emailValue;
	var matchEmail = "";
	var emailFieldId;
	
	emailValue = emailField.value;
	
	matchEmail = emailValue.match(/^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$/);
	
	if(!matchEmail && emailValue != "")
	{
		alert("The following Errors Occurred\n\n You must enter a valid email address.\n");
		
		emailFieldId = emailField.id;
		
		if (document.getElementById)
		{		
			wholeEmailField = document.getElementById(emailFieldId);
		}
		else if (document.all)
		{
			wholeEmailField = document.all[emailFieldId];
		}
		
		setTimeout("wholeEmailField.focus()", 100);
		setTimeout("wholeEmailField.select()", 100);
		return false;
	}
	return true;
}

function ValidateForm(theForm)
{
var sErr = "";

	if ((document.Subscribe.fchkEmpREC.checked) || (document.Subscribe.fchkWorREC.checked) || (document.Subscribe.fchkMedREC.checked)) 
	{
		if (document.Subscribe.fAddEmail.value == "")
		{
			 sErr += "You must enter the email address to which the newsletter is to be sent.\n";
		}
	}
	if ((document.Subscribe.fchkEmpREM.checked) || (document.Subscribe.fchkWorREM.checked) || (document.Subscribe.fchkMedREM.checked)) 
	{
		if (document.Subscribe.fRemEmail.value == "")
		{ 
			sErr += "You must enter the email address to which the newsletter is to stop being sent.\n";
		}
	}
	if(document.Subscribe.fAddEmail.value != "")
	{
		if(!(document.Subscribe.fchkEmpREC.checked) && !(document.Subscribe.fchkWorREC.checked) && !(document.Subscribe.fchkMedREC.checked))
		{
			sErr += "You must select a newsletter you would like to receive.\n";		
		}
	}
	if(document.Subscribe.fRemEmail.value != "")
	{
		if(!(document.Subscribe.fchkEmpREM.checked) && !(document.Subscribe.fchkWorREM.checked) && !(document.Subscribe.fchkMedREM.checked))
		{
			sErr += "You must select a newsletter listing you would like to be removed from.\n";		
		}
	}
	
	
	if (sErr != "") 
	{
		alert("The following Errors Occurred\n\n" + sErr);
		return false;
	}
	else
	{
		emailOk = checkEmail(theForm);
		if(!emailOk)
		{
			return false;
		}
		return true;
	}
}
//-->



