// JavaScript Document

function mueveReloj(){
	
A = new Date()
dateText = ""
dayMonth=""
monthValue=""
day= A.getDate()
hora = A.getHours()
minuto = A.getMinutes()
segundo = A.getSeconds()

// El código siguiente toma la fecha del sistema y convierte el nombre del día al español.

dayValue = A.getDay()
if (dayValue == 0)
dateText += "Domingo"
else if (dayValue == 1)
dateText += "Lunes"
else if (dayValue == 2)
dateText += "Martes"
else if (dayValue == 3)
dateText += "Miercoles"
else if (dayValue == 4)
dateText += "Jueves"
else if (dayValue == 5)
dateText += "Viernes"
else if (dayValue == 6)
dateText += "Sabado"

// A continuación hacemos lo mismo pero con el mes en curso.
monthValue = A.getMonth()
dateText += " "
if (monthValue == 0)
dayMonth += "Enero"
if (monthValue == 1)
dayMonth += "Febrero"
if (monthValue == 2)
dayMonth += "Marzo"
if (monthValue == 3)
dayMonth += "Abril"
if (monthValue == 4)
dayMonth += "Mayo"
if (monthValue == 5)
dayMonth += "Junio"
if (monthValue == 6)
dayMonth += "Julio"
if (monthValue == 7)
dayMonth += "Agosto"
if (monthValue == 8)
dayMonth += "Septiembre"
if (monthValue == 9)
dayMonth += "Octubre"
if (monthValue == 10)
dayMonth += "Noviembre"
if (monthValue == 11)
dayMonth += "Diciembre"

// Aunque es probable que nunca sea necesario, introducimos las modificaciones necesarias para poder visualiza años anteriores al 2000.
if (A.getYear() < 2000)
dateText += ", " + day + " de " +dayMonth+ " de " + (1900 + A.getYear())
else
dateText += ", " + day + " de " +dayMonth+ " de " + (A.getYear())


// Por último y a efectos de diseño formateamos el texto colocando un cero delante del dígito cuando sea necesario
if (segundo < 10)
segundo = "0" + segundo;

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

if (hora < 10)
hora="0" + hora;
timeText=dateText+", " + hora + ":" + minuto + ":" + segundo 
// Una vez hecho esto, formateamos el texto a mostrar como queramos.
 	  
   horaImprimible = timeText
   cambiaTexto(horaImprimible)
   setTimeout("mueveReloj()",1000)
}

function cambiaTexto(nuevaHora){
   xInnerHtml('capareloj',nuevaHora)
} 
