var req;
var v_doReload = false;

//===================================
//function used to do loading graphic
//===================================
function loadingImg(id) {

	//set loading graphic
	document.getElementById(id).innerHTML = "<div style=\"text-align: center; margin-top: 0px;\"><img src=\"/imoweb/amendments/_includes/images/ajax-loader.gif\" width=\"31\" height=\"31\" /><img src=\"/imoweb/amendments/_includes/images/ajax-load-text.jpg\" width=\"146\" height=\"31\" /></div>";

}
//===================================
//===================================


//============================
//function for performing AJAX
//============================
function clientSideInclude(id, url, doReload, doLoadImg) {

	if (doReload) { v_doReload = true; }		//set global variable
	if (doLoadImg) { loadingImg(id); }			//show loading images
		

	//var req = null;
	// For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
	req.onreadystatechange = csi_stateChanged;
    req.open('GET', url, true);
    req.send(null);
	//element.innerText = req.responseText;
	//element.innerHTML = req.responseText;
    //element.style.display = "";
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }

}
//============================
//============================


//=======================================
//function for determining and displaying
//the results of clientSideInclude
//=======================================
function csi_stateChanged() {

	//if AJAX state is 4 (fully loaded) then load information
	if (req.readyState == 4) {
		element.innerHTML = req.responseText;
		element.style.display = "";

		//if reload = true
		if (v_doReload) {
			window.location.href = window.location.pathname;
		}
	}
}
//=======================================
//=======================================