/**
 * Basic overlay class, any object which wants an overlay should inheret this
 */
VZT.Overlay = new Class({
    Implements:[VZT.Base,Events,Chain],
    overlay: null,

    initialize: function(){
        this._bind();
        //var IE6 = true;///false /*@cc_on || @_jscript_version < 5.7 @*/;
        //if(IE6) {
            
            
        //}

    },
    _get_screen_height: function(){
        var height  = Math.max(
             Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
             Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
             Math.max(document.body.clientHeight, document.documentElement.clientHeight)
        );
        return height;
    },
    /**
     * bind to appcore to listen for important events
     */
    _bind: function(){
       
        var self = this;
        VZT.AppCore.Events.addEvent("window_resize", function(e) {
            self.resizeOverlay();
        });
    },
    setupIE: function(){
        if(Browser.Engine.trident4) {
         var olf = document.createElement('iframe');
            olf.id = "modal_overlay_frame";

            this.overlay_iframe = olf;
            $('modal_overlay').appendChild(olf);
            olf.style.display = 'none';
        }
            
    },
    /**
     * unbind from appcore 
     */
    _unbind: function(){
        var self = this;
        VZT.AppCore.removeEvent("window_resize", function(e) {
            self.resizeOverlay();
        });
    },

    /**
     * shows the overlay
     */
    showOverlay: function(){

        var height = this._get_screen_height();
        if( this.overlay_iframe != null){
           
            this.overlay_iframe.style.top = 0+'px';
            this.overlay_iframe.style.display = 'block';
            this.overlay_iframe.style.height = height + 'px';
            this.overlay_iframe.style.position = "absolute";
            this.overlay_iframe.style.width = "100%";
        }

        this.overlay.setStyles({
               top: 0,
               display: 'block',
               height: height + "px",
               opacity: .7});
       // VZT.AppCore.Animations.revertAnimation("generic_fade", this.overlay, {start: .5});

        
        VZT.AppCore.setPageState('overlay');
    },

    /**
     * resizes the overlay
     */
    resizeOverlay: function(){
        if(VZT.AppCore.hasPageState('overlay'))
        {
           var height  = this._get_screen_height();
            this.overlay.setStyle('height', height);
        }
    },

    /**
     * hides the overlay
     */
    hideOverlay: function()  {
       var self = this;
        VZT.AppCore.removePageState('overlay');
        self.overlay.setStyle('display', 'none');

    }
});
