function Reloj(){ 
hora = A.getHours() 
minuto = A.getMinutes() 
segundo = A.getSeconds() 

// Para visualizar la forma como se mira el tiempo
 if (segundo < 10) 
segundo = "0" + segundo; 

if (minuto < 10) 
minuto = "0" + minuto; 

if (hora < 10) 
hora = "0" + hora; 

if (hora < 12)
 {
 greeting="BUENOS DIAS!"
 timeText=greeting + " " + hora + ":" + minuto + ":" + segundo + " AM "
 }
 else if(hora == 12)
 {
 greeting="BUENAS TARDES!"
 timeText=greeting + " " + hora + ":" + minuto + ":" + segundo + " PM "
 }
 else if(hora < 18)
 {
 greeting="BUENAS TARDES!"
 timeText=greeting + " " + hora + ":" + minuto + ":" + segundo + " PM "
 }
 else
 {
 greeting="BUENAS NOCHES!"
 timeText=greeting + " " + hora + ":" + minuto + ":" + segundo + " PM "
 }
 
// horaImprimible = timeText + dateText
 horaImprimible = hora + ":" + minuto + ":" + segundo
 
document.form_reloj.reloj.value = horaImprimible 

setTimeout("Reloj()",1000) 

}

// ESTA ES LA FUNCION ACTIVA
function hora(){
 var fecha = new Date()
 var hora = fecha.getHours()
 var minuto = fecha.getMinutes()
 var segundo = fecha.getSeconds()
 A = new Date() 
 dateText = ""
 fecha =""
 
 // Tomar el dia actual y convertirlo al espanol
 dayValue = A.getDay()
 if (dayValue == 0)
 dateText += "Dom"
 else if (dayValue == 1)
 dateText += "Lun"
 else if (dayValue == 2)
 dateText += "Mar"
 else if (dayValue == 3)
 dateText += "Mie"
 else if (dayValue == 4)
 dateText += "Jue"
 else if (dayValue == 5)
 dateText += "Vie"
 else if (dayValue == 6)
 dateText += "Sab"
 
// tomar el mes actual y convertirlo a meses en espanol
 monthValue = A.getMonth()
 if (monthValue == 0)
 mes = "Ene"
 if (monthValue == 1)
 mes = "Feb"
 if (monthValue == 2)
 mes = "Mar"
 if (monthValue == 3)
 mes = "Abr"
 if (monthValue == 4)
 mes = "May"
 if (monthValue == 5)
 mes = "Jun"
 if (monthValue == 6)
 mes = "Jul"
 if (monthValue == 7)
 mes = "Ago"
 if (monthValue == 8)
 mes = "Sep"
 if (monthValue == 9)
 mes = "Oct"
 if (monthValue == 10)
 mes = "Nov"
 if (monthValue == 11)
 mes = "Dic"
 
// Para visualizar el ano, si es antes del 2000
 if (A.getYear() < 2000) 
fecha = A.getDate() + "-" + mes + "-" + (1900 + A.getYear())
 else 
fecha = A.getDate() + "-" + mes + "-" +(A.getYear())
 
 if(hora>=12 && hora<=23)
 m="p.m"
 else
 m="a.m"
 if (hora < 10) {hora = "0" + hora}
 if (minuto < 10) {minuto = "0" + minuto}
 if (segundo < 10) {segundo = "0" + segundo}
 
 var nowhora = dateText + ", " + fecha + " " + hora + ":" + minuto + ":" + segundo + " " + m
 document.getElementById('hora').firstChild.nodeValue = nowhora
 tiempo = setTimeout('hora()',1000)
 }

