var DOM = (document.getElementById) ? true:false
var IE4 = (document.all && !DOM) ? true:false
var NS4 = (document.layers) ? true:false

function darId(id) {
   if (DOM) return document.getElementById(id);
   if (IE4) return document.all[id];
   if (NS4) return document.layers[id];
}

function Fecha(){
	this.f = new Date();
	this.semana = new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
	this.mes = new Array(
		"Enero","Febrero","Marzo",
		"Abril","Mayo","Junio",
		"Julio","Agosto","Septiembre",
		"Octubre","Noviembre","Diciembre"
	);
	this.dNombre = this.semana[this.f.getDay()];
	this.dNumero = this.f.getDate();
	this.mNombre = this.mes[this.f.getMonth()];
	this.aCompleto = this.f.getFullYear();
	this.hora = function(objName, spanId){
		fTemp = new Date();
		hours = ( fTemp.getHours() > 9 ) ? fTemp.getHours() : "0"+fTemp.getHours();
		minutes = ( fTemp.getMinutes() > 9 ) ? fTemp.getMinutes() : "0"+fTemp.getMinutes();
		seconds = ( fTemp.getSeconds() > 9 ) ? fTemp.getSeconds() : "0"+fTemp.getSeconds();
		darId(spanId).innerHTML = hours+":"+minutes+":"+seconds;
		setTimeout(objName+".hora('"+objName+"','"+spanId+"')",1000);
	}
	this.todaLaFecha = function(){
		return this.dNombre+" "+this.dNumero+", "+this.mNombre+" "+this.aCompleto;
	}
}

function inicializador(){
	miFecha = new Fecha();
	miFecha.hora("miFecha","reloj");
	darId("fecha").innerHTML = miFecha.todaLaFecha();
}