﻿function ScreenBox()
{
	this.Screen = null;
	this.Box = null;
	this.Active = false;
}

//IE FF
ScreenBox.prototype =
{
    Create:
        function (id, opacity, box, front)
        {        
        	var s, d, st;
        
			s = $C("DIV");            
            if (s == null) return false;
            
            d = GetPageSize();
            s["className"] = "ScreenBox";
            st = s["style"];
            s["id"] = id;
			st["width"] = d[0] + "px";
            st["height"] = d[1] + "px";
            st["top"] = 0 + "px";
            st["left"] = 0 + "px";
         	st["filter"] = "alpha(opacity=" + opacity + ")";
         	st["MozOpacity"] = opacity / 100;
         	
         	if (front == false) st["zIndex"] = 50;
         	//st["opacity"] = 5;
         	//filter:alpha(opacity=75);-moz-opacity:.75;opacity:.75;"
			
			this.Screen = s;
            
            if (box == true)
            {
    			s = $C("DIV");
	    		if (s == null) return false;
			
			    st = s["style"];
			    s["className"] = "ScreenBoxMsj";
			    s["id"] = id + "fixed98div";
			    //No deben de estar fijos!!!
			    st["width"] = 400 + "px";
                st["height"] = 200 + "px";
                st["top"] = 200 + "px";
                st["left"] = 220 + "px";			    

			    s["innerHTML"] = "<center><span id='winWaitMsj' class='WaitText'>ESPERE POR FAVOR...</span></center>" +
							    "<center><img alt='Espere por favor' src='../JFramework/images/32/works.gif' /></center>";            

                this.Box = s;
            }
            else this.Box =null;

            return true;
        },
    
    SetIndex:
        function (index)
        {
            this.Screen["style"]["zIndex"] = index;
        },
        
	Show:
		function ()
		{
		    var d;
		
			if (this.Screen == null || this.Active == true) return false;
			
			d = GetPageSize();
			
			this.Screen["style"]["width"] = d[0] + "px";
            this.Screen["style"]["height"] = d[1] + "px";
			
			$Add(this.Screen);
			this.Active = true;
			if (this.Box == null) return false;
			$Add(this.Box);			
		},

	Hide:
		function ()
		{
		    if (this.Screen == null || this.Active == false) return false;
		
			if (this.Screen == null) return false;
			$Rem(this.Screen);
			this.Active = false;
			if (this.Box == null) return false;
			$Rem(this.Box);						
		}
}

//IE FF
function GetPageSize() 
{
	        
	var xScroll, yScroll;
		
	if (window.innerHeight && window.scrollMaxY) 
	{	
		xScroll = window.innerWidth + window.scrollMaxX;
		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
		if(document.documentElement.clientWidth)
			windowWidth = document.documentElement.clientWidth; 
		else
			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 = xScroll;		
	else
		pageWidth = windowWidth;
	
	return [pageWidth,pageHeight];
}

