function getObjectByID(id) {
	// define local properties
	// alert (id);
	if (document.all) {
		return document.all[id];
	}
	if (document.layers) {
		return document.layers[id];
	}
	return document.getElementById(id);
}

function getHTTPObject ()
{
	obj = 0;
	try {
		obj = new XMLHttpRequest ();
	} catch (e) {
		try {
			obj = new ActiveXObject ("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				obj = new ActiveXObject ("Microsoft.XMLHTTP");
			} catch (e){
				return obj;
			}
		}
	}
	return obj;
}

var httpObject = getHTTPObject ();
var sbBusy = false;

function sendRequest (url, obj)
{
	try {		
		if (sbBusy) {
			//alert ("busy... abort()");
			httpObject.onreadystatechange = function () {};
			httpObject.abort();
		}
		httpObject.open ("GET", url, true);
		sbBusy = true;
		httpObject.onreadystatechange = this.update;
		httpObject.send (null);
	} catch (e) {
		//alert (e.message);
	}
}

function update ()
{
	if (httpObject.readyState != 4) {
		return;
	}
	
	sbBusy = false;
	
	if (httpObject.status != 200) // && httpObject.status != 0) 
	{
		return;
	} 
	try {
		if (httpObject.responseXML)
		{			
			var xmlData = httpObject.responseXML.documentElement;
			var items =  xmlData.getElementsByTagName("item");		
			var id, value, hint;
			for (i=0; i!=items.length; ++i) {								
				id = (items[i].getElementsByTagName("id")[0].firstChild.data);
				value = (items[i].getElementsByTagName("value")[0].firstChild.data);
				hint = (items[i].getElementsByTagName("hint")[0].firstChild.data);
				if (getObjectByID(id)) {
					getObjectByID(id).innerHTML = value;
				}
			}	
		}
	} catch (e) {
		//alert (e.message);
	}
}

function start()
{
	// initialize
	try {
		if (!httpObject) {
			alert ("httpObject==0"); return;		
		}
		window.setInterval("sendRequest('"+this.url+"')", this.pollTime);
	} catch (e) {
		//alert (e.message);
	}
}



function StatusBarUpdater ()
{
	this.sessionID = 0;
	this.url = "";
	this.pollTime = 10000;
	
	this.update = update;
	this.start = start; 	
	this.sendRequest = sendRequest;
}
