function getHTTPObject() {
    var xmlhttp;
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    return xmlhttp;
}

var http = getHTTPObject(); // We create the XMLHTTPRequest Object
function handleHttpResponse() {
    //check if the response has been received from the server
    if(http.readyState == 4){
        //read and assign the response from the server
        var response = http.responseText;
        //do additional parsing of the response, if needed
        //in this case simply assign the response to the contents of the <div> on the page.
       	if(response == ""){
        	getResult(obj_id_temp, obj_param_temp, obj_url_temp);
        } 
		document.getElementById(obj_id_temp).innerHTML = response;
        //If the server returned an error message like a 404 error, that message would be shown within the div tag!!. 
        //So it may be worth doing some basic error before setting the contents of the <div>
          
	}
}
var obj_id_temp;
var obj_param_temp;
var obj_url_temp;

function getResult(obj_id, obj_param, obj_url) {
	obj_id_temp = obj_id;
	obj_param_temp = obj_param;
	obj_url_temp = obj_url;
    http.open("POST", obj_url + "?action=" + escape(obj_param) + "&param=" + Math.random(), true);
    http.onreadystatechange = handleHttpResponse;   
    http.send(null);    
}


function getLogin(obj_id, obj_uname , obj_pass , obj_url) {
	obj_id_temp = obj_id;
	obj_uname_temp = obj_uname;
	obj_pass_temp = obj_pass;
	obj_url_temp = obj_url;
//	alert(obj_pass);
    http.open("POST", obj_url + "?uname=" + escape(obj_uname) + "&pass=" + escape(obj_pass) + "&param=" + Math.random(), true);
    http.onreadystatechange = handleHttpResponse;   
    http.send(null);    
}


function getPoll(obj_id, obj_idd, obj_poll , obj_url) {
	obj_id_temp = obj_id;
	obj_idd_temp = obj_idd;
	obj_poll_temp = obj_poll;
	obj_url_temp = obj_url;
//	alert(obj_pass);
    http.open("POST", obj_url + "?id=" + escape(obj_idd) + "&poll=" + escape(obj_poll) + "&param="+ Math.random(), true);
    http.onreadystatechange = handleHttpResponse;   
    http.send(null);    
}

////////////////////////////////////////////
var http1 = getHTTPObject(); // We create the XMLHTTPRequest Object
function handleHttpResponse1() {
    //check if the response has been received from the server
    if(http1.readyState == 4){
        //read and assign the response from the server
        var response = http1.responseText;
        //do additional parsing of the response, if needed
        //in this case simply assign the response to the contents of the <div> on the page.
       	if(response == ""){
        	getResult(obj_id_temp1, obj_param_temp1, obj_url_temp1);
        } 
        document.getElementById(obj_id_temp1).innerHTML = response;
        //If the server returned an error message like a 404 error, that message would be shown within the div tag!!. 
        //So it may be worth doing some basic error before setting the contents of the <div>
          
	}
}
var obj_id_temp1;
var obj_param_temp1;
var obj_url_temp1;

function getResult1(obj_id, obj_param, obj_url) {
	obj_id_temp1 = obj_id;
	obj_param_temp1 = obj_param;
	obj_url_temp1 = obj_url;
    http1.open("POST", obj_url + "action=" + escape(obj_param) + "&param=" + Math.random(), true);
    http1.onreadystatechange = handleHttpResponse1;   
    http1.send(null);    
}
