// JavaScript Document
function generateEmail(){
	var mailObject = new createXMLHttpRequest();
	mailObject.onreadystatechange = parseStatus;
	function parseStatus(){
		if (mailObject.readyState == 4) {
			if (mailObject.status == 200) {				
				document.getElementById('questionBox').value = "Your question was sent, thank you!";
				setTimeout("document.getElementById('questionBox').value = ''",500);
			} else {
				// server error
			}
		}
	}
	this.sendEmail = function(toVal,messageVal,nameVal,emailVal) {
		var completeMessage = '?to='+toVal+'&message='+messageVal+'&from_n='+nameVal+'&from_e='+emailVal;
		document.getElementById('questionBox').value = "Please be patient while your question is sent...";
		mailObject.open('GET','./php/email.php'+completeMessage,true);
		mailObject.send(null);
	}
}
/** Extended email */
	var emailFunction = new generateEmail();
function sendEmail(emailObject){
	var prayer = document.getElementById('questionBox').value;
	var from_n = document.getElementById('name').value;
	var from_e = document.getElementById('email').value;
	var to = "gx3chaos@gmail.com";
	emailFunction.sendEmail(to,prayer,from_n,from_e);
}
