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] = "Gennaio"
monthNames[2] = "Febbraio"
monthNames[3] = "Marzo"
monthNames[4] = "Aprile"
monthNames[5] = "Maggio"
monthNames[6] = "Giugno"
monthNames[7] = "Luglio"
monthNames[8] = "Agosto"
monthNames[9] = "Settembre"
monthNames[10] = "Ottobre"
monthNames[11] = "Novembre"
monthNames[12] = "Dicembre"
dayNames = new MakeArray(7)
dayNames[1] = "Domenica"
dayNames[2] = "Lunedì"
dayNames[3] = "Martedì"
dayNames[4] = "Mercoledì"
dayNames[5] = "Giovedì"
dayNames[6] = "Venerdì"
dayNames[7] = "Sabato"

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
}