﻿    //#ffffff
    //onmousedown='PsInnerTitleBarDown(ps.LayerWindowImp)' onmousemove='PsInnerTitleBarMove(ps.LayerWindowImp)' onmouseup='PsInnerTitleBarUp(ps.LayerWindowImp)' 
    function LayerWindow()
    {
        document.write("<div id='LayerWindow_CoverageLayer' class='LayerWindow_coverageLayerDiv' style='display:none;height:100%'></div>");
        document.write("<div id='LayerWindow_WindowLayer' class='LayerWindow_windowLayerDiv' style='display:none;'>");
        document.write("<table border='0' cellpadding='0' cellspacing='0' style='border:#FFECEC 4px solid'>");
        document.write("<tr><td class='LayerWindow_titleStyle'  >");
        document.write("<table border='0' cellpadding='0' cellspacing='2' style='width:100%;border:1px #cccccc solid'><tr><td width='20'><img src='images/FrontImages/WindowLogin.gif' width='18'/></td><td width='100%' id='LayerWindow_TitleBar' style='font-size: 9pt;font-weight: bold;color: dimgray;cursor: default;'></td><td align='right' width='20'><img src='Images/FrontImages/Close.gif' width='18' onclick='Ly.LayerWindowImp.Close(\"Clear\")' /></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(".LayerWindow_coverageLayerDiv{z-index: 51;left: 0px;position: absolute;top: 0px;background-color:#ffffff ;filter: alpha(opacity=5);opacity: 0.5;}");
        document.write(".LayerWindow_windowLayerDiv{border: #cccccc 1px solid;z-index: 51;position: absolute;}");
        document.write(".LayerWindow_titleStyle{filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#f4f4f4',endColorStr='#FFECEC',gradientType='1');cursor:default;}");
        document.write("</style");

        this.innerDraging = false;
        this.innerX = -1;
        this.innerY = -1;
        
        this.CoverageLayer = document.getElementById("LayerWindow_CoverageLayer");
        this.WindowLayer = document.getElementById("LayerWindow_WindowLayer");
        this.TitleBar = document.getElementById("LayerWindow_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 = LayerWindowOpen;
        this.Close = LayerWindowClose;
        this.RefreshParent = LayerWindowRefreshParent;
    }

    function InnerTitleBarDown(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(){InnerTitleBarMove(Ly.LayerWindowImp);}
    }
    function InnerTitleBarMove(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 InnerTitleBarUp(layerWindowImp)
    {
        layerWindowImp.innerDraging = false;
    }
    
    function LayerWindowClose(returnValue)
    {
        this.ReturnValue = returnValue;
        this.CoverageLayer.style.display = "none";
        this.WindowLayer.style.display = "none";
        this.IFrame.src = "";
        if (this.CloseAfterEvent)
            this.CloseAfterEvent();
            
    }
    
    function LayerWindowRefreshParent(returnValue)
    {
        this.ReturnValue = returnValue;
        if (this.CloseAfterEvent)
            this.CloseAfterEvent(); 
    }
    
    function LayerWindowOpen(title, url, args, isShowTitle, width, height, closeAfterEvent)
    {
        
                this.Title = "花行天下鲜花订购";
        if (title != "")
            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 = 80;
        this.Left = (a1+ a2 + a3) / 2 - this.Width / 2+5;
        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;
    }
