
function hidetable()
{
	if (document.getElementById('tablemidleserv').style.display == '')
	{
		document.getElementById('tablemidleserv').style.display 	 = 'none';
		document.getElementById('tablemidle').style.display 		 = '';
		document.getElementById('tableheader').style.backgroundImage = 'url(themes/a2t_v4/images/header_server0.png)';
	}
	else
	{
		document.getElementById('tablemidleserv').style.display 	 = '';
		document.getElementById('tablemidle').style.display 		 = 'none';
		document.getElementById('tableheader').style.backgroundImage = 'url(themes/a2t_v4/images/header_server1.png)';
	}
}

var debutmoniteur = new Date();
var time_debut    = debutmoniteur.getTime();
var listeSrc = new Array("moniAjax.php?ip=91.121.114.23:41011",
						 "moniAjax.php?ip=91.121.114.23:41010",
						 "moniAjax.php?ip=91.121.114.23:21010",
						 //"moniAjax.php?ip=88.191.80.51:41010",
						 //"moniAjax.php?ip=88.191.80.51:41011",
						 "moniAjax.php?ip=91.121.114.23:21011");
var Gmonitor = 1;

function getMoniteur(src,id)
{
	if(navigator.appName == "Microsoft Internet Explorer")
		var http = new ActiveXObject("Microsoft.XMLHTTP");
	else
		var http = new XMLHttpRequest();
		
	http.abort();
	if (document.getElementById(id))
	{
		document.getElementById(id).style.background = 'url(themes/a2t_v4/images/monitor/ajax-loader.gif) center center no-repeat';
		document.getElementById(id).innerHTML = '';
	}
	http.open("GET", src, true);
	http.onreadystatechange=function() 
		{
			switch(http.readyState)
			{
				/*case 0:
				case 1:
				case 2:
				case 3:	document.getElementById(id).innerHTML = "Wait...."; break;*/
				case 4:
					if (http.responseText != 'erreur')
					{
							document.getElementById(id).innerHTML = http.responseText;
							document.getElementById(id).style.background = '';
					}
					break;
				default: break;
			}
		}
	http.send(null);
}

function move(i)
{
	var t = new Date();
	var time = t.getTime();
	
	if (time_debut > (time-2500)) return false;
	else time_debut = time;
	
	$('#monitorsb,#monitorsHeada').fadeOut(1);
	$('#monitorsa,#monitorsHeadb').fadeOut(1);
	$('#monitorsc,#monitorsHeadc').fadeOut(1);
	
	function ma(i,max)
	{
		if (i < 0)
			return max;
		else if(i > max)
			return 0;
		else return i;
	}


	
	var listeImg = new Array(" 9px 3px url(themes/a2t_v4/images/monitor/cod4_match.png) no-repeat",
							 " 9px 3px url(themes/a2t_v4/images/monitor/cod4_publicHC.png) no-repeat",
							 " 9px 3px url(themes/a2t_v4/images/monitor/cod2_public.png) no-repeat",
							 //" 9px 3px url(themes/a2t_v4/images/monitor/cod4_publicPro.png) no-repeat",
							 //" 9px 3px url(themes/a2t_v4/images/monitor/cod4_match2.png) no-repeat",
							 " 9px 3px url(themes/a2t_v4/images/monitor/cod2_match.png) no-repeat");
	                               
	var max = (listeSrc.length-1);
	var tmp = ma(Gmonitor,max);
	
	var a = (((tmp+i)<0)? max : (((tmp+i)>max)? 0 : (tmp+i)));
	tmp = ma(tmp+1,max);
	var b = (((tmp+i)<0)? max : (((tmp+i)>max)? 0 : (tmp+i)));
	tmp = ma(tmp+1,max);
	var c = (((tmp+i)<0)? max : (((tmp+i)>max)? 0 : (tmp+i)));

	
	
	if (i == 1)
	{
		document.getElementById('monitorsa').innerHTML = document.getElementById('monitorsb').innerHTML;
		document.getElementById('monitorsb').innerHTML = document.getElementById('monitorsc').innerHTML;
		getMoniteur(listeSrc[c],'monitorsc');
		$('#monitorsc,#monitorsHeadc').fadeIn(3000);
		$('#monitorsb,#monitorsHeadb').fadeIn(2000);
		$('#monitorsa,#monitorsHeada').fadeIn(1000);
	}
	else
	{
		document.getElementById('monitorsc').innerHTML = document.getElementById('monitorsb').innerHTML;
		document.getElementById('monitorsb').innerHTML = document.getElementById('monitorsa').innerHTML;
		getMoniteur(listeSrc[a],'monitorsa');
		$('#monitorsa,#monitorsHeada').fadeIn(3000);
		$('#monitorsb,#monitorsHeadb').fadeIn(2000);
		$('#monitorsc,#monitorsHeadc').fadeIn(1000);
	}

	document.getElementById('monitorsHeada').style.background = listeImg[a];
	document.getElementById('monitorsHeadb').style.background = listeImg[b];
	document.getElementById('monitorsHeadc').style.background = listeImg[c];

	Gmonitor = ma(Gmonitor+i,max);


}

//Init :)

function refreshMe(tabid,ip)
{
	var idparent = document.getElementById(tabid).parentNode.id;
	$('#'+idparent).fadeOut(1);
	getMoniteur("moniAjax.php?ip="+ip,idparent);
	$('#'+idparent).fadeIn(2000);
}

	window.onload = function()
	{
		getMoniteur("moniAjax.php?ip=91.121.114.23:41010",'monitorsa');
		setTimeout('getMoniteur("moniAjax.php?ip=91.121.114.23:21010","monitorsb")',2000);
		setTimeout('getMoniteur("moniAjax.php?ip=91.121.114.23:21011","monitorsc")',4000);
	};
	