var CSTTimer = new Class({

    interval: 1000,        // 1 sec by default
    containerId: null,    // container where time output
    timerHandler: null,
    container: null,

    initialize: function(){
        this.isStarted = false;
    },

    start: function(containerId) {
        this.containerId = containerId;

        if(this.containerId == null) { alert("Please set block ID to display results."); return false; }
        this.container = $(this.containerId);

        if(!this.isStarted) {
            this.isStarted = true;
            this.onTick();
        }
    },

    stop: function() {
        clearTimeout(this.timerHandler);
        this.isStarted = false;
    },

    onTick: function() {
        this.updateTimerValue(this.getCSTDateString(this.getCSTDate()));
        this.timerHandler = setTimeout( jQuery.proxy( this.onTick, this ), this.interval);
    },

    updateTimerValue: function(value) {
        if(this.container) this.container.html(value.toUpperCase());
    },

    getMonthLabel: function(monthIndex) {
        var months = new Array(13);
        months[0] = "January";
        months[1] = "February";
        months[2] = "March";
        months[3] = "April";
        months[4] = "May";
        months[5] = "June";
        months[6] = "July";
        months[7] = "August";
        months[8] = "September";
        months[9] = "October";
        months[10] = "November";
        months[11] = "December";

        return months[monthIndex];
    },

    addLeadingZero: function(dt) {
        if (dt.length < 2) return '0'+dt; else return dt;
    },

    getCSTDateString: function(cstDate) {
        return  this.addLeadingZero(cstDate.getHours()+'')+':'
        + this.addLeadingZero(cstDate.getMinutes()+'') + ' CST';
    },

    getCSTDate: function() {
        var localDate = new Date();
        var gmtTime = localDate.getTime() + localDate.getTimezoneOffset() * 60 * 1000;

        cstTime = gmtTime + (-5 * 60 * 60 * 1000);

        return new Date(cstTime);
    }

});

//this.addLeadingZero(cstDate.getDay()+'') + ' '
  //      +this.getMonthLabel(cstDate.getMonth()) + ' '
    //    + cstDate.getFullYear() + ' '
      //  +
