﻿// JScript File
Timer.prototype.start = function() {
    var oThis = this;
    this.started = true;
    oThis.timerid = setTimeout(callback, oThis.interval);
    function callback() {
        if(oThis.started) {
            oThis.elapsed();

            if(oThis.continuous) {
                oThis.timerid = setTimeout(callback, oThis.interval);
            }
        }
    }
}

Timer.prototype.stop = function() {
    this.started = false;
    clearTimeout(this.timerid);
}

function Timer(continuous) {
    this.continuous = false;
    if(typeof continuous != "undefined")
        this.continuous = continuous;
    this.started = false;
    this.interval = 1000;
    this.elapsed = function() { alert(this + 'this function is not implemented yet')}; 
    this.timerid;   
}
