var xmlHttp;
var receiveMethod = "text";

function GetXmlHttpObject(){
 
	var objXMLHttp=null;
	if (window.XMLHttpRequest) 	objXMLHttp=new XMLHttpRequest();
	else if (window.ActiveXObject)	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	return objXMLHttp;
}


function sendGET(queryString) {
   xmlHttp=GetXmlHttpObject();
   
   xmlHttp.onreadystatechange = handleStateChange;
   xmlHttp.open("GET", queryString, true);
   xmlHttp.send(null);
}

function sendPOST(url, queryString) {
    xmlHttp=GetXmlHttpObject();
   
    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");   //multipart/form-data
    xmlHttp.send(queryString);
}
  
function handleStateChange() {
    if(xmlHttp.readyState == 4) {
        switch(xmlHttp.status){
        		case 200:
        			if(receiveMethod=="text") completeEventHandlerText(xmlHttp.responseText);
        			else completeEventHandler(xmlHttp.responseXML);
        			break;
        		case 204:
        			if(xmlHttp.status == 204) errorEventHandler();
        			break;
        		case 404:
        			alert('File not found');
        			break;
        	}
    }
}

