/*
Required objects on HTML page:
document.frmContact
	.Email
	.Telephone
	.ContactName
	.CompanyName
	.Comments
*/

function isEmail (strEmail)
{
 var reEmail = /^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
 return reEmail.test (strEmail);
}

function validate_contact () {
	var re = /( |\s)/g;
	var strBullet = "\u2022\xA0\xA0 ";
	var strErrors = "";
	var intErrors = 0;
	
	//Verify email address
	if (!isEmail(document.frmContact.Email.value.replace(re,""))) {
		strErrors += strBullet + "A valid e-mail address is required.\n"
		intErrors++;
	}

	if (document.frmContact.Telephone.value.replace(re,"") == "") {
		strErrors += strBullet + "A contact telephone number is required.\n"
		intErrors++;
	}
	if (document.frmContact.ContactName.value.replace(re,"") == "") {
		strErrors += strBullet + "A contact name is required.\n"
		intErrors++;
	}
	if (document.frmContact.CompanyName.value.replace(re,"") == "") {
		strErrors += strBullet + "A company name is required.\n"
		intErrors++;
	}
	if (document.frmContact.Comments.value.replace(re,"") == "") {
		intErrors++;
		strErrors += strBullet + "Your comments are required.\n"
	}
	
	if (intErrors==0) {
		document.frmContact.submit()
	} else {
		if (intErrors==1) strPlural=""; else strPlural="s";
		window.alert("This form is not completely filled out - it has the following problem" + strPlural + ": \n\n" + strErrors);
	}
}