var xmlHttp = null;

function addToMailingList()
{
		var name = document.getElementById("name").value;
		var email = document.getElementById("email").value;

		//send request
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
			alert ("Browser does not support HTTP Request");
			return;
		  } 
		var url="php/addToMailingList.php";
		xmlHttp.onreadystatechange=updateSignUpFields;
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("name=" + escape(name) + "&email=" + escape(email)); 

}


function updateSignUpFields() 
{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{		
		  // locate form on page
		  var replaceDiv = document.getElementById("signup");
		  var form = document.getElementById("signupform");
		  
		  // create confirmation text
		  pElement = document.createElement("p");
		  textNode = document.createTextNode(xmlHttp.responseText);
		  pElement.appendChild(textNode);
		  
		  // replace form
		  replaceDiv.replaceChild(pElement, form);
		} 
}