function openWin(sURL, sWinName, iWinType, iX, iY){

    var x = screen.width;
    var y = screen.height;
    x = (x / 2)-(iX /2);
    y = (y / 2)-(iY /2);
    
    if(window.opener == '[object]')
    {
        var oWinOpener = window.opener;
        var PopupPositionX = x + 30;
        var PopupPositionY = y + 70;
        
        /*
        for(i=0;i=1;i++)
        {
            oWinOpener = oWinOpener.window.opener;
            if(oWinOpener=='[object]')
            {
                PopupPositionX += 30;
                PopupPositionY += 20;
            }
            else
            {
                break;
            }
        }
        */
        
        x = PopupPositionX;
        y = PopupPositionY;
    }
    
	switch (iWinType) {
		case 1: {
			window.open (sURL, sWinName, "toolbar=0, menubar=0, location=0, status=1, width=" + iX + ", height=" + iY + ", scrollbars=yes, resizable=1");
			break;
		}
		case 2: {
			window.open (sURL, sWinName, "toolbar=0, menubar=1, location=0, status=1, width=" + iX + ", height=" + iY + ", scrollbars=yes, resizable=yes, left=0, top=0");
			break;
		}
		case 3: {
			if (arguments.length > 4)
				return window.open (sURL, sWinName, "toolbar=0, menubar=0, location=0, status=1, width=" + iX + ", height=" + iY + ", scrollbars=yes, resizable=0, left=" + arguments[5] + ", top=" + arguments[6], "true");
			else
				return window.open (sURL, sWinName, "toolbar=0, menubar=0, location=0, status=1, width=" + iX + ", height=" + iY + ", scrollbars=yes, resizable=no", "true");
			break;
		}
		case 4: {
			return window.open (sURL, sWinName, "toolbar=0, menubar=0, location=0, status=1, width=" + iX + ", height=" + iY + ", scrollbars=yes, resizable=yes, left="+x+", top="+y+"");
			break;
		}
		case 5: {
			return window.open (sURL, sWinName, "toolbar=0, menubar=1, location=0, status=1, width=" + iX + ", height=" + iY + ", scrollbars=yes, resizable=yes, left=0, top=0");
			break;
		}
		case 6: {
			window.open (sURL, sWinName, "toolbar=0, menubar=1, location=0, status=1, width=" + iX + ", height=" + iY + ", scrollbars=yes, resizable=1, left=20, top=20");
			break;
		}
	}
}

function modelessDlg(sURL, iDialogType, iX, iY){
	switch (iDialogType) {
		case 1: {
			return showModelessDialog(sURL, window, "status:0;center:1;help:0;resizable:1;dialogWidth: " + iX + "px;dialogHeight:" + iY + "px;");
		}
	}
}

function modalDlg(sURL, sArgument, iDialogType, iX, iY){
	switch (iDialogType) {
		case 1: {
			return showModalDialog(sURL, sArgument, "scroll:yes;status:no;center:1;help:0;resizable:0;dialogWidth: " + iX + "px;dialogHeight:" + iY + "px;");
		}
		case 2: {
			return showModalDialog(sURL, sArgument, "scroll:yes;status:0;center:1;help:0;resizable:1;dialogWidth: " + iX + "px;dialogHeight:" + iY + "px;");
		}
	}
}

function openExcelWindow(sURL, sName, iX, iY)
{
	var oWindow = window.open ("about:blank", sName, "toolbar=1, menubar=1, location=0, status=0, width=" + iX + ", height=" + iY + ", scrollbars=yes, resizable=yes, left=0, top=0");
	oWindow.location = sURL;
	return oWindow;
}

function openReportWindow(sURL, sName, iX, iY)
{
	var oWindow = window.open ("about:blank", sName, "toolbar=1, menubar=1, location=0, status=0, width=" + iX + ", height=" + iY + ", scrollbars=yes, resizable=yes, left=0, top=0");
	oWindow.location = sURL;
	return oWindow;
}

function defaultWindow(sURL, sName, iX, iY)
{
	window.open(sURL, sName, "location=0, resizable=1, toolbar=0, top=0, left=0, height=" + iY + ", width=" + iX)
}

function mdlDlg(sURL, sArgument, iDialogType, iX, iY){
	switch (iDialogType) {
		case 1: {
			return showModalDialog(sURL, sArgument, "scroll:yes;status:no;center:1;help:0;resizable:0;dialogWidth: " + iX + "px;dialogHeight:" + iY + "px;");
		}
		case 2: {
			return showModalDialog(sURL, sArgument, "scroll:yes;status:0;center:1;help:0;resizable:1;dialogWidth: " + iX + "px;dialogHeight:" + iY + "px;");
		}
	}
}
