// JavaScript Document// create a xml http request objectfunction CreateXmlHttpRequest(){	var httpRequest = null;	try	{		httpRequest = new ActiveXObject("Msxml2.XMLHTTP");	}	catch (e)	{		try		{			httpRequest = new ActiveXObject("Microsoft.XMLHTTP");		}		catch (e)		{			httpRequest = null;		}	}		if (!httpRequest && typeof XMLHttpRequest != "undefined")	{		httpRequest = new XMLHttpRequest();	}	//alert(httpRequest);	return httpRequest;}// get url use via syncfunction getUrlSync(url){	return getUrl(url, false, null);}// get url use via asyncfunction getUrlAsync(url, handleStateChange){	return getUrl(url, true, handleStateChange);}function getUrlXMLResponseCallback(xmlHttpReq) {	if(xmlHttpReq.responseXML == null) {		alert("Error while processing your request.");		return;	}	var root_node = getRootNode(xmlHttpReq);	//alert (root_node);	var return_code = getNodeValue(root_node, 'Return_code');	//alert("return code " + return_code);	if(return_code == 0) {		var content = getContentNode(xmlHttpReq);		/*if (content != null) {			alert(content);		}*/		if(this.successCallback != null) {			this.successCallback(xmlHttpReq, content, return_code, error_msg);		}	} else {		var error_msg = getNodeValue(root_node, 'Message');		if(this.successCallback != null) {			this.successCallback(xmlHttpReq, content, return_code, error_msg);		}						//alert(error_msg)	}}// execute on successfunction execOnSuccess(stateChangeCallback){	return function(xmlHttpReq)		{			if(xmlHttpReq.readyState == 4){				if(xmlHttpReq.status == 200){										stateChangeCallback(xmlHttpReq);					//alert(xmlHttpReq + " " + xmlHttpReq.readyState + " " + xmlHttpReq.status);									}else{					//alert("xml http status is " + xmlHttpReq.status);				}			}else{				//alert("xml http ready state is " + xmlHttpReq.readyState);			}					};}// get urlfunction getUrl(url, async, handleStateChange) {	var xmlHttpReq = CreateXmlHttpRequest();	if (!xmlHttpReq)		return;	if (handleStateChange)	{		xmlHttpReq.onreadystatechange = function()			{				handleStateChange(xmlHttpReq);			};	}	else	{		xmlHttpReq.onreadystatechange = function() {;}	}		xmlHttpReq.open("GET", url, async);	xmlHttpReq.send(null);	//alert(xmlHttpReq);}// get url xml responsefunction getUrlXMLResponse(url, successCallback) {	this.successCallback = successCallback;	this.urlResponseCallback = getUrlXMLResponseCallback;	getUrl(url, true, execOnSuccess(this.urlResponseCallback)) 	}// post urlfunction postUrl(url, data, async, stateChangeCallback) { 	var xmlHttpReq = getXmlHttpRequest(); 	if (!xmlHttpReq)		return;	xmlHttpReq.open("POST", url, async);	xmlHttpReq.onreadystatechange = function() {			stateChangeCallback(xmlHttpReq);		};	// post url must set content-type with value application/x-www-form-urlencoded	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	xmlHttpReq.send(data);	//alert ('url: ' + url + '\ndata: ' + data);}// post url xml responsefunction postUrlXMLResponse(url, data, successCallback) {	this.successCallback = successCallback;	this.urlResponseCallback = getUrlXMLResponseCallback;	postUrl(url, data, true, execOnSuccess(this.urlResponseCallback))}// get a node value with specific tag namefunction getContentNode(xmlHttpReq) {	return xmlHttpReq.responseXML.getElementsByTagName('Content')[0];}// get a node value with tag namefunction getNodeValue(obj,tag) {	node=obj.getElementsByTagName(tag);		if(node!=null && node.length>0) {		return node[0].firstChild.nodeValue;	}	else {		return null;	}}// get the root objectfunction getRootNode(xmlHttpReq) {	return xmlHttpReq.responseXML.getElementsByTagName('plist')[0];}