﻿function keyPress(e) {
    if (e.keyCode == 13 || e.which == 13) {
        // get event source
        var targ;
        if (e.target) targ = e.target;
        else if (e.srcElement) targ = e.srcElement;
        if (targ.nodeType == 3) // defeat Safari bug
            targ = targ.parentNode;

        // if source is a button, allow enter
        if (targ && targ.type && targ.type == "submit") return true;

        // else try to find a button with attribute "EnterPress" == True and click it
        var numInputs = document.getElementsByTagName("input").length;
        for (var i = 0; i < numInputs; i++) {
            if (document.getElementsByTagName("input")[i].getAttribute("EnterPress") == "True") {
                document.getElementsByTagName("input")[i].focus();
                document.getElementsByTagName("input")[i].click();
            }
        }

        // no button with "EnterPress" == True found, cancel the enter event
        return false;
    }
}

function StartClock() {
    UpdateClock();
    window.setInterval('UpdateClock()', 1000);
}

function UpdateClock() {
    driveon.templateClock.update();
}

if (typeof (driveon) == 'undefined') driveon = {};

driveon.templateClock =
{
    update: function() {
        var thistime = new Date();
        var hours = thistime.getHours();
        var minutes = thistime.getMinutes();
        var seconds = thistime.getSeconds();
        if (eval(hours) < 10) { hours = "0" + hours };
        if (eval(minutes) < 10) { minutes = "0" + minutes };
        if (seconds < 10) { seconds = "0" + seconds };
        thistime = hours + ":" + minutes + ":" + seconds;

        document.getElementById("Clock").innerHTML = thistime;

    }
}

