
// declare a global  XMLHTTP Request object
//var XmlHttpObj;
// create an instance of XMLHTTPRequest Object, varies with browser type, try for IE first then Mozilla
// called from onChange or onClick event of the continent dropdown list
function subscribe() 
{

	var name=document.getElementById("subscriber_name").value;
	var mailid=document.getElementById("emailid").value;
	var status="OK";
	var requestUrl;
	if(name=="")
	{
	status="NOTOK";
	document.getElementById("showmessage").innerHTML="<font color='red'>Enter Name</font>";	
	}
	if(mailid=="" && status=="OK")
	{
	status="NOTOK";
	document.getElementById("showmessage").innerHTML="<font color='red'>Enter Mail Id</font>";		
	}
	if(mailid!="" && status=="OK")
{
var mailstatus=echeck(mailid);
if(!mailstatus)
{
document.getElementById("showmessage").innerHTML="<font color='red'>Enter Valid Mail Id</font>";	
}
}
	if(status=="OK")
	{
    requestUrl = "new_subscriber.php" + "?name="+name+"&mailid="+mailid;		
	
 
	
    // use the following line if using php
    // requestUrl = "xml_data_provider.php" + "?filter=" + encodeURIComponent(selectedContinent);
	
//alert(requestUrl);
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
//		alert("XmlHttpObj");
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandler;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
}}


// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function StateChangeHandler()
{
//	alert("readystate " + XmlHttpObj.readyState);
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
//		alert("readystate " + XmlHttpObj.status);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
//			alert("in 200:"+XmlHttpObj.responseXML.documentElement);
			Populatedistricts();
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}

// populate the contents of the country dropdown list
function Populatedistricts()
{
var emsg=XmlHttpObj.responseText;
//document.getElementById("complaincediv").style.display="none";
var err=emsg.split("_");
//alert(err[1]);
document.getElementById("showmessage").innerHTML=err[0];
if(err[1]=="1")
{
	document.getElementById("subscriber_name").value="";
	document.getElementById("emailid").value="";	
}
}

// returns the node text value 
