VZT.appcore.events = new Class({
    Implements:[VZT.Base,Events],

    _oldsize: null,
    _timer_object : null,
    _tick: 0,
     /**
     * Notify the app core of a new event
     * @param event
     * @param args
     */
    Notify: function(event, args){
		this.fireEvent(event, args);
	},

    /**
     * Timer function
     */
    _timer: function(){
        this._tick = (this._tick + 1) % 100;
        this._checkresize();
        this.Notify("timer", this.tick);
    },

    /**
     * Checks to see if the browser has resized, a bit of a hack since some browsers dont support
     * on resize, and other ones, support it differently.
     */
    _checkresize: function(){
        if(this._oldsize === null)
        {
            this._oldsize = $(window).getSize();
        } else {
            var new_size = $(window).getSize();
            if(new_size.x !== this._oldsize.x || new_size.y !== this._oldsize.y)
            {
                this.Notify("window_resize", new_size);
            }
        }
    },

    initialize: function(){
        var self = this;

        var pevent = function(){
            self._timer();
        };
        this._timer_object = setInterval(pevent,  10);
        this._timer_object = setInterval(pevent,  10);
        $(document.body).addEvent("click", function(e){ self.Notify("click", e) });
        $(document.body).addEvent("mouseover", function(e){ self.Notify("mouseover", e) });
        $(document.body).addEvent("mouseout", function(e){ self.Notify("mouseout", e) });
    }
});
