function isMSIE()
{
	return (navigator.appName == "Microsoft Internet Explorer");
}

function addEventObject(o, evento, callbackFunction, bubble)
{
	if(isMSIE())
	{
		o.attachEvent(evento, callbackFunction);
	}
	else
	{
		if(evento.indexOf('on')==0)
		{
			evento = evento.substr(2);
		}
		o.addEventListener(evento, callbackFunction, bubble);
	}
}

function Marcadores()
{
	this.getObject = function(id)
	{
		var o = null;
		if(isMSIE())
		{
			o = document.getElementById(id);
		}
		else
		{
			var ieo = document.getElementById(id);
			if(ieo)
			{
				var embo = ieo.getElementsByTagName('embed');
				if(embo.length) o=embo[0];
			}
		}
		return o;
	}

	this.callFunction = function(idMarcador, functionName, arrParams)
	{
		var strArguments = functionName;
		if(typeof(arrParams)!='undefined')
		{
			for(var i=0; i< arrParams.length; ++i)
			{
				strArguments += '<param>' + arrParams[i];
			}
		}
		var marcador = this.getObject(idMarcador);
		if(marcador);
		marcador.SetVariable('objSocket.call', strArguments);
	}

	this.setData = function(idMarcador, data)
	{
		this.callFunction(idMarcador, 'setData', new Array(data));
		Marcadores_AutoProcess();
	}

	this.setServerTime = function(idMarcador, hora)
	{
		this.callFunction(idMarcador, 'setServerTime', new Array(hora));
	}

	this.refresh = function(idMarcador)
	{
		remote_marcadorSetData(idMarcador);
	}

	this.init = function(){ if(m_pos==0) Marcadores_AutoProcess(); }

	this.initServerTime = function(idMarcador)
	{
		remote_marcadorSetServerTime(idMarcador);
	}

	this.getObject = function(id)
	{
		var o = null;
		if(isMSIE())
		{
			o = document.getElementById(id);
		}
		else
		{
			var ieo = document.getElementById(id);
			if(ieo)
			{
				var embo = ieo.getElementsByTagName('embed');
				if(embo.length) o=embo[0];
			}
		}
		return o;
	}

	this.autoProcess = function()
	{
		if(m_pos < m_arrMarcadores.length)
		{
			var id = m_arrMarcadores[m_pos];
			m_pos++;
			if(this.getObject(id)!=null)
			{
				this.initServerTime(id);
				setTimeout('Marcadores_AutoProcess();', 2500);
			}
			else { Marcadores_AutoProcess(); }
		}
	}

	this.showAll = function()
	{
		var o = null;
		for(var i=0; i<m_arrMarcadores.length; i++)
		{
			o = document.getElementById(m_arrMarcadores[i]);
			if(o!=null && o.style.display!='block') { o.style.display = 'block'; }
		}
	}

	var m_pos = 0;
	var m_arrMarcadores = new Array('rugby','futbol','tenis','basquet');
}

var marcadores = new Marcadores();
function Marcadores_AutoProcess()
{
	setTimeout('marcadores.autoProcess();', 750);
}

function call_remote_7minutosSetData(){
  selectedTitular = ( parseInt(selectedTitular)+1 < arrayTitulares.length ) ? parseInt(selectedTitular)+1 : 0 ;
  remote_7minutosSetData(arrayTitulares[selectedTitular]);
}

function Marcadores_OnLoad()
{
  /*
  if( document.getElementById("obj_7minutos") ){
	  setInterval('call_remote_7minutosSetData()',10000);
	}
	*/
	marcadores.showAll();
}

addEventObject(window, 'onload', Marcadores_OnLoad, true)
setTimeout('Marcadores_OnLoad()', 120000);
