var req;
var responseStr;
function initRequest(postString){
	
	var theCookie = document.cookie;
	


    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("POST", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {


			//WE SET THE AJAXSTATE TO MAP IF WE ARE REQUESTING A MAP
			//WE SET THE AJAXSTATE TO QUERY IF WE ARE REQUESTING FEATURE INFORMATION
			if (ajaxState == "MAP"){

				//WE PASS THE AJAX RESPONSE TO processMapChange IF A MAP WAS REQUESTED
				req.onreadystatechange = processMapChange;
				req.open("POST", "makemap.aspx", true);
				req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
				req.setRequestHeader("Cookie", theCookie);
				req.send(postString);
			}else if (ajaxState == "QUERY"){
				req.onreadystatechange = processQueryChange;
				req.open("POST", "makequery.aspx", true);
				req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
				req.send(postString);
			}
			
        }
    }
}



//handleMapUpdate AND handleQueryUpdate ARE BOTH CONTAINED IN GEOMAPTOOLS.JS
//WHICH IS INCLUDED IN THE MAPWORKER.ASPX PAGE
function processMapChange(){
    // only if req shows "complete"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
			top.ajaxFrame.handleMapUpdate(req.responseText);
        } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
            //clearMapData();
            return null;            
        }
    }
}
function processQueryChange(){
    // only if req shows "complete"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
			top.ajaxFrame.handleQueryUpdate(req.responseText);
        } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
            //clearMapData();
            return null;            
        }
    }
}



