var timerID = null;
var timerRunning = false;

function stopclock (){
        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
}

function showtime () {

        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds()
        var timeValue = "" + ((hours >12) ? hours -12 :hours)
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        timeValue += ((seconds < 10) ? ":0" : ":") + seconds
        timeValue += (hours >= 12) ? " p.m." : " a.m."
        document.clock.face.value = timeValue;
        // you could replace the above with this
        // and have a clock on the status bar:
        // window.status = timeValue;
        timerID = setTimeout("showtime()",1000);
        timerRunning = true;

}

function startclock () {

        // Make sure the clock is stopped

        stopclock();

        showtime();

}

function MakeArray(n) {
	this.length = n
	return this
}
monthNames = new MakeArray(12)
monthNames[1] = "Enero"
monthNames[2] = "Febrero"
monthNames[3] = "Marzo"
monthNames[4] = "Abril"
monthNames[5] = "Mayo"
monthNames[6] = "Junio"
monthNames[7] = "Julio"
monthNames[8] = "Agosto"
monthNames[9] = "Septiembre"
monthNames[10] = "Octubre"
monthNames[11] = "Noviembre"
monthNames[12] = "Diciembre"
dayNames = new MakeArray(7)
dayNames[1] = "DOMINGO"
dayNames[2] = "LUNES"
dayNames[3] = "MARTES"
dayNames[4] = "MIÉRCOLES"
dayNames[5] = "JUEVES"
dayNames[6] = "VIERNES"
dayNames[7] = "SÁBADO"

function customDateString() {
	currentDate = new Date()
	var theDay = dayNames[currentDate.getDay() + 1]
	var theMonth = monthNames[currentDate.getMonth() + 1]
	msie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
	if (msie4) {
	    var theYear = currentDate.getYear()
	}
	else {
	     var theYear = currentDate.getYear() +1900
	}
	return theDay + ", " + currentDate.getDate() + " "  + theMonth + " "  + theYear
}