var MaskPanel=function()
{
    this.divobj = null;
    this.container = null;
    
    this.show=function(containerDiv)
    {
      if(!document.getElementById("xdivmasking"))
      {
          var divEle=document.createElement('div');
          divEle.setAttribute("id","xdivmasking");
          document.body.appendChild(divEle);
          var divSty=document.getElementById("xdivmasking").style;
          divSty.position="absolute"; 
          divSty.top="0px"; 
          divSty.left="0px";
          divSty.zIndex="91"; 
          divSty.opacity=".50";
          divSty.backgroundColor="#000";
          divSty.filter="alpha(opacity=50)";

          var divFram=document.createElement('iframe');
          divFram.setAttribute("id","xmaskframe");
          document.body.appendChild(divFram);
          divSty=document.getElementById("xmaskframe").style;
          divSty.position="absolute"; 
          divSty.top="0px"; 
          divSty.left="0px"; 
          divSty.zIndex="90";
          divSty.border="none";
          divSty.filter="alpha(opacity=0)";
       }

       this.divobj=document.getElementById("xdivmasking");
       this.waitifrm=document.getElementById("xmaskframe");
       
       var dsh=document.documentElement.scrollHeight;
       var dch=document.documentElement.clientHeight;
       var dsw=document.documentElement.scrollWidth;
       var dcw=document.documentElement.clientWidth;
       
       var bdh=(dsh>dch)?dsh:dch;
       var bdw=(dsw>dcw)?dsw:dcw;

       this.waitifrm.style.height=this.divobj.style.height=bdh+'px';
       this.waitifrm.style.width=this.divobj.style.width=bdw+'px';  
       this.waitifrm.style.display=this.divobj.style.display="block";
       
       if(containerDiv != null)
       {
    	   this.container = containerDiv;
    	   this.container.style.display="block";
    	   this.container.style.top = (((document.documentElement.clientHeight/2) + document.documentElement.scrollTop) - (this.container.offsetHeight/2))+'px';
    	   this.container.style.left = (((document.documentElement.clientWidth/2) + document.documentElement.scrollLeft) - (this.container.offsetWidth/2))+'px';
       }	   
    };
    
    this.showDynamic = function(containerDiv, contentWidth)
    {
        var dsw = document.documentElement.scrollWidth;
        var dsh = document.documentElement.scrollHeight;
        var dcw = document.documentElement.clientWidth;
        var dch = document.documentElement.clientHeight;
        var dbw = document.body.clientWidth;
        var dbh = document.body.clientHeight;
        var wMargin = 0;
        if(dsw == dcw || contentWidth > dbw)
           wMargin = (dsw - contentWidth) / 2;
        else
           wMargin = (dbw - contentWidth) / 2;

        //var maskWidth = contentWidth + (wMargin * 2);
        /*alert("dsw: " + dsw);
        alert("dcw: " + dcw);
        alert("dbw: " + dbw);
        alert("maskWidth: " + maskWidth);*/
       if(!document.getElementById("xdivmasking"))
       {
           var divEle = document.createElement('div');
           divEle.setAttribute("id","xdivmasking");
           document.body.appendChild(divEle);
           var divSty = document.getElementById("xdivmasking").style;
           divSty.position = "absolute"; 
           divSty.top = "0px"; 
           divSty.left = "0px";
           divSty.zIndex = "91"; 
           divSty.opacity = ".50";
           divSty.backgroundColor = "#000";
           divSty.filter = "alpha(opacity=50)";

           var divFram = document.createElement('iframe');
           divFram.setAttribute("id","xmaskframe");
           document.body.appendChild(divFram);
           divSty = document.getElementById("xmaskframe").style;
           divSty.position = "absolute"; 
           divSty.top = "0px"; 
           divSty.left = "0px"; 
           divSty.zIndex = "90";
           divSty.border = "none";
           divSty.filter = "alpha(opacity=0)";
        }

        this.divobj = document.getElementById("xdivmasking");
        this.waitifrm = document.getElementById("xmaskframe");
        
        //var bdh = (dsh > dch) ?dsh : dch;
        //var bdw = (dsw > dcw) ? dsw : dcw;

        //this.waitifrm.style.width = this.divobj.style.width = (maskWidth > dbw ? dsw : dbw) + 'px';
        this.waitifrm.style.width = this.divobj.style.width = dsw + 'px';
        this.waitifrm.style.height = this.divobj.style.height = dsh + 'px';
        this.waitifrm.style.display = this.divobj.style.display = "block";
        
        if(containerDiv != null)
        {
           this.container = containerDiv;
           this.container.style.left = wMargin + "px";
           this.container.style.width = contentWidth + "px";
               
           this.container.style.top = "7%";
           this.container.style.display = "block";
        }
    };
    
    this.hide=function()
    {
        this.waitifrm.style.display=this.divobj.style.display="none";
        if(this.container != null)
        {
        	this.container.style.display="none";
        }
    };
    
    this.setContent = function(containerDiv)
    {
    	if(this.container == null ||containerDiv == null)
    		return;
    	
       this.container.style.display = "none";
       
  	   this.container = containerDiv;
 	   this.container.style.display="block";
 	   this.container.style.top = (((document.documentElement.clientHeight/2) + document.documentElement.scrollTop) - (this.container.offsetHeight/2))+'px';
 	   this.container.style.left = (((document.documentElement.clientWidth/2) + document.documentElement.scrollLeft) - (this.container.offsetWidth/2))+'px';
    }
}

