var _MBOX ={

    sourceWidth     : "400",
    sourceHeight    : "300",
    sourceStyle     : "default",
    duration        : "0.3",
    lightSize       : "0.5",

    centerBOX : function(_divID, useViewSize)
    {
        var divElement  = document.getElementById(_divID);
        var bodySize    = this.getPageSize();
        var divSize     = $(divElement).getDimensions();
        
        if (useViewSize!=true)
            var divPOS_X    = (parseInt(bodySize[0]) - parseInt(divSize.width)) / 2;
        else
            var divPOS_X    = (parseInt(bodySize[2]) - parseInt(divSize.width)) / 2;
            
        
        document.getElementById(_divID).style.left  = divPOS_X + "px";
        document.getElementById(_divID).style.top   = this.currentScrollPos() + 100 + "px";
    },
    
    currentScrollPos : function()
    {
        var scrollPos = window.pageYOffset;
        if (scrollPos == undefined)
            scrollPos = document.body.scrollTop;
        return scrollPos;
    },
    
    
    setSource : function(_source)
    {
        $('MBOX_sourceLayer').style.width    = this.sourceWidth;
        $('MBOX_sourceLayer').style.height   = this.sourceHeight;  
        $('MBOX_sourceLayer').className      = this.sourceStyle;

        //$('MBOX_iframe').src = _source;
        var _i_ = "<iframe ID='MBOX_iframe' src='" + _source + "'"
                + " name='MBOX_ifram'"
                + " width='100%'"
                + " height='100%'"
                + " align='center'"
                + " scrolling='no'"
                + " marginheight='0'"
                + " marginwidth='0'"
                + "frameborder='0'>"
            + " NO FRAME "
        + "</iframe>";
        
        $('MBOX_sourceLayer').innerHTML = _i_;
            
        
    },
     
    showLightBG : function()
    {
        var _size = this.getPageSize();
    
        document.getElementById('MBOX_lightBG').style.width  = _size[0];
        document.getElementById('MBOX_lightBG').style.height = _size[1];

        $('MBOX_sourceLayer').show();
        
        Effect.Appear('MBOX_lightBG',{
                                    to:this.lightSize,
                                    duration:this.duration,
                                    afterFinish:function(){
                                                            //Effect.Appear('MBOX_sourceLayer',{duration:0.3});
                                                           }
                                });
    },
    
    hideLightBG : function()
    {
        Effect.Fade('MBOX_sourceLayer',{
                                    duration:this.duration,
                                    afterFinish:function(){
                                                            Effect.Fade('MBOX_lightBG',{duration:0.3});
                                                           }
                                });                    
        
    },
    
    //
    // getPageSize()
    // Returns array with page width, height and window width, height
    // Core code from - quirksmode.org
    // Edit for Firefox by pHaez
    //
    getPageSize : function()
    {
    	var xScroll, yScroll;
    	
    	if (window.innerHeight && window.scrollMaxY) {	
    		xScroll = document.body.scrollWidth;
    		yScroll = window.innerHeight + window.scrollMaxY;
    	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    		xScroll = document.body.scrollWidth;
    		yScroll = document.body.scrollHeight;
    	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    		xScroll = document.body.offsetWidth;
    		yScroll = document.body.offsetHeight;
    	}
    	
    	var windowWidth, windowHeight;
    	if (self.innerHeight) {	// all except Explorer
    		windowWidth = self.innerWidth;
    		windowHeight = self.innerHeight;
    	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    		windowWidth = document.documentElement.clientWidth;
    		windowHeight = document.documentElement.clientHeight;
    	} else if (document.body) { // other Explorers
    		windowWidth = document.body.clientWidth;
    		windowHeight = document.body.clientHeight;
    	}	
    	
    	// for small pages with total height less then height of the viewport
    	if(yScroll < windowHeight){
    		pageHeight = windowHeight;
    	} else { 
    		pageHeight = yScroll;
    	}
    
    	// for small pages with total width less then width of the viewport
    	if(xScroll < windowWidth){	
    		pageWidth = windowWidth;
    	} else {
    		pageWidth = xScroll;
    	}
    	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
    	return arrayPageSize;
    },

    
    
    initMBOX : function(_source, _width, _height, _style)
    {
        (_width)  ? this.sourceWidth = _width : "";
        (_height) ? this.sourceHeight = _height : "";
        (_style)  ? this.sourceStyle = _style : "";
    
    
        //(!_type) ? _type = "ifram" : "";
        this.setSource(_source);
        this.centerBOX('MBOX_sourceLayer', true);
        this.showLightBG();
    },

  
    //------------------------
    EOF : "END OF FILE"  
};
