﻿    //#ffffff
    //onmousedown='PsInnerTitleBarDown(ps.LayerWindowImp)' onmousemove='PsInnerTitleBarMove(ps.LayerWindowImp)' onmouseup='PsInnerTitleBarUp(ps.LayerWindowImp)' 
    function PsLayerWindow()
    {
        
        document.write("<div id='PsLayerWindow_CoverageLayer' class='PsLayerWindow_coverageLayerDiv' style='display:none;height:100%'></div>");
        document.write("<div id='PsLayerWindow_WindowLayer' class='PsLayerWindow_windowLayerDiv' style='display:none;'>");
        document.write("<table border='0' cellpadding='0' cellspacing='0' style='border:#3465A4 4px solid'>");
        document.write("<tr><td class='PsLayerWindow_titleStyle'  >");
        document.write("<table border='0' cellpadding='0' cellspacing='2' style='width:100%;border:1px #cccccc solid'><tr><td width='20'><img src='../images/PsLayerWindow_icon.gif' width='18'/></td><td width='100%' id='PsLayerWindow_TitleBar' style='font-size: 9pt;font-weight: bold;color: dimgray;cursor: default;'></td><td align='right' width='20'><img src='../images/close.jpg' width='18' onclick='ps.LayerWindowImp.Close()' /></td></tr></table>");
        document.write("</td></tr>");
        document.write("<tr><td height='300' width='400'><iframe width='100%' height='100%' scrolling='no'></iframe></td></tr>");
        document.write("</table>");
        document.write("</div>");
        document.write("<style>");
        document.write(".PsLayerWindow_coverageLayerDiv{z-index: 51;left: 0px;position: absolute;top: 0px;background-color:#ffffff ;filter: alpha(opacity=5);opacity: 0.5;}");
        document.write(".PsLayerWindow_windowLayerDiv{border: #cccccc 1px solid;z-index: 51;position: absolute;}");
        document.write(".PsLayerWindow_titleStyle{filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#f4f4f4',endColorStr='#98B2E6',gradientType='1');cursor:default;}");
        document.write("</style");

        this.innerDraging = false;
        this.innerX = -1;
        this.innerY = -1;
        
        this.CoverageLayer = document.getElementById("PsLayerWindow_CoverageLayer");
        this.WindowLayer = document.getElementById("PsLayerWindow_WindowLayer");
        this.TitleBar = document.getElementById("PsLayerWindow_TitleBar");
        this.CloseAfterEvent = false;
        
        this.innerTable = this.WindowLayer.childNodes[0];
        this.innerTitleTD = this.innerTable.rows[0].cells[0];
        this.innerFrameTD = this.innerTable.rows[1].cells[0];
        
        this.IFrame = this.innerFrameTD.childNodes[0];
        
        this.Title = "";
        this.Url = "";
        this.Width = 400;
        this.Height = 300;
        this.Top = 0;
        this.Left = 0;
        this.IsShowTitle = false;
        this.Parameters = "";
        this.ReturnValue = "";
        this.Open = PsLayerWindowOpen;
        this.Close = PsLayerWindowClose;
    }

    function PsInnerTitleBarDown(layerWindowImp)
    {
        layerWindowImp.innerDraging = true;
        layerWindowImp.innerX = event.clientX;
        layerWindowImp.innerY = event.clientY;
        layerWindowImp.Top = layerWindowImp.WindowLayer.offsetTop;
        layerWindowImp.Left = layerWindowImp.WindowLayer.offsetLeft;
        document.onmousemove = function(){PsInnerTitleBarMove(ps.LayerWindowImp);}
    }
    function PsInnerTitleBarMove(layerWindowImp)
    {
        if(layerWindowImp.innerDraging)
        {
            layerWindowImp.WindowLayer.style.left=layerWindowImp.Left+event.clientX-layerWindowImp.innerX+"px";
            layerWindowImp.WindowLayer.style.top=layerWindowImp.Top+event.clientY-layerWindowImp.innerY+"px";
        }
    }
    function PsInnerTitleBarUp(layerWindowImp)
    {
        layerWindowImp.innerDraging = false;
    }
    
    function PsLayerWindowClose(returnValue)
    {
        this.ReturnValue = returnValue;
        this.CoverageLayer.style.display = "none";
        this.WindowLayer.style.display = "none";
        this.IFrame.src = "";
        if (this.CloseAfterEvent)
            this.CloseAfterEvent();
            
    }
    
    function PsLayerWindowOpen(title, url, args, isShowTitle, width, height, closeAfterEvent)
    {
        
        this.Title = title;
        this.Url = url;
        this.IsShowTitle = isShowTitle;
        this.Width = width;
        this.Height = height;
        this.Parameters = args;
        this.CloseAfterEvent = closeAfterEvent;
        
        this.TitleBar.innerHTML = this.Title;
        
        if (isShowTitle)
        {
            this.WindowLayer.style.borderWidth = 1;
            this.innerTitleTD.style.display = "";
        }
        else
        {
            this.WindowLayer.style.borderWidth = 0;
            this.innerTitleTD.style.display = "none";
        }
        
        var a1 = document.body.clientWidth;
        var a2 = Number(document.body.leftMargin);
        var a3 = Number(document.body.rightMargin);
        var a4 = (window.screen.height -window.screenTop)+20;
        var a5 = Number(document.body.topMargin)-120; 
        var a6 = Number(document.body.bottomMargin);
        
        this.CoverageLayer.style.top = 0;
        this.CoverageLayer.style.left = 0;
        this.CoverageLayer.style.width= (a1+ a2 + a3)-20;
        this.CoverageLayer.style.height = a4 + a5 + a6;
        
        this.Top = 20;
        this.Left = (a1+ a2 + a3) / 2 - this.Width / 2;
        if (this.Left < 0)
            this.Left = 0;
        
        this.WindowLayer.style.top = this.Top;
        this.WindowLayer.style.left = this.Left;
        
        this.innerFrameTD.style.width = this.Width;
        this.innerFrameTD.style.height = this.Height;
        
        this.CoverageLayer.style.display = "";
        this.WindowLayer.style.display = "";
        
        this.IFrame.src = this.Url;
    }
