var http;
var elementContainer;

function createRequestObject() {
	var ro;

	// First, try to create an XMLHttpRequest object for most modern browsers.
	try { ro = new XMLHttpRequest(); }
	catch (error) {
		/* If the default method didn't work, try to create the object for Microsoft IE 5/6 using an ActiveX Object. */
		try { ro = new ActiveXObject("Microsoft.XMLHTTP"); }
		catch (error) { return false; }
	}
	return ro;
}

// retrieve a page using the XMLHttpRequest object.
function http_getPage(url,qs,post,callFunc) {
/* @param url			- URL to retrieve
	@param qs			- query string portion (GET or POST)
	@param post			- if 1, POST operation used (response is returned)
	@param callFunc	- function to call when done (if GET used)
*/
	http = createRequestObject();
	if (http) {
		if (post) {
		// POST operation...
			http.open("POST",url,false);
			http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			http.send(qs);
			return http.responseText;
		}
		else {
		// GET operation...
			http.open("GET",url+((qs.length>0)?("?"+qs):""));
			http.send(null);
			http.onreadystatechange=callFunc;			
		}
	}
}

