var xmlReq;
var xmlReqFunction;

function GetXML(url, reqFunctionVar) {  //url to open; function to call (send empty string if no function needed)
	xmlReqFunction = reqFunctionVar;

	try { xmlReq=new XMLHttpRequest(); } //compliant browsers
	catch (e) {
		try { xmlReq=new ActiveXObject("Msxml2.XMLHTTP"); } //IE
		catch (e) {
			try { xmlReq=new ActiveXObject("Microsoft.XMLHTTP"); } //old IE
			catch (e) { /*alert("Error");*/ }
		}
	}
  
	xmlReq.onreadystatechange=function() {
		if (xmlReq.readyState == 4) {
			if(xmlReq.status == 200) {
				if (xmlReqFunction != "") {
					eval(xmlReqFunction + "(\"" + xmlReq.responseText.replace(/\"/g, "\\\"") + "\");");  //eval is used because function name is a variable; clean up output
				}
			} else {
				/*alert("Could not load the XML document. (" + xmlReq.status + ")");*/
			}
		}
		
	}
	
	xmlReq.open("GET",url,true);
	xmlReq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");  //this is new code..  always fetches new response in place of using cache (due to IE)
	xmlReq.send(null);

}

///////////////////////////////////////////////

var xmlReq2;
var xmlReqFunction2;

function GetXMLPOST(url, reqFunctionVar, parms) {  //url to open; function to call (send empty string if no function needed); parameters to post (remember to URI encode the parameter values before they are passed)
	xmlReqFunction2 = reqFunctionVar;

	try { xmlReq2=new XMLHttpRequest(); } //compliant browsers
	catch (e) {
		try { xmlReq2=new ActiveXObject("Msxml2.XMLHTTP"); } //IE
		catch (e) {
			try { xmlReq2=new ActiveXObject("Microsoft.XMLHTTP"); } //old IE
			catch (e) { /*alert("Error");*/ }
		}
	}
	
	xmlReq2.onreadystatechange=function() {
		if (xmlReq2.readyState == 4) {
			if(xmlReq2.status == 200) {
				if (xmlReqFunction2 != "") {
					eval(xmlReqFunction2 + "(\"" + xmlReq2.responseText.replace(/\"/g, "\\\"") + "\");");  //clean up output
				}
			} else {
				/*alert("Could not load the XML document. (" + xmlReq2.status + ")");*/
			}
		}
	}
	
	xmlReq2.open("POST",url,true);
	
	//Send the proper header information along with the request
	xmlReq2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlReq2.setRequestHeader("Content-length", parms.length);
	xmlReq2.setRequestHeader("Connection", "close");
	xmlReq2.send(parms);
	
}

/*/////////////////////////////////////////////

The functions below can be invoked on any javascript string like this…

alert(" Hello ".trim());

var message = "This is a longer sentence.";
alert(message.shorten(10));

////////////////////////////////////////////*/

// Returns the string with all the beginning and ending whitespace removed
String.prototype.trim = function() {
  return this.replace(/^\s+/, '').replace(/\s+$/, '');
};
// Returns the left x characters of the string
String.prototype.left = function(count) {
  if (this.length>count) {
    return this.substring(0, count);
  }
  else {
    return this;
  }
}
// Returns the right x characters of the string
String.prototype.right = function(count) {
  if (this.length>count) {
    return this.substring(this.length-count, this.length);
  }
  else {
    return this;
  }
}
// Returns true if the string begins with value
String.prototype.startsWith = function(value) {
  if (this.length<value.length) {
    return false;
  }
  else {
    return this.substring(0, value.length)===value;
  }
}
// Returns true if the string ends with value
String.prototype.endsWith = function(value) {
   if (this.length<value.length) {
    return false;
  }
  else {
    return this.substring(this.length-value.length, this.length)===value;
  }
}
// Returns a shortened version of the string suffixed with "..." if characters are truncated from the original string
String.prototype.shorten = function(maxLength) {
  if (!this) {
    result = null;
  }
  else if (this.length>maxLength) {
    preferredSize = maxLength-'...'.length;
    if (preferredSize>0) {
      result = this.left(preferredSize) + '...';
    }
    else {
      result = this.left(maxLength);
    }
  }
  else {
    result = this;
  }
  return result;
}