// global variables to keep track of the request
// and the function to call when done
var ajaxreq=false, ajaxCallback;
// ajaxRequest: Sets up a request
function ajaxRequest(filename) {
  try {
	  // Firefox / IE 7/ Others
		ajaxreq = new XMLHttpRequest();
	} catch (error) {
	  try {
	    // IE 5 and 6
		  ajaxreq = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (error) {
	    return false;
	  }
  }
	ajaxreq.open("GET", filename, true);
	ajaxreq.onreadystatechange = ajaxResponse;
	ajaxreq.send(null);
}
// ajaxResponse: Waits for response and calls a function
function ajaxResponse() {
  if (ajaxreq.readyState !=4) return;
	if (ajaxreq.status==200) {
	  // If the request succeeded
		if (ajaxCallback) ajaxCallback();
	} else alert ("Request Failed: " + ajaxreq.statusText);
	return true;
}
function ajaxPostRequest(url,str) {
  try {
	  // Firefox / IE 7/ Others
		ajaxreq = new XMLHttpRequest();
	} catch (error) {
	  try {
	    // IE 5 and 6
		  ajaxreq = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (error) {
	    return false;
	  }
  }
	ajaxreq.open("POST", url, true);
	ajaxreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	ajaxreq.onreadystatechange = ajaxResponse;
  ajaxreq.send(str);
}
