// ----------------------------------------------
// Author: (c) Andreas 'decoman' Fay
// ----------------------------------------------
// Version:    1.3.0
// ----------------------------------------------
// Functionindex
// ----------------------------------------------
// v0.1 - show
// v0.1 - start
// v0.1 - stop
// ----------------------------------------------


function clock(strElement, strType, intMilliseconds)
{
    // Attributes -------------------------------
    var blnActive                                =  true;
    var objClock                                 =  intMilliseconds ? new Date(intMilliseconds) : new Date();
    var strClockElement                          =  strElement;
    var strClockType                             =  strType;


    // ------------------------------------------
    // Method (privileged)
    // ------------------------------------------
    // Name:        show
    // Description:
    // Input:
    // Output:
    // ------------------------------------------
    // Version:     0.1
    // ------------------------------------------
    // ChangeLog
    // ------------------------------------------
    // v0.1 (21.01.2007)
    // ------------------------------------------
    this.show                                    =  function()
    {
        if (!blnActive)
            return false;
    
        var strReturn;
        objClock.setTime(objClock.getTime()+1000);

        switch (strClockType)
        {
            case "h:ii:ss":
                var minutes                      =  objClock.getMinutes()+"";
                minutes                          =  (minutes.length == 1) ? "0"+minutes : minutes;
                var seconds                      =  objClock.getSeconds()+"";
                seconds                          =  (seconds.length == 1) ? "0"+seconds : seconds;
                strReturn                        =  objClock.getHours() + ":" + minutes + ":" + seconds;
                break;

            case "full":
                strReturn                        =  objClock.toLocateString();
                break;
        }

        document.getElementById(strClockElement).innerHTML
                                                 =  strReturn;
    }


    // ------------------------------------------
    // Method (privileged)
    // ------------------------------------------
    // Name:        start
    // Description:
    // Input:
    // Output:
    // ------------------------------------------
    // Version:     0.1
    // ------------------------------------------
    // ChangeLog
    // ------------------------------------------
    // v0.1 (01.06.2007)
    // ------------------------------------------
    this.start                                   =  function()
    {
        blnActive                                =  true;
    }


    // ------------------------------------------
    // Method (privileged)
    // ------------------------------------------
    // Name:        stop
    // Description:
    // Input:
    // Output:
    // ------------------------------------------
    // Version:     0.1
    // ------------------------------------------
    // ChangeLog
    // ------------------------------------------
    // v0.1 (01.06.2007)
    // ------------------------------------------
    this.stop                                    =  function()
    {
        blnActive                                =  false;
    }
}