﻿//the id of the element that will be modified
function StartTimer(id)
{   
    ShowTime(id);      
    setInterval( "ShowTime(\'" + id + "\')" , 30000);
}

function StopTimer()
{
    clearInterval();
}

function ShowTime(id)
{     
    var thisdate = new Date();      
    var temp = 'Today: ' + thisdate.getDate() + '/&nbsp;'+getMonthAbrev(thisdate.getMonth()) + '/&nbsp;' + thisdate.getFullYear();
    temp += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    temp += AddZeroBefore(thisdate.getHours()) + "&nbsp;:&nbsp;" + AddZeroBefore(thisdate.getMinutes());      
       
    document.getElementById(id).innerHTML=temp;
}

function getMonthAbrev(index)
{
    switch(index)
    {
        case 0 : return "January";
        case 1:  return "February";
        case 2 : return "March";
        case 3: return "April";
        case 4 : return "May";
        case 5: return "June";
        case 6 : return "July";
        case 7: return "August";
        case 8: return "September";
        case 9 : return "October";
        case 10: return "November";
        case 11 : return "December";
        default : return "";        
    }
}
function AddZeroBefore(quantity)
{
    if(quantity.toString().length == 1 ) return '0' + quantity;
    else return quantity;
}

