clocks = new Array();

/**
 * Clock()
 *
 * @param   starttime       timestring formatted like 'April 21, 2010 06:18:19'
 * @param   html_id         clock html id
 * @param   displaytype     large or small
 **/
function Clock(starttime, html_id, displaytype) {
    this.currenttime    = new Date(starttime);
    this.html_id        = html_id;
    this.displaytype    = displaytype;
}

var month_array = new Array("Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December");
var day_array=["Zondag","Maandag","Dinsdag","Woensdag","Donderdag","Vrijdag","Zaterdag","Zondag"];

function padlength(what){
    var output=(what.toString().length==1)? "0"+what : what;
    return output;
}

function displaytime(){
    for(var i in clocks) {
        clocks[i].currenttime.setSeconds(clocks[i].currenttime.getSeconds()+1);
        var timestring = padlength(clocks[i].currenttime.getHours())+":"+padlength(clocks[i].currenttime.getMinutes());
        var datestring = day_array[clocks[i].currenttime.getDay()]+" "+padlength(clocks[i].currenttime.getDate())+" "+month_array[clocks[i].currenttime.getMonth()]+" "+clocks[i].currenttime.getFullYear();
        if(clocks[i].displaytype == 'large')
        {
            timestring = timestring+":"+padlength(clocks[i].currenttime.getSeconds());
            document.getElementById(clocks[i].html_id+'_day').innerHTML = datestring;
        }
        document.getElementById(clocks[i].html_id+'_time').innerHTML = timestring;
    }
}

/**
 * Window onload function for both objects
 */
window.onload=function(){
    if(clocks.length > 0)
        { setInterval("displaytime()", 1000); }
}
