
//Gets the browser specific XmlHttpRequest Object
// *** ajax DOM test *** //
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		 //Internet Explorer
		 try {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 }
	}
	return xmlHttp;
}

function submitForm()
{ 
	document.getElementById("submitted").innerHTML="";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
	 alert ("Browser does not support HTTP Request")
	 return false;
	}
	
	var firstname = document.form1.FirstName.value;
	var lastname = document.form1.LastName.value;
	var email = document.form1.Email.value;
	var ip = document.form1.IP.value;
	
	var url ="/received.php";
	var data = "FirstName="+firstname+"&LastName="+lastname+"&Email="+email+"&MM_insert=form1&IP="+ip;
	data = data + "&ajaxid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedsubmit
	
	xmlHttp.open('POST', url, true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(data);
	return false;
}

function displayForm(){
	document.getElementById("submitted").innerHTML=	"";
	document.getElementById("submitform").style.display = "block";
}
function stateChangedsubmit() 
{ 
	
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("submitform").style.display = "none";
		document.getElementById("submitted").innerHTML=xmlHttp.responseText
	} else {
		document.getElementById("submitted").innerHTML="<div>Sending request ...</div>";

	}
}