﻿
function PopupWindow(strDiv)
{
    this.Width = 400;
    this.Height = 300;
    this.ContentDiv = strDiv;
    this.ZIndex = 10;
    this.ShowShadow = true;
    
    this.SetShadow = function(bOn)
    {
        this.ResizeShadow();
        
        drop = document.getElementById("shadow");
        
        if( bOn )
        {
            drop.style.zIndex=this.ZIndex;
            drop.style.display='block';
            drop.style.backgroundColor = 'Gray';
        }
        else
        {
            drop.style.display='none';
        }
    }

    this.CenterObject = function()
    {
        panel=document.getElementById(this.ContentDiv);
        var size=GetScreenSize();
        
        if (self.innerHeight) // all except Explorer
        {
            panel.style.position='fixed';
        }
        else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
        {
            panel.style.position='absolute';
            document.body.style.overflow='hidden';
        }
        else if (document.body) // other Explorers
        {
            version = 0;
            
            if (navigator.appVersion.indexOf("MSIE")!=-1)
            {
                temp=navigator.appVersion.split("MSIE")
                version=parseFloat(temp[1])
                
                if (version<7)
                {
                    panel.style.position='absolute';
                    document.body.style.overflow='hidden';
                }
                else
                {
                    panel.style.position='absolute';
                }
            }
        }
    
        panel.style.display='block';
        panel.style.left = ((size.Width-this.Width)/2).toString() + 'px';
        panel.style.top = (((size.Height-this.Height)/2)).toString() + 'px';
        panel.style.width = this.Width.toString() + 'px';
        panel.style.height = this.Height.toString() + 'px';
        panel.style.zIndex=this.ZIndex+1;
    }

    this.ShowPopup = function()
    {
        if( this.ShowShadow )
            this.SetShadow(true);

        this.CenterObject();
    }

    this.HidePopup = function()
    {
        panel=document.getElementById(this.ContentDiv);
        panel.style.display='none';
        
        if( this.ShowShadow )
            this.SetShadow(false);
    }
    
    this.ResizeShadow = function()
    {
        var drop = document.getElementById("shadow");
        
        if( drop ) 
        {
			var size = GetScreenSize();
            drop.style.left='0px';
            drop.style.top='0px';
            drop.style.width=size.Width.toString() + 'px';
            drop.style.height=size.Height.toString() + 'px';
        }
    }
}

// Make sure we have a drop shadow
if( !document.getElementById('shadow') )
{
	if (self.innerHeight) // all except Explorer
	{  
		document.write('<div id="shadow" style="position:fixed; display:none; filter:alpha(opacity=50); opacity:.5;"></div>');
	}
	else
	{
		version=0
		if (navigator.appVersion.indexOf("MSIE")!=-1)
		{
			temp=navigator.appVersion.split("MSIE")
			version=parseFloat(temp[1])
		}

		if (version<7)	// Explorer 6  
		{
			document.write('<div id="shadow" style="position:absolute; display:none; filter:alpha(opacity=50); opacity:.5;"></div>');
		}
		else
		{
			document.write('<div id="shadow" style="position:absolute; display:none; filter:alpha(opacity=50); opacity:.5;"></div>');
		}
	}
}
