//Función de Fecha y Hora
var months = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
var dayName = new Array ("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado");
var relojGlobal;
var intDiferencia;
var segundos;
var hora;
var minutos;
var campo;

function reloj(idcampo) {	
	var date = relojGlobal;
	intDiferencia = (relojGlobal - new Date())  / 1000;
	segundos = relojGlobal.getSeconds();
	hora = relojGlobal.getHours(); 
	minutos = relojGlobal.getMinutes();
	campo = idcampo;
	correrReloj()
}
function correrReloj(){
	var difMax = 60;
	var difSeg = (relojGlobal - new Date())  / 1000;
	segundos++;	

	if (segundos == 60) {
	  segundos = 0;
	  minutos++;
	  if (minutos == 60) {
		minutos = 0;
		hora++;
		if (hora == 24) {
		  hora = 0;
		}
	  }
	}

	var datePC =  new Date(relojGlobal);
	relojGlobal = new Date(datePC.getFullYear(),datePC.getMonth(),datePC.getDate(),hora,minutos,segundos);
	date = relojGlobal;
	var year = date.getFullYear();
	var month = date.getMonth();
	var day = date.getDate();
	var hour = date.getHours();
	var minute = date.getMinutes();
	var second = date.getSeconds();
	var monthname = months[month];

	if (hour >= 12) {
		var AM_PM = "PM";
	}
	else{
		var AM_PM = "AM";
	}
	if (minute < 10) {minute = "0" + minute}
	if (second < 10) {second = "0" + second}
	if (month < 10) {month = "0" + month}
	var dayString = dayName[date.getDay()];
	if (document.getElementById(campo) !=null){
		document.getElementById(campo).innerHTML = " " + dayString + " " + day + " de " + monthname + " de " + year + ", " +  hour + ":" + minute + ":" + second //+ " " + AM_PM + " "
	}
	setTimeout("correrReloj()", 1000);
}
//Fin Función de Fecha y Hora