var xmlhttp;

// IE code branch
if (Browser.IE) {
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		// Try an older object
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
} else {
	// Other browsers
	try {
		// Firefox and Safari method
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		try {
			// Last known method
			xmlhttp = window.createRequest;
		} catch (e) { }
	}
}

if (typeof(xmlhttp) == 'undefined') alert ('Couldn\'t initialize http object!');

function httprequest (page) {
	httprequest(page,null);
}

function httprequest (page, callback) {
	xmlhttp.open("GET", page, true);
	if (typeof(callback) == 'function') {
		xmlhttp.onreadystatechange = function () {
			if (xmlhttp.readyState==4) {
				// Create the return object
				var returnobject = new Object();
				returnobject.rawText = xmlhttp.responseText;
				// Split return value in lines
				var lines = xmlhttp.responseText.split('\n');
				// Digest each line
				for (x in lines) {
					line = lines[x];
					splt = line.indexOf('=');
					if (splt > -1)
						eval ('returnobject.'+line.substr(0,splt)+' = \''+line.substr(splt+1,line.length-splt-2)+'\';');
				}
				callback(returnobject);
			}
		}
	}
	xmlhttp.send(null);
}
