var Oo =
{
	'tempoXHR': 60000,
	'tempoRefresh': 30000,
	'url': 'inc/cpt.php?LSSS='+lp+'&ISSS='+idp+'&LASSS='+lang+'&diode='+diode+'&game='+game+'&path='+path+'&chat='+chat+'&id='+idm+'&closenav='+closenav,

	connect: function(oElem, sEvType, fn, bCapture)
	{
		return document.addEventListener ?
			oElem.addEventListener(sEvType, fn, bCapture):
			oElem.attachEvent ?
				oElem.attachEvent('on' + sEvType, fn):
				false;
	},

	aTag: function(oEl, sTag)
	{
		return oEl.getElementsByTagName(sTag);
	},

	bXHRSupport: (typeof XMLHttpRequest != "undefined"),
	bActiveXSupport: (window.ActiveXObject),
	aMSXML: ["Microsoft.XMLHTTP",
		"MSXML2.XMLHTTP", "MSXML2.XMLHTTP.3.0",
		"MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.5.0",
		"MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.7.0"],

	createXHR: function()
	{
		if(Oo.bXHRSupport)
			return new XMLHttpRequest;
		else if(Oo.bActiveXSupport)
		{
			var iI;
			iI = Oo.aMSXML.length;

			do
			{
				try
				{
					return new ActiveXObject(Oo.aMSXML[--iI]);
				}
				catch(oError) { };
			}
			while(iI > 0);
			throw new Error("L'objet oXHR n'a pas été créé");
		}
	},

	getXHR: function(oReq)
	{
		var oXHR, oTimer;
		oXHR = Oo.createXHR();
		Oo.oReq = oReq;
		oXHR.open(Oo.oReq['method'], Oo.oReq['url'], true);
		oTimer = setTimeout(

			function()
			{
				if(oXHR)
					return oXHR.abort();
			},
			Oo['tempoXHR']
		);

		oXHR.onreadystatechange = function()
		{
			if(oXHR.readyState === 4)
				if(oXHR.status && /200|304/.test(oXHR.status))
				{
					clearTimeout(oTimer);
				Oo.oReq['response'] = oXHR.responseText;
				if(Oo.oReq['callback'])
					(Oo.oReq['callback'])();
				}
		}

		oXHR.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		if(Oo.oReq['method'] === 'post')
			oXHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

		return Oo.oReq['method'] === 'get' ?
			oXHR.send(null):
			oXHR.send(Oo.oReq['param']);
	},

	control: function(oEl)
	{
		return setInterval(
			function()
			{
				return Oo.getXHR(
					{
						'cible': oEl,
						'url': Oo['url'],
						'method': 'get',
						'callback': function()
						{
							return Oo.refresh(Oo.oReq['cible'], Oo.oReq['response']);
						}
					}
				);
			},
			Oo['tempoRefresh']
		);
	},

	refresh: function(oEl, sResponse)
	{
		return oEl.innerHTML = sResponse;
	},

	init: function()
	{
		var aDivs, iDiv;
		aDivs = Oo.aTag(document, 'div');
		iDiv = aDivs.length;
		do if(aDivs[--iDiv].className === 'cptonline')
			Oo.control(aDivs[iDiv]);
		while(iDiv > 0);
		return true;
	}
};

Oo.connect(window, 'load', Oo.init, false);
