//alert ('Loading commonAjax.js')
//
//  Please see and maintain Change Log at end of file
//


	//core AJAX scipt request. Called from functions in code.
	function loadXMLDoc(url, processFunct) {
		//set default processing funtion to basic universal processReqChange()
		processFunct = (processFunct)?processFunct:'alertResponse'
	  // branch for native XMLHttpRequest object
	  if (window.XMLHttpRequest) {
	      req = new XMLHttpRequest();
	          eval('req.onreadystatechange = '+processFunct);
	      req.open("GET", url, true);
	      req.send(null);
	  // branch for IE/Windows ActiveX version
	  } else if (window.ActiveXObject) {
	      req = new ActiveXObject("Microsoft.XMLHTTP");
	      if (req) {
	          eval('req.onreadystatechange = '+processFunct);
	          req.open("GET", url, true);
	          req.send();
	      }
	  }
	}

	//core basic processing for ajax request. Called from loadXMLDoc
	function processReqChange() {
		// only if req shows "complete"
	  if (req.readyState == 4) {
	  	// only if "OK"
	    if (req.status == 200) {
	    	// ...processing statements go here...
	      response  = req.responseXML.documentElement;
	      method = response.getElementsByTagName('method')[0].firstChild.data;
	      result = response.getElementsByTagName('result')[0].firstChild.data;
	      eval(method + '(result)');
	    } else {
	    	alert("There was a problem retrieving the XML data:\n" + req.statusText);
	    }
	  }
	}
	function postXMLDoc(url,postData,completedFunction)	{
		// branch for native XMLHttpRequest object
	  if (window.XMLHttpRequest) {
	      req = new XMLHttpRequest();
	      req.onreadystatechange = showSaving;
	      req.onreadystatechange = eval(completedFunction)
	      url = url + '?' + postData
	      req.open("GET", url, true);
	      req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	      req.send(null);
	  // branch for IE/Windows ActiveX version
	  } else if (window.ActiveXObject) {
	      req = new ActiveXObject("Microsoft.XMLHTTP");
	      if (req) {
	          req.onreadystatechange = showSaving;
	          req.onreadystatechange = eval(completedFunction);
	          url = url + '?' + postData
	          req.open("GET", url, true);
	          //req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	          req.send();
	      }
	  }

	}
	function showSaving(completedFunction)	{
		//make sure savingStatus is included
			if(req.readyState == 0)	window.status = 'Saving';
			if(req.readyState == 1) window.status = 'Saving.';
			if(req.readyState == 2) window.status = 'Saving..';
			if(req.readyState == 3) window.status = 'Saving...';
			if(req.readyState == 4) window.status = 'Finished';
			//if(req.readyState == 4) eval(completedFunction);
			if(req.readyState == 4) t = setTimeout("window.status=''",3000)
			
	}

	function alertResponse() {			// Displays returned text in javaScript alert()
		// only if req shows "complete"
	  if (req.readyState == 4) {
	  	// only if "OK"
	    if (req.status == 200) {
			alert (req.responseText)
			}
		}
	}

	function jScriptEval() {				// Executes returned text as javaScript code
		// only if req shows "complete"
	  if (req.readyState == 4) {
	  	// only if "OK"
	    if (req.status == 200) {
	    	eval(req.responseText)
			}
		}
	}


/*==================================================
Chane Log
26 April 2006 - Clifford Scarborough
	Added Change Log
	Added alertResponse function
	Cleaned up loadXMLDoc funcion
29 April 2006 - Clifford
	Changed default result processor to alertResponse()
5 May 2006 - Clifford
	Added a couple comments
====================================================*/