//-------------------------------------------------------------------------------
//- XML RPC HANDLER
//-------------------------------------------------------------------------------

var SERVER_URI = 'ajax/xml_rpc.php';

function create_http_handle(TYPE){
	var http_handle = false;
	if (window.XMLHttpRequest){
		http_handle = new XMLHttpRequest();
		if (http_handle.overrideMimeType){
			if (TYPE == "XML"){
				http_handle.overrideMimeType('text/xml');
			} else {
				http_handle.overrideMimeType('text/html');
			}
		}
	} else if (window.ActiveXObject){
		try {
			http_handle = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_handle = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_handle){
		alert("We are sorry but you are using an outdated browser.  To view this site you must update your browser.");
		return false;
	} else {
		return http_handle;
	}
}

function sendHTTPrequest(PARAMETERS, ONCHANGE, METHOD, TYPE){
	if (TYPE == "")TYPE = "HTML";
	http = create_http_handle(TYPE);
	
	http.onreadystatechange = function() {
		if(http.readyState == 4 && http.status == 200) {
			eval(ONCHANGE + '();');
		}
	}
	
	//Kill the Cache problem in IE.
//	var now = "upid=" + new Date().getTime();
//	PARAMETERS += (PARAMETERS.indexOf("?")+1) ? "&" : "?";
//	PARAMETERS += now;
	if (METHOD == "POST"){
		http.open('POST', SERVER_URI , true);
		http.setRequestHeader("Content-type", "application/x-www-form-URLencoded");
		http.setRequestHeader("Content-length", PARAMETERS.length);
		http.setRequestHeader("Connection", "close");
		http.send(PARAMETERS);
	} else {
		http.open('GET', SERVER_URI + PARAMETERS, true);
		http.send(null);
	}
}
