function clock(elName)
{
	// This script is taken from http://club.telepolis.com/jagar1/Buscaminas/Buscaminas.htm
	var secunds = 0;
	var timerID = null;
	var timerRunning = false;
	var Hora;
	var Timer = window.document.getElementById(elName);
	this.startChronometer = startChronometer;
	this.stopChronometer = stopChronometer;

	function runClock()
	{
		Timer.innerHTML=seconds();
		timerID = setTimeout(function() {runClock()},1050);	//setTimeout() se llama a si mismo.
		timerRunning = true;
	}
	
	function seconds()
	{
		secunds++;
		if(secunds < 10)
		secunds = "00" + secunds;
		else if(secunds < 100)
		secunds = "0" + secunds;
		if(secunds >= 1000)
			stopChronometer();
		else
			return secunds;
	}

	function _timeNow()	//Toma la hora y la formatea
	{ 
		var Segundos, seconds, minutes, hours, timeStr;
		var now = new Date();
		Segundos=parseInt((now-Hora)/1000);
		seconds = Segundos;//%60;
		//minutes = parseInt(Segundos/60)%60;
		//hours = parseInt(Segundos/3600)%60;
		//timeStr = (hours < 10) ? "0" + hours : hours;
		//timeStr += ((minutes < 10) ? ":0" : ":") + minutes;
		if(seconds < 10)
		seconds = "00" + seconds;
		else if(seconds < 100)
		seconds = "0" + seconds;
		if(seconds >= 1000)
			stopChronometer();
		else
			return seconds;
	}

	function startChronometer()
	{
		if (timerRunning)	// No se para el reloj, sigue por donde iba
			return;
		Hora=new Date();
		runClock();
	}

	function stopChronometer()
	{
		var tmp=seconds();
		if (timerRunning)
		{
			clearTimeout(timerID);
			Timer.innerHTML=tmp;
			timerRunning = false;
		}
	}
}
