// Copyright (C) 2001  SJS Solutions Ltd

var _dateObj;

// called in body onLoad. Installs an interval timer that runs
// update_date_and_time().
function install_date_and_time_updater(current_time)
{
    _dateObj = new Date(current_time);
    update_html(_dateObj);
    setInterval(update_date_and_time, 100);
}

// when called it puts a date string in the tag with id `date' and
// the time in the tag with id `time'.
function update_date_and_time()
{
    var d = new Date(_dateObj.valueOf()+100);
    var updateHTML = _dateObj.getSeconds()!=d.getSeconds()?1:0;

    _dateObj = d;

    if (updateHTML) {
        update_html(d);
    }
}

function update_html(d)
{
    if (document.getElementById) {
        document.getElementById("date").innerHTML = format_verbose_date(d);
        document.getElementById("time").innerHTML = format_time(d);
    } else if (document.all) {
        document.all("date").innerText = format_verbose_date(d);
        document.all("time").innerText = format_time(d);
    }
}
