//this file sets up all the xmlxttp connectivity required for AJAX updating of select fields
//to make the the xmlhttpURL() function work, you must provide handler functions as well

//hook up xmlhttp object depending on browser compatibility
var xmlhttp;

/*function to load ajax element*/
function loadAjax(){
	try {
	
		if (typeof XMLHttpRequest != 'undefined')
			// handle Opera, Safari, and Mozilla
			xmlhttp = new XMLHttpRequest();
		else if (typeof ActiveXObject != undefined) {
			// allow for both types of IE xml
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");		
			} catch (e) {
				try {
					xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (E) {
					xmlhttp = false;
				}
			}
		
		} else
			xmlhttp = false;
	} catch (y) {
		xmlhttp = false;
	}
}

/* generic xmlhttp document fetcher */
function xmlhttpURL(url, requestHandler) {
	if (typeof ActiveXObject != undefined) reloadAjax();
	if (xmlhttp) {
		xmlhttp.onreadystatechange = requestHandler;
		xmlhttp.open('GET', url, true);
		xmlhttp.send(null);
	}
}

/* generic xmlhttp form poster */
function xmlhttpPOST(url, params, requestHandler) {
	if (xmlhttp) {
		xmlhttp.onreadystatechange = requestHandler;
		xmlhttp.open('POST', url+"?"+params, true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", params.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(params);
	}
}

//actually load ajax here
loadAjax();
reloadAjax = loadAjax;
