
<!-- Begin
function ajax_addToEmailList() {
	var email = document.getElementById("email2add").value;
	if(email == '')
	{
		alert("Please input your email address.");
	}else{
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(email))
		{
			addToEmailList();
		}else{
			alert("Please input a valid email address.");
		}

	}

}
function ajaxInitial()
{
	try {
	  request = new XMLHttpRequest();
	} catch (trymicrosoft) {
	  try {
		request = new ActiveXObject("Msxml2.XMLHTTP");
	  } catch (othermicrosoft) {
		try {
		  request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (failed) {
		  request = false;
		}
	  }
	}
	
	if (!request)
		alert("Error initializing XMLHttpRequest!");
	return request;
}
function getInfo(where,request)
{
	var readyState=request.readyState;	
   if (readyState == 4)
	{
		var out= request.responseText;
	}else{
		var out = "<div id='loading_img'><img src='images/loading.gif' /></div>";
	}
	document.getElementById(where).innerHTML = out;
}
function addToEmailList()
{
	var http = ajaxInitial();
	var ParamString = "";
	ParamString += 'email='+document.getElementById('email2add').value;

	var url = "add2emaillist.php?action=add";

	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", ParamString.length);
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function() {getInfo('emailListTable',http)};//Call a function when the state changes.
	http.send(ParamString);
}
function backToForm()
{
	var http = ajaxInitial();

	var url = "add2emaillist.php";

	http.open("GET", url, true);
	
	http.onreadystatechange = function() {getInfo('emailListTable',http)};//Call a function when the state changes.
	http.send(null);
}
// End -->
