
var timerID = null;
var timerRunning = false;

function startclock () 
   {
   stopclock();
   time();
   }

function stopclock ()
   {
   if(timerRunning) clearTimeout(timerID);
   timerRunning = false;
	}
function time ()
   {
   	var now = new Date();
   	var yr = now.getYear();
  	var mName = now.getMonth() + 1;
   	var dName = now.getDay() + 1;
	var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
	//var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."
	var hours = now.getHours();
	//hours = ((hours > 12) ? hours - 12 : hours);
	var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
	var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
   if(dName==1) Day = "Domenica";
   if(dName==2) Day = "Lunedì";
   if(dName==3) Day = "Martedì";
   if(dName==4) Day = "Mercoledì";
   if(dName==5) Day = "Giovedì";
   if(dName==6) Day = "Venerdì";
   if(dName==7) Day = "Sabato";
   if(mName==1) Month="Gennaio";
   if(mName==2) Month="Febbraio";
   if(mName==3) Month="Marzo";
   if(mName==4) Month="Aprile";
   if(mName==5) Month="Maggio";
   if(mName==6) Month="Giugno";
   if(mName==7) Month="Luglio";
   if(mName==8) Month="Agosto";
   if(mName==9) Month="Settembre";
   if(mName==10) Month="Ottobre";
   if(mName==11) Month="Novembre";
   if(mName==12) Month="Dicembre";
   var DayDateTime=(""
       + Day
       + ", "
       + dayNr
       + " "
       + Month
       + " "
       + yr);
       //+ " - "
       //+ hours
       //+ minutes
       //+ seconds
       

	document.time.orario.value=DayDateTime
   //window.status=DayDateTime;
   timerID = setTimeout("time()",1000);
   timerRunning = true;
   }

function clearStatus()

   {
   if(timerRunning)
      clearTimeout(timerID);
   timerRunning = false;
   //window.status=" ";
   }
