// ------------------------------------------------------------------------------------------------------------
// FW4's modified AJAX routine
// -------------------------------------
// Usage:
// geturl(url,functionname)
//
// url = url :)
// functionname = you have to make this one yourself outside this js file
//	e.g. myfunction(t)
// 		t will be the requested content, passed to function "myfunction"
// ------------------------------------------------------------------------------------------------------------

var http = new Array();
pid=0;

rs1="-|éX(§èçàµ£*¨";
rs2="(éµù^(é$ù(";
rs3="èçàµ$*£µ£_è";

function handleHttpResponse(p,rf) {
	if (http[p].readyState == 4) {
		t=http[p].responseText;

		// remove carriage return
		while (t.indexOf("\r")!=-1) t=t.replace("\r","");

		// escape backslashes
		while (t.indexOf("\\")!=-1) t=t.replace("\\",rs3);
		while (t.indexOf(rs3)!=-1) t=t.replace(rs3,"\\\\'");

		// escape single quotes
		while (t.indexOf("'")!=-1) t=t.replace("'",rs1);
		while (t.indexOf(rs1)!=-1) t=t.replace(rs1,"\\'");

		// replace and escape line feeds
		while (t.indexOf("\n")!=-1) t=t.replace("\n",rs2);
		while (t.indexOf(rs2)!=-1) t=t.replace(rs2,"\\n");

		s=rf+"('"+t+"')";
		eval(s);
	}
}

function geturl(url,retfunc) {
	http[pid] = getHTTPObject();
	http[pid].open("GET", url, true);
	http[pid].onreadystatechange = new Function("handleHttpResponse("+pid+",'"+retfunc+"')");
	http[pid].send(null);
	pid++;
}



// do not touch below, it'll be screwed up... trust me

function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

