// JavaScript Document
var xmlHttp;

function sendXMLRequesst(url,parameters) {
	
	xmlHttp=getXmlHttpObject();

	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	/* get method.
	xmlHttp.onreadystatechange=processXMLRequest;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	*/
	
	// post method.
	xmlHttp.onreadystatechange = processXMLResponse;
    xmlHttp.open('POST', url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", parameters.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(parameters);
    
	
} // End of Function.
 
function getXmlHttpObject() {
	var xmlHttp=null;
	
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	return xmlHttp;
} // End of Function.
 
function processXMLResponse() {
		// only if req shows "complete"
		
		if (xmlHttp.readyState == 4) {
			// only if "OK"
			if (xmlHttp.status == 200) {
				// ...processing statements go here...
				
				response = xmlHttp.responseXML.documentElement;
			
				method = response.getElementsByTagName('method')[0].firstChild.data;
				
				result = response.getElementsByTagName('result')[0];
							
				eval(method + '(result)');
			} else {
				alert("There was a problem retrieving the XML data:\n" + xmlHttp.statusText);
			}
		}
	
} // End of Function.
