/*************************************************
 * Created by Hedde Bosman aka Tex-nd            *
 * Free to copy under the GPL license            *
 * ( http://www.gnu.org/copyleft/gpl.html )      *
 *************************************************/

/******************
 * creating the xmlHttpRequest object
 * from w3schools.com
 *****/
function createXmlHttpReq() {
var xmlhttp = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	return xmlhttp;
}
/******************
 * retrieve a given URL and set the handler;
 *****/
function getURL(url, fPtr, cls) {
	var xmlhttp = false;
	xmlhttp = createXmlHttpReq();
	
	if (xmlhttp) {
		xmlhttp.open("GET", url, true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4 && xmlhttp.status == 200) {
				if (xmlhttp.responseXML != undefined) {
					if (cls != undefined && cls != null) {
						// method of an object
						fPtr.call(cls, xmlhttp.responseText, xmlhttp.responseXML.documentElement);
					} else {
						fPtr(xmlhttp.responseText, xmlhttp.responseXML.documentElement);
					}
				} else {
					if (cls != undefined && cls != null) {
						fPtr.call(cls, xmlhttp.responseText, null);
					} else {
						fPtr(xmlhttp.responseText, null);
					}
				}
			}
		}
		xmlhttp.send(null)
	} else {
		return false;
	}
	return true;
}


