/******* Some utility AJAX functions. Written by Aaron Davidson. Last updated on 8/17/07. *******/
/** Loads the XML file to be traversed/read by loading from ActiveObject xmlDoc the XML file xmlFile.
 *  IMPORTANT: Sends verification function to the function verify. You must implement this method to get anything back. 
 */
function loadXML(xmlDoc, xmlFile) {
  xmlDoc.onreadystatechange=verify;

	if(!isIE())
	{
    		xmlDoc.open("GET", xmlFile, true);
		xmlDoc.send(null);
	}
	else
	{
    		xmlDoc.async="false";
		xmlDoc.load(xmlFile);
	}
}

/** Returns if this browser is IE or not (the other browsers mostly share the same DOM architecture) */
function isIE()
{
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE");
		version=parseFloat(temp[1]);
		if(version >= 5.5)
			return true;
	}

	return false;
}

/** Returns the active object, however it can be returned by this browser. */
function getActiveObject()
{
	if(isIE())
		return new ActiveXObject("Microsoft.XMLDOM");
	else
		return new XMLHttpRequest();
}

/** Strips a string of excess whitespace (including \t and \n characters and leading 0s) at its beginning and end. */
function strip(str)
{
	return stripEnd(stripFront(str));
}

function stripFront(str)
{
	if(str.substring(0,1) == " " || str.substring(0,1) == "\t" || str.substring(0,1) == "\n" || (str.substring(0,1) == "0" && str.length > 1))
		return stripFront(str.substring(1));
	else
		return str;
}

function stripEnd(str)
{
	if(str.substring(str.length-1) == " " || str.substring(str.length-1) == "\t" || str.substring(str.length-1) == "\n")
		return stripEnd(str.substring(0, str.length-1));
	else
		return str;
}
