var timerID = null;          //Identidad del temporizador
var timerRunning = false;    //Flag para saber si el reloj esta activo

function stopTimer()
{        //Para el reloj       
if(timerRunning) 
	{                
	clearTimeout(timerID);
	timerRunning = false;
	}
} 

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 diasemana = new Array ('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo');
	var nombremes = new Array ('ENE', 'FEB', 'MAR', 'ABR', 'MAY', 'JUN', 'JUL', 'AGO', 'SEP', 'OCT', 'NOV', 'DIC');
	var ahora;
	var fecha = new Date();
	var mes = fecha.getMonth();	
	var dia = fecha.getDay();
	var num = fecha.getDate();
	var ano=fecha.getFullYear();
	ahora = num + "/" + nombremes[mes];
	return ahora;
	}

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("hora").innerHTML= Hora;
	window.document.getElementById("fecha").innerHTML= Dia;
	window.status=Dia + " " + Hora;
	//window.document.title=Dia + " " + Hora;	//Si no hay frames
	timerID = setTimeout("runClock()",1000);	//setTimeout() se llama a si mismo.
	timerRunning = true;
	}


function startTimer()
	{     // Para el reloj, si esta activo y lo arranca.    
	stopTimer();
	runClock();
	}

function enviamensaje() {
	var vnombre=document.getElementById('nombre').value;
	var vemail=document.getElementById('email').value;
	var vasunto=document.getElementById('asunto').value;
	var vdestino=document.getElementById('destino').value;
	var referencia = FCKeditorAPI.GetInstance("mensaje");
	var vmensaje = referencia.GetHTML();
	var error=5;
	if (vnombre=="") {
		alert("El campo -Nombre- es obligatorio");
		error=1;
	}
	if (vemail=="") {
		alert("El campo -Email- es obligatorio");
		error=1;
	}
	if (vasunto=="") {
		alert("El campo -Asunto- es obligatorio");
		error=1;
	}
	if (vmensaje=="") {
		alert("El campo -Mensaje- es obligatorio");
		error=1;
	}
	if (error==5) {
		document.contactoform.submit();
	}
}
function enviamensaje2() {
	var vnombre=document.getElementById('nombre').value;
	var vemail=document.getElementById('email').value;
	var vasunto=document.getElementById('asunto').value;
	var vdestino=document.getElementById('destino').value;
	var error=5;
	if (vnombre=="") {
		alert("El campo -Nombre- es obligatorio");
		error=1;
	}
	if (vemail=="") {
		alert("El campo -Email- es obligatorio");
		error=1;
	}
	if (vasunto=="") {
		alert("El campo -Asunto- es obligatorio");
		error=1;
	}
	if (error==5) {
		document.enviaform.submit();
	}
}
function confirmamensaje() {
	var mensaje=document.getElementById('respuesta').value;
	if (mensaje==1) {alert("Mensaje enviado correctamente");}
	if (mensaje==2) {alert("Ha ocurrido un problema y el mensaje no se ha podido enviar, por  favor inténtelo de nuevo");}
}
function imprimirPagina() { if (window.print) window.print(); else alert("Lo siento, pero a tu navegador no se le puede ordenar imprimir" + " desde la web. Actualizate o hazlo desde los menús"); }