
<!--

function matchEmails(email1, email2) {
return (email1 == email2) ;
}

function checkEmail(email) {
var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
return (filter.test(email)) ;
}



function validate_contact_info (email,email2, name, email_body) {
	
	
	//give form the bennefit of the doubt,
	var fails = false;
	//trace errors for alert
	var errors = "";
	
	//test email
	if(!checkEmail(email))
	{
		fails=true;
		errors += "There is a problem with your email. \n";
	}
	if(!matchEmails(email, email2))
	{
		fails=true;
		errors += "Emails do not match. \n";
	}
	

	//test name
	if(name == '')
	{
		fails = true;
		errors += "Your name is empty. \n";
		
	}

	//testbody
	if(email_body== '')
	{
		fails = true;
		errors += "Your comment is empty. \n";
		
	}

	//resopnd to failure by printing error and return false
	if(fails)
	{
    	window.alert ("You Have Errors in the Form: \n" + errors);
		return false;
	}
	else
		return true;
}

function validate_and_send_contact (doc) 
{
	var form = doc.form;
	var name = form.name.value;
	var email = form.email.value;
	var email2 = form.email2.value;
	var email_body = form.email_body.value;
	
	if(validate_contact_info(email, email2, name, email_body))
	{
		 var postrequest = new request();
		postrequest.onreadystatechange = function ()
		{
			if (postrequest.readyState == 4) 
			{
				var cont = document.getElementById('Content');
				cont.innerHTML=postrequest.responseText;
			}
		
		};
		
		var parameters = "name=" + encodeURI(doc.form.name.value) +"&email=" +doc.form.email.value + "&email_body=" + encodeURI(doc.form.email_body.value);
		postrequest.open("POST", "contactdo.php", true);
		postrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		postrequest.send(parameters);	
	}
}
-->