function Trim(strValue) 
	{
		return LTrim(RTrim(strValue));
	}

function CheckMandatory(oForm)
	{
		var oElement;
		var strError = '';
		
		//check each object to see if it is Mandatory
		for(i=0; i<oForm.elements.length; i++)
		{
			oElement = oForm.elements[i];
	
			if((oElement.attributes['Mandatory']) && ((oElement.value + '') == ''))
			{
				strError = strError + '\n - Please supply a value for `'+oElement.attributes['Header'].value +'`';
			}
		}
		
		return strError;
	}

function CheckNumeric(oForm)
	{
		var oElement;
		var strError = '';
		
		//check each object to see if it is Mandatory
		for(i=0; i<oForm.elements.length; i++)
		{
			oElement = oForm.elements[i];
			
			if(oElement.Numeric && (oElement.value + '') != '')
			{
				if(isNaN(oElement.value))
				{
					strError = strError + '\n - Please supply a numeric value for `'+oForm.elements[i].Header+'`';
				}
			}
		}
		
		return strError;
	}

function CheckEmail(oForm)
	{
		var oElement;
		var strError = '';
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		
		//check each object to see if it is Mandatory
		for(i=0; i<oForm.elements.length; i++)
		{
			oElement = oForm.elements[i];
			
			if(oElement.Email && (oElement.value + '') != '')
			{	
				if(filter.test(oElement.value))
				{
				}
				else
				{
					strError = strError + '\n - Please supply a valid email address in `'+oForm.elements[i].Header+'`';
				}
			}
		}
		
		return strError;
	}

//function to check where there is an email address before trying to 
//send the password to a non existant email address
//function GetEmail(ID, ForgotPassword) 
//	{
//		var strError = '';
//		var oEmailAddress = ID;
//		var oForgotPassword = ForgotPassword;
//		
//		if ((Trim(oEmailAddress.value) == '') || (Trim(oEmailAddress.value) == 'Email Address')) {
//			strError = strError + '\n - Please fill in `'+oEmailAddress.Header+'`';
//		}
//	
//		//if there was an error then display it else go to the next page
//		if (strError.length == 0) {
//			oForgotPassword.href = oForgotPassword.href + oEmailAddress.value;
//			return true;
//		} else {
//			alert('Please correct the following errors:'+strError);
//			return false;
//		}
//	}

function ShowHide(ID) {
	if (document.getElementById(ID).style.display == 'none') {
		document.getElementById(ID).style.display = 'block';
	} else {
		document.getElementById(ID).style.display = 'none';
	}
	
}

function ForgottenPassword() 
{
	if (document.getElementById('EmailAddress').value == ''){
		alert('Please enter your email address.');
		return false;
	} else {
		document.getElementById('Forgotten').href = 'email_password.asp?EmailAddress=' + document.getElementById('EmailAddress').value;	
	}
}

//function GetEmail() {
//	var strError = '';
//	var oEmailAddress = document.getElementById('EmailAddress');
//	var oForgotPassword = document.getElementById('ForgotPassword');
//
//	if (oEmailAddress.value == '') {
//		strError = strError + '\n - Please fill in your Email Address';
//	}	
//
//	//if there was an error then display it else go to the next page
//	if (strError.length == 0) {
//		oForgotPassword.href = oForgotPassword.href + oEmailAddress.value;
//		return true;
//	} else {
//		alert('Please correct the following errors:'+strError);
//		return false;
//	}
//
//}
//
