
var secs
var timerID = null
var timerRunning = false
var delay = 1000




var doispontos = ":";

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 1
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
        timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    { 
        StopTheClock() ;
        d = new Date();
        
        
        curr_date = d.getDate();
        thisDay=d.getDay();
        curr_month = d.getMonth();
        curr_year = d.getFullYear();
              
        minutos =  '0';
        if (doispontos == ":") { doispontos = "."; } else { doispontos = ":"; }
        if (String(d.getMinutes()).length == 1) {
          minutos = '0'+d.getMinutes();
        } else {
          minutos = d.getMinutes();
        }
        
        document.getElementById('current_date').innerHTML =myDays[thisDay]+", "+curr_date +" "+ m_names[curr_month] + " " + curr_year+" | "+d.getHours()+doispontos+minutos;
        InitializeTimer();
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

InitializeTimer();
//-->


