/***********************************************
* Email Validation script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function isEmail(email) {
	return /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i.test(email);
}

function sendEmail(name, email, subject, comments, bodyID, errorID) {
	document.getElementById('errorMessage').innerHTML = "";

	while (comments.indexOf('\n') >= 0) comments = comments.replace('\n', '<br>');
	
	http = getXMLHTTPObject();
	http.open("POST", "includes/ajax.php?function=sendEmail&name=" + name + "&email= " + email + "&subject=" + subject + "&comments=" + comments, true);
	http.send(null);
	
	http.onreadystatechange = function() {
		if (http.readyState == 4)
			if (http.responseText != "")
				if (http.responseText == "E-Mail Sent!")  document.getElementById(bodyID).innerHTML = "E-Mail Sent!";
				else document.getElementById(errorID).innerHTML = http.responseText;
	}
}
