
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;
}
var httpObj = getHTTPObject();

//
// Given an HTML-writeable DOM element or the id name of one, 
//  takes 2nd argument text/html and re-draws the region.
//
// Optional 3rd arg also updates className of element.
//
function updateRegion() {
	var targetRegion = arguments[0];
	var targetRegionObj;
	if ( typeof targetRegion == "object" ) {
		targetRegionObj = targetRegion;
	} else {
		targetRegionObj = document.getElementById(targetRegion);
	}
	targetRegionObj.innerHTML = arguments[1];
	if ( arguments[2] ) { targetRegionObj.className = arguments[2]; }
}

//
// Given a document.form object and a function to execute when 
//  results (as text/xml) are loading into DOM, makes call to server
//  with form input.
//
// Page from which call is made has to include /scripts/ajax/getHttpObj.js as well.
//
// Currently, only GET method implemented.
//
function doAjaxForm() {
	if (httpObj) {    
		var searchQS = "?";
		var searchFields = arguments[0].elements;
		for ( var i=0; i<searchFields.length; i++ ) {
			searchQS = searchQS + searchFields[i].name + "=" + searchFields[i].value + "&";
		}
		httpObj.open("GET", arguments[0].action+searchQS, true);
		httpObj.onreadystatechange = arguments[1];
		httpObj.send(null);
	}
}

//
// Given a url and a function to execute when 
//  results (as text/xml) are loading into DOM, makes call to server
//  with url (params appended).
//
// Page from which call is made has to include /scripts/ajax/getHttpObj.js as well.
//
// Currently, only GET method implemented.
//
function doAjaxLink() {
	if (httpObj) {    
		var searchURL = arguments[0];
		httpObj.open("GET", searchURL, true);
		httpObj.onreadystatechange = arguments[1];
		httpObj.send(null);
	}
}
