// Muestra la hora y la fecha, actualizandas cada segundo, en una caja de texto
// Gerard 23/05/09
//

//Mostrar la fecha
function muestraReloj()
{
  hoy=new Date();
  var mes='';
  var dia='';
  var result='';

  if(hoy.getMonth()==0){
   mes="ENE"
  }else if(hoy.getMonth()==1){
   mes="FEB"
  }else if(hoy.getMonth()==2){
   mes="MAR"
  }else if(hoy.getMonth()==3){
   mes="ABR"
  }else if(hoy.getMonth()==4){
   mes="MAY"
  }else if(hoy.getMonth()==5){
   mes="JUN"
  }else if(hoy.getMonth()==6){
   mes="JUL"
  }else if(hoy.getMonth()==7){
   mes="AGO"
  }else if(hoy.getMonth()==8){
   mes="SEP"
  }else if(hoy.getMonth()==9){
   mes="OCT"
  }else if(hoy.getMonth()==10){
   mes="NOV"
  }else{
   mes="DIC"
  }
  
  if(hoy.getDay()==0){
   dia="DOM"
  }else if(hoy.getDay()==1){
   dia="LUN"
  }else if(hoy.getDay()==2){
   dia="MAR"
  }else if(hoy.getDay()==3){
   dia="MIE"
  }else if(hoy.getDay()==4){
   dia="JUE"
  }else if(hoy.getDay()==5){
   dia="VIE"
  }else{
   dia="SAB"
  }

  result='Madrid, '+dosDigitos(hoy.getDate());
  result+=' '+mes+' '+hoy.getFullYear()+' | ';
  result+=dia+' '+dosDigitos(hoy.getHours())+':'+dosDigitos(hoy.getMinutes())+':'+dosDigitos(hoy.getSeconds());
  document.reloj.date.value=result;
  setTimeout("muestraReloj()",1000);
}

// Formato numérico a 2 dígitos fijos
function dosDigitos(valor)
{
	if (valor>9) {
		return valor;
	}
	else {
		return '0'+valor;
	}
}
