function isEmail(str)
{
	// are regular expressions supported?
	var supported = 0;
	if (window.RegExp)
	{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr))
		{
			supported = 1;
		}
	}
	if (!supported)
	{
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	}
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

function CheckForm()
{
	var alertmessage = '';
	if(document.getElementById('ContactUsForm').Name.value == '')
	{
		alertmessage += "\n -   Please tell us your name";
	}
	if(document.getElementById('ContactUsForm').Email.value == '')
	{
		alertmessage += "\n -   Please enter your email address at which we can contact you";
	}
	if(document.getElementById('ContactUsForm').EmailConf.value == '')
	{
		alertmessage += "\n -   Please confirm your email address";
	}
	if(document.getElementById('ContactUsForm').Email.value != document.getElementById('ContactUsForm').EmailConf.value)
	{
		alertmessage += "\n -   Your confirmation email does not match your email";
	}
	if(document.getElementById('ContactUsForm').Email.value != '')
	{
		if(isEmail(document.getElementById('ContactUsForm').Email.value) == 0)
		{
			alertmessage += "\n -   Please enter a valid email address";
		}
	}
	if(document.getElementById('ContactUsForm').EmailConf.value != '')
	{
		if(isEmail(document.getElementById('ContactUsForm').EmailConf.value) == 0)
		{
			alertmessage += "\n -   Please enter a valid email address in the confirmation field";
		}
	}
	if(document.getElementById('ContactUsForm').Message.value == '')
	{
		alertmessage += "\n -   Please tell us why you are contacting us in the message field";
	}
	if(alertmessage == '')
	{
		document.getElementById('ContactUsForm').submit();
		return true;
	}
	else
	{
		topmessage = "There are the following errors on the form:\n";
		alertmessage += "\n\n Please click OK and complete all fields to continue";
		errormessage = topmessage + alertmessage;
		alert(errormessage);
		return false;
	}
}

