/*
   Function to display date and time in a page
   by: Jose Luis Torres
*/

var dt_Date;
var dt_Month;
var dt_Day;

dt_Month = new Array();
dt_Day = new Array();

// Months' Array definition
dt_Month[ 0 ] = 'Enero';
dt_Month[ 1 ] = 'Febrero';
dt_Month[ 2 ] = 'Marzo';
dt_Month[ 3 ] = 'Abril';
dt_Month[ 4 ] = 'Mayo';
dt_Month[ 5 ] = 'Junio';
dt_Month[ 6 ] = 'Julio';
dt_Month[ 7 ] = 'Agosto';
dt_Month[ 8 ] = 'Septiembre';
dt_Month[ 9 ] = 'Octubre';
dt_Month[ 10 ] = 'Noviembre';
dt_Month[ 11 ] = 'Diciembre';

// WeekDays' Array definition
dt_Day[ 0 ] = 'Domingo';
dt_Day[ 1 ] = 'Lunes';
dt_Day[ 2 ] = 'Martes';
dt_Day[ 3 ] = 'Miercoles';
dt_Day[ 4 ] = 'Jueves';
dt_Day[ 5 ] = 'Viernes';
dt_Day[ 6 ] = 'Sabado';

// Return the actual date
function getTodayDate()
{
   dt_Date = new Date();
   return dt_Day[ dt_Date.getDay() ] + ' ' + 
          dt_Date.getDate() + ' de ' + 
          dt_Month[ dt_Date.getMonth() ] + ' de ' + 
          dt_Date.getFullYear();
}

// Return the actual time
function getNowTime()
{
   dt_Date = new Date();
   return dt_Date.getHours() + ':' + 
          ( dt_Date.getMinutes() < 10 ? '0' + dt_Date.getMinutes() : dt_Date.getMinutes() );
//           + ':' + 
//          ( dt_Date.getSeconds() < 10 ? '0' + dt_Date.getSeconds() : dt_Date.getSeconds() );
}

// Set the actual date as a value of a variable or field.
function setDateInField( str )
{
   eval( str + '=getTodayDate()' );
   setTimeout( 'setDateInField(\'' + str + '\')', 60000 )
}

// Set the actual time as a value of a variable or field.
function setTimeInField( str )
{
   eval( str + '=getNowTime()' );
   setTimeout( 'setTimeInField(\'' + str + '\')', 500 )
}

