function startFocus() {
	document.sendEmail.username.focus();
}


function makeHttpObject() {    
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
  return xmlhttp;
}

function emailValidation() {
	
	var sRequest = makeHttpObject();
	
	sRequest.open("POST", 'validateEmail.php', true);
	sRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	var param = 'username=' + document.getElementById('username').value;
	
	var userEmail = document.getElementById('username').value;

	sRequest.send(param);

	sRequest.onreadystatechange = function(){
		if (sRequest.readyState == 4) {
		var response = sRequest.responseText;
			if (response == "1") {
				var  myDiv = document.getElementById('valiDiv');
				myDiv.innerHTML = "<span style='color:maroon'>The email address text box appears to be blank. Please enter your email address.</span>";
				document.forms.sendEmail.reset();
				startFocus();
				
			} else if(response == "2") {
				var  myDiv = document.getElementById('valiDiv');
				myDiv.innerHTML = "<span style='color:maroon'>The email address (" + userEmail + ") you entered appears to be invalid.</span>";
				document.forms.sendEmail.reset();
				startFocus();
			} else if(response == "3") {
				var  myDiv = document.getElementById('valiDiv');
				myDiv.innerHTML = "<span style='color:maroon'>The email address (" + userEmail + ") you entered does not match any of our records.</span>";
				document.forms.sendEmail.reset();
				startFocus();
			} else {
				var  myDiv = document.getElementById('valiDiv');
				var  myButton = document.getElementById('sendButton');
				var  myBox = document.getElementById('username');


				myDiv.innerHTML = "<span style='color:maroon'>Password information has been sent to the email account associated with the information. Please use the <strong>Return </strong> button on the navigation bar to your left to return to the login page.</span>";
				myButton.style.display="None";
				myBox.style.display="None";



			}
		}
	}
	

	return false;	
}



