function Ajax()
{
	this.toString = function() { return "Ajax"; }
	
	this.makeRequest = function(_method, _url)
	{
		this.request = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP");
		this.request.open(_method, _url, true);
		this.request.send(_url);
	}
	
	this.checkReadyState = function(_id, _1, _2, _3)
	{	
		switch (this.request.readyState)
		{
			case 1:
				if (_id != null) document.getElementById(_id).innerHTML = _1;
				break;
			case 2:
				if (_id != null) document.getElementById(_id).innerHTML = _2;
				break;
			case 3:
				if (_id != null) document.getElementById(_id).innerHTML = _3;
				break;
			case 4:
				return this.request.status;
		}
	}
}

var oAjax = new Ajax();
var limit = 0;

function ajaxRefresh()
{
  if (limit==1)
  {
    //make background request
    oAjax.makeRequest('GET', '/scripts/sessionrefresh.php');
    limit = iMinutes * 60 + iSeconds;
  }
  else
  {
    limit--;
  }
  setTimeout("ajaxRefresh()",1000)
}

function beginAjaxRefresh()
{
  limit = iMinutes * 60 + iSeconds;
  setTimeout("ajaxRefresh()",1000)
}

var iMinutes = 5;
var iSeconds = 0;
beginAjaxRefresh();
