try 
{
	http = new XMLHttpRequest(); /* e.g. Firefox */
} 
catch(e) 
{
	try 
	{
    	http = new ActiveXObject("Msxml2.XMLHTTP"); 
  	}
	catch (e) 
	{
    	try 
		{
    		http = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
    	} 
		catch (E) 
		{
			http = false;
		} 
	} 
}

function AddSubscriber(email) // url = xyz.php?mode=
{
	//alert("1. " + email);
	if(!ValidateSubscriberEmail(email))
		return false;

	var url_str = "hilton_edwards_subscribers.php?sub_mode=ADD&email="+email;
	var myRandom=parseInt(Math.random()*99999999);  // cache buster

	//alert(url_str);
	//return false;
	
	http.open("POST", url_str +"&rand=" + myRandom, true);
	http.onreadystatechange = handleHttpSubscriberAddResponse;
	http.send(null);
}

function handleHttpSubscriberAddResponse()	// return type flag~id~display string
{
	if (http.readyState == 4)
	{
		//alert(http.responseText);
		results = http.responseText.split("~");
		result_len = results.length;

		if(results[0]==1) // only if successful...
		{
			if(document.all)
				document.location.href = "hilton_edwards_response_yes.php";
			else
				window.location = "hilton_edwards_response_yes.php";
		}
		else
		{
			if(results[1]=='Subscriber Exists')
			{
				if(document.all)
					document.location.href = "hilton_edwards_response_no.php?flag=x";
				else
					window.location = "hilton_edwards_response_no.php?flag=x";
			}
			else
			{
				if(document.all)
					document.location.href = "hilton_edwards_response_no.php";
				else
					window.location = "hilton_edwards_response_no.php";
			}
		}
  	}
}

function ValidateSubscriberEmail(email_txt)
{
	flag = true;
	
	if(str_trim(email_txt)=="" || !validate_email(email_txt))
		flag = false;
	
	return flag;		
}
