var timerID = null;
var timerRunning = true;
var Titulo;
var Estado;

function stopTimer() {        //Para el reloj       
	if(timerRunning) {                
		clearTimeout(timerID);
		timerRunning = false;
	}
} 

function startTimer()
	{     // Para el reloj, si esta activo y lo arranca.    
	stopTimer();
	runClock();
	}

function runClock()
	{        
	var Hora=timeNow();		// Solo para evitar hacer varias llamadas
	var Dia=fechahoy();
	// Mostrar la hora en los elementos que se desee
	window.document.getElementById("Data").innerHTML= Dia;
	window.document.getElementById("Hora").innerHTML= Hora;

//mostrar reloj en el title
	//window.document.title=Dia + " " + Hora;
	//top.document.title=Dia + " " + Hora;		 //Por si hay frames
	timerID = setTimeout("runClock()",1000);	//setTimeout() se llama a si mismo.
	timerRunning = true;
	}

function timeNow() 
	{        //Toma la hora y la formatea        
	now = new Date();
	hours = now.getHours();
	minutes = now.getMinutes();
	seconds = now.getSeconds();
	timeStr = ((hours < 10) ? "0" : "") + hours;
	timeStr += ((minutes < 10) ? ":0" : ":") + minutes;
	timeStr += ((seconds < 10) ? ":0" : ":") + seconds;
	return timeStr;
	}

function fechahoy()
	{
	var ahora;
	var fecha = new Date();
	var mes = fecha.getMonth();	
	var num = fecha.getDate();
	var ano=fecha.getFullYear();
	ahora = num + "-" + mes+1 + "-" + ano;
	return ahora;
	}
function Arranca()
	{
	window.document.getElementById("Data").style.display='';
	window.document.getElementById("Hora").style.display='';
	Estado=window.status;
	Titulo=top.document.title;
	startTimer();
	}
function Para()
	{
	stopTimer();
	window.document.getElementById("Data").style.display='none';
	window.document.getElementById("Hora").style.display='none';
	window.status=Estado;
	top.document.title=Titulo;
	}