<!--

/*  AJAX */

var Ajax = 
{
	init: function() {
		
	},
	status: 0, 
	error: '',
	showprogress: false,
	sendRequest: function (reqtype,url,parameters,object, runfunction) {
		if (Ajax.showprogress) {
			//Ajax.toggleProgressBar();
			object.innerHTML = '<div id="aj_progress_holder"><img id="aj_progress" src="../images/progress.gif"></div>';
		}
		
		var xmlhttp;
		xmlhttp=this.GetXmlHttpObject();
		
		if (xmlhttp==null) {
			Ajax.status = 1;
			Ajax.error = "Your browser does not support XMLHTTP";
			object.innerHTML = "Your browser does not support XMLHTTP";
			return;
		}
		
		if (reqtype=="GET") {
			url += '?'+parameters;
			parameters = null;
		} else {
			if (parameters=="") {
				parameters = null;
			}
		}
		
		xmlhttp.onreadystatechange = function()
		  {		
			if (xmlhttp.readyState == 4)
			{
			  if (xmlhttp.status == 200 || xmlhttp.status == 304)
			  {
				 object.innerHTML = xmlhttp.responseText;
				 eval(runfunction);
				 //setTimeout("Ajax.toggleProgressBar();", 500);
				 //Ajax.toggleProgressBar();
			  }
			  else
			  {
				object.innerHTML = "The server was unable to be contacted.";
				Ajax.status = 1;
				Ajax.error = "The server was unable to be contacted.";
			  }
			}
		  };
		  
		//xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.open(reqtype,url,true);
		xmlhttp.send(parameters);

	},
	GetXmlHttpObject: function () {
		if (window.XMLHttpRequest) {
			// code for IE7+, Firefox, Chrome, Opera, Safari
			return new XMLHttpRequest();
		}
		
		if (window.ActiveXObject) {
			// code for IE6, IE5
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
		return null;
	}, 
	toggleProgressBar: function () {
		jhCore.toggleBlanket('aj_blanket'); 
		jhCore.toggleProgressBar('aj_progress');
	}
};

Core.start(Ajax);
	

//-->
