﻿var __ie6 = /msie 6/i.test(window.navigator.userAgent);

function OpenDialogHelper(){};

OpenDialogHelper.openNormalDlg = function(urlPath,dlgName,width,height,resizable)
{   
    var objNewWin;
    var top = (screen.availHeight / 2) - (height / 2);
    var left = (screen.availWidth / 2) - (width / 2);
    var resize = "0";
    
    if (width=="") width = "790";
    if (height=="") height = "480";
    if(resizable) resize = "1";

    var objNewWin = window.open(urlPath,dlgName,"fullscreen=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=" + resize + ",width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);

    objNewWin.focus();
    
    return objNewWin;
};

OpenDialogHelper.openNormalSDlg = function(urlPath,dlgName,width,height,resizable)
{   
    var objNewWin;
    var top = (screen.availHeight / 2) - (height / 2);
    var left = (screen.availWidth / 2) - (width / 2);
    var resize = "0";
    
    if (width=="") width = "790";
    if (height=="") height = "480";
    if(resizable) resize = "1";
    height=screen.availHeight-76;
    var objNewWin = window.open(urlPath,dlgName,"fullscreen=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=" + resize + ",width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);

    objNewWin.focus();
    
    return objNewWin;
};

OpenDialogHelper.openModalDlg = function(sPath, oArgs, iX, iY)
{
    //在实际部署使用时，应打开下面一行代码的注释。

    //
    //因为站点一般不会被用户设置为Local intranet，所以IE6模态窗口中会出现状态栏，

    //并且IE6的模态窗口高度指整个窗口的高度，而不是窗口中可用显示区域的高度。

    //因此状态栏会挡住窗口下部的界面，影响使用。

    //
    if(__ie6) iY += 20;
    
    //IE7中的dialogWidth和dialogHeight参数的值所指的宽和高，不包括窗口的标题栏和外边框。IE6包括。
    //可惜客户端界面风格无法通过脚本获得。在WinXP和WinClassic风格中，标题栏的高度是不同的。

    if(__ie6)
    {
        iX += 6;
        iY += 32;   //WinXP界面风格
        //iY += 25; //WinClassic界面风格
    }
    try
    {
        if(oArgs == null){
            oArgs = new Object();
        }
        
        oArgs.Width = iX;
        oArgs.Height = iY;
        
	    return window.showModalDialog(sPath, oArgs, "dialogWidth:" + iX + "px;dialogHeight:" + iY + "px;help:0;status:0;scroll:0;center:1");
	}
	catch(e)
	{
	}
};

OpenDialogHelper.openResizeModalDlg = function(sPath, oArgs, iX, iY)
{
    
    if (iX==null || iY==null) 
    {
        iX=screen.availWidth;
        iY=screen.availHeight;
    }
    if(__ie6) iY += 20;

    if(__ie6)
    {
        iX += 6;
        iY += 32;   //WinXP界面风格
        //iY += 25; //WinClassic界面风格
    }
    try
    {
	    return window.showModalDialog(sPath, oArgs, "dialogWidth:" + iX + "px;dialogHeight:" + iY + "px;help:0;status:1;scroll:0;center:1;resizable:1;help:1;Maximize=yes");
	}
	catch(e)
	{
	}
};


