// JavaScript Document

// Get the HTTP Object
function getHTTPObject(){
if (window.ActiveXObject) 
return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) 
return new XMLHttpRequest();
else {
alert("Your browser does not support AJAX.");
return null;
}
}
// Implement business logic    
function doValidInsert(){
httpObject = getHTTPObject();
	if (httpObject != null) {
	
	var url="register-exec.php"
	
	url=url+"?email="+document.getElementById('email').value+"&fname="+document.getElementById('fname').value+"&lname="+document.getElementById('lname').value+"&streetaddress1="+document.getElementById('streetaddress1').value+"&streetaddress2="+document.getElementById('streetaddress2').value+"&city="+document.getElementById('city').value+"&state="+document.getElementById('state').value+"&zip="+document.getElementById('zip').value+"&country="+document.getElementById('country').value;
	url=url+"&sid="+Math.random()
	
	httpObject.onreadystatechange=setOutput 
	
	//Get the php page
	httpObject.open("POST",url,true)
	httpObject.send(null)
}
}
// Change the value of the outputText field
function setOutput(){
if(httpObject.readyState == 4){
if(httpObject.responseText=="thanks"){
window.location="thanks.php";
} else {
document.getElementById("submiterrorMsg").style.display='block';
document.getElementById("submiterrorMsg").innerHTML= httpObject.responseText;
window.location="registration.php#top";
}

}
}