// Make a POST to the server 
// and pass on any data from browser
// via the XMLHTTPRequest

function talktoServer(url){
	var req = newXMLHttpRequest();
	//register the callback handler function
  	var callbackHandler = getReadyStateHandler(req, updateMsgOnBrowser);
  	req.onreadystatechange = callbackHandler;
  	req.open("POST", url, true);
  	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  	req.send("msg");
}

// This is the callback functions that gets called
// for the response from the server with the XML data

function updateMsgOnBrowser(testXML) {
}


//the following two functions are helper infrastructure to 
//craete a XMLHTTPRequest and register a listner callback function

function newXMLHttpRequest() {
	var xmlreq = false;
	if (window.XMLHttpRequest) {
		xmlreq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
    		// Try ActiveX
		try { 
			xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) { 
			// first method failed 
			try {
				xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				 // both methods failed 
			} 
		}
 	}
   	return xmlreq;
} 

function getReadyStateHandler(req, responseXmlHandler) {
	return function () {
	if (req.readyState == 4) {
		if (req.status == 200) {
                  response = req.responseText;
                  splitarr = response.split("|");
                  document.orderform.out.value = splitarr[0];
                  alert (splitarr[1]);
		} else {
			//var hellomsg = document.getElementById("hellomsg");
			//hellomsg.innerHTML = "ERROR: "+ req.status;
      		}
    	}
 	}
}

