///////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  © 2000-2001 Steven John Mapua
//  All Rights Reserved
//  smapua@comcast.com
//
///////////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function OpenWin(sURL,sName,x,y)
{

    var w = x; //510;
    var h = y; //460;
    var sb = 1;

    winId = window.open(sURL,sName,"width=" + w + ",height=" + h + ",menubar=0,location=0,toolbar=0,personalbar=0,status=1,scrollbars=" + sb + ",directories=0,resizable=1,copyhistory=0");// 'WIDTH=480, HEIGHT=450, CENTER, ');
    winId.focus();

    CenterWin(winId,w,h);

}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function CenterWin(oWin,x,y)
{

    var nRatio = 1;
    var sx = screen.width;
    var sy = screen.height;

    if((sx < x) && (sy < y))
    {
        // Move window to default position
        oWin.moveTo(0,0)
        return;
    }

    else if((sx > x) && (sy < y))
    {
        oWin.moveTo((sx - x) /2,0)
        return;
    }

    oWin.moveTo((sx - x) /2 ,((sy - y) /2) * .95);

}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function openWinEx(sImage,sHeight,sWidth,sCaption,sAddPath)
{
    var fred;
    try
    {
        if(winId)
            if(!winId.closed())
                winId.close();
    }
    catch(fred){}

    //var winId;
    var bIsIE       = new Boolean();
    var bAddPath    = new Boolean();
    var nWidth      = new Number(sWidth);
    var nHeight     = new Number(sHeight);
    var nAddHeight  = new Number();
    var nAddWidth   = new Number(40);
    var nRatio      = new Number();
    var nScrnWidth  = new Number(screen.width); //screen.width
    var nScrnHeight = new Number(screen.height); //screen.height
    var szTitle     = new String();

    nScrnHeight = nScrnHeight * .95;
    nScrnWidth  = nScrnWidth  * .95;


    bAddPath = false;
    try
    {
        if((sAddPath) && (sAddPath.length))
            bAddPath = true;
    }
    catch(fred){}

    nRatio = 1;

    if(navigator.appName == "Microsoft Internet Explorer")
    {
        bIsIE = true;
        nAddHeight += 40;
    }
    else
    {
        bIsIE = false;
        nAddHeight += 10;
    }

    if(nHeight > nWidth)
    {
        if(nScrnHeight <= nHeight)
        {
            nRatio = ((nScrnHeight - (nAddHeight + 20))/nHeight)
        }
    }
    else
    {
        if(nScrnWidth <= nWidth)
        {
            nRatio = ((nScrnWidth - (nAddWidth + 20))/nWidth)
        }
    }

    if(nRatio < 1)
    {
        nHeight = nHeight * nRatio;
        nWidth  = nWidth  * nRatio;
    }

    szTitle = " - " + sCaption;
    if(sCaption == "Enlarge")
        szTitle = "";


    nWidth += nAddWidth;
    nHeight += nAddHeight;


    winId = window.open("","newwin","width=" + nWidth + ",height=" + nHeight + ",menubar=0,resizable=1,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1");

    with(winId.document)
    {
        write('<HTML>\n');
        write('    <HEAD>\n');
        write('        <TITLE>Kuuloa Kai' + szTitle + '</TITLE>\n');
        write('\n');
        write('            <STYLE>\n');
        write('                INPUT.btn_Grey\n');
        if (bIsIE)
        {
            write('                {\n');
            write('                    BORDER-RIGHT: thin outset;\n');
            write('                    BORDER-TOP: thin outset;\n');
            write('                    FONT-WEIGHT: bold;\n');
            write('                    FONT-SIZE: 8pt;\n');
            write('                    BORDER-LEFT: thin outset;\n');
            write('                    CURSOR: hand;\n');
            write('                    COLOR: #ffffff;\n');
            write('                    BORDER-BOTTOM: thin outset;\n');
            write('                    FONT-FAMILY: Arial, Helvetica, san-serif;\n');
            write('                    HEIGHT: 16pt;\n');
            write('                    BACKGROUND-COLOR: #666666\n');
            write('                }\n');
            write('                .FourPt\n');
            write('                {\n');
            write('                    FONT-WEIGHT: normal;\n');
            write('                    FONT-SIZE: 4pt;\n');
            write('                    FONT-FAMILY: Arial, Helvetica, san-serif\n');
            write('                }\n');
        }
        else
        {
            write('                {\n');
            write('                    BORDER-RIGHT: thin outset;\n');
            write('                    BORDER-TOP: thin outset;\n');
            write('                    FONT-WEIGHT: bold;\n');
            write('                    FONT-SIZE: 12px;\n');
            write('                    FONT-WEIGHT: normal;\n');
            write('                    BORDER-LEFT: thin outset;\n');
            write('                    CURSOR: hand;\n');
            write('                    COLOR: #ffffff;\n');
            write('                    BORDER-BOTTOM: thin outset;\n');
            write('                    FONT-FAMILY: Arial, Helvetica, san-serif;\n');
            write('                    HEIGHT: 20px;\n');
            write('                    BACKGROUND-COLOR: #666666\n');
            write('                }\n');
            write('                .FourPt\n');
            write('                {\n');
            write('                    FONT-WEIGHT: normal;\n');
            write('                    FONT-SIZE: 8px;\n');
            write('                    FONT-FAMILY: Arial, Helvetica, san-serif\n');
            write('                }\n');
        }
        write('            </STYLE>\n');
        write('    </HEAD>\n');
        write('\n');
        if(bAddPath)
            write('    <BODY BACKGROUND="' + sAddPath + 'images/strips_bg.gif" RIGHTMARGIN=0 CLASS=FourPt\n');
        else
            write('    <BODY BACKGROUND="images/strips_bg.gif" RIGHTMARGIN=0 CLASS=FourPt\n');
        write('     MARGINWIDTH=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0 MARGINHEIGHT=0>\n');
        write('\n');
        write('    <DIV ALIGN=center>\n');
        write('        <FORM>\n');
        write('             <TABLE HEIGHT=' + (nHeight - nAddHeight) + ' WIDTH=' + (nWidth - nAddWidth) + ' BORDER=0 VALIGN=middle CLASS=FourPt>\n');
        write('                 <TR>\n');
        write('                     <TD ALIGN=center VALIGN=middle>\n');
        write('                        <IMG SRC="' + sImage + '" HEIGHT=' + (nHeight - nAddHeight) + ' WIDTH=' + (nWidth - nAddWidth) + ' BORDER=0><BR><BR>\n');
        write('                        <INPUT CLASS="btn_Grey" TYPE="button" VALUE="Close" NAME="btn_Close" onClick="window.close();">\n');
        write('                     </TD>\n');
        write('                 </TR>\n');
        write('            </TABLE>\n');
        write('        </FORM>\n');
        write('    </DIV>\n');
        write('\n');
        write('    </BODY>\n');
        write('</HTML>\n');

    }

    winId.focus();

    CenterWinEx(winId,nWidth,(nHeight + 50));

}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function CenterWinEx(oWin,x,y)
{

    var nRatio = 1;
    var sx = screen.width;
    var sy = screen.height;

    if((sx < x) && (sy < y))
    {
        // Move window to default position
        oWin.moveTo(0,0)
        return;
    }

    else if((sx > x) && (sy < y))
    {
        oWin.moveTo((sx - x) /2,0)
        return;
    }

    oWin.moveTo((sx - x) /2 ,((sy - y) /2) * .80);

}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/*
function openWinLocal(sImage,sCaption)
{
    var fred;
    try
    {
        if(winId)
            if(!winId.closed())
                winId.close();
    }
    catch(fred){}

    //var winId;
    var bIsIE       = new Boolean();
    //var bAddPath    = new Boolean();
    //var nWidth      = new Number(sWidth);
    //var nHeight     = new Number(sHeight);
    //var nAddHeight  = new Number();
    //var nAddWidth   = new Number(40);
    var nRatio      = new Number();
    var nScrnWidth  = new Number(screen.width);
    var nScrnHeight = new Number(screen.height);
    var szTitle     = new String();

    //alert("screen.width: " + nScrnWidth + "\nscreen.height: " + nScrnHeight)
    bAddPath = false;
    try
    {
        if((sAddPath) && (sAddPath.length))
            bAddPath = true;
    }
    catch(fred){}

    nRatio = 0;
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        bIsIE = true;
        nAddHeight += 40;
    }
    else
    {
        bIsIE = false;
        nAddHeight += 10;
    }
    if(nHeight > nWidth)
    {
        if(nScrnHeight <= nHeight)
        {
            nRatio = ((nScrnHeight - (nAddHeight + 20))/nHeight)
        }
    }
    else
    {
        if(nScrnWidth <= nWidth)
        {
            nRatio = ((nScrnWidth - (nAddWidth + 20))/nWidth)
        }
    }

    if(nRatio < 0)
    {
        nHeight = nHeight * nRatio;
        nWidth  = nWidth  * nRatio;
    }

    szTitle = " - " + sCaption;
    if(sCaption == "Enlarge")
        szTitle = "";


    nWidth += nAddWidth;
    nHeight += nAddHeight;


    winId = window.open("","newwin",",menubar=0,resizable=1,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1");

    with(winId.document)
    {
        write('<HTML>\n');
        write('    <HEAD>\n');
        write('        <TITLE>Kuuloa Kai' + szTitle + '</TITLE>\n');
        write('\n');
        write('            <STYLE>\n');
        write('                INPUT.btn_Grey\n');
        if (bIsIE)
        {
            write('                {\n');
            write('                    BORDER-RIGHT: thin outset;\n');
            write('                    BORDER-TOP: thin outset;\n');
            write('                    FONT-WEIGHT: bold;\n');
            write('                    FONT-SIZE: 8pt;\n');
            write('                    FONT-WEIGHT: normal;\n');
            write('                    BORDER-LEFT: thin outset;\n');
            write('                    CURSOR: hand;\n');
            write('                    COLOR: #ffffff;\n');
            write('                    BORDER-BOTTOM: thin outset;\n');
            write('                    FONT-FAMILY: Arial, Helvetica, san-serif;\n');
            write('                    HEIGHT: 16pt;\n');
            write('                    BACKGROUND-COLOR: #666666\n');
            write('                }\n');
            write('                .FourPt\n');
            write('                {\n');
            write('                    FONT-WEIGHT: normal;\n');
            write('                    FONT-SIZE: 4pt;\n');
            write('                    FONT-FAMILY: Arial, sans-serif, Helvetica\n');
            write('                }\n');
        }
        else
        {
            write('                {\n');
            write('                    BORDER-RIGHT: thin outset;\n');
            write('                    BORDER-TOP: thin outset;\n');
            write('                    FONT-WEIGHT: bold;\n');
            write('                    FONT-SIZE: 12px;\n');
            write('                    FONT-WEIGHT: normal;\n');
            write('                    BORDER-LEFT: thin outset;\n');
            write('                    CURSOR: hand;\n');
            write('                    COLOR: #ffffff;\n');
            write('                    BORDER-BOTTOM: thin outset;\n');
            write('                    FONT-FAMILY: Arial, Helvetica, san-serif;\n');
            write('                    HEIGHT: 20px;\n');
            write('                    BACKGROUND-COLOR: #666666\n');
            write('                }\n');
            write('                .FourPt\n');
            write('                {\n');
            write('                    FONT-WEIGHT: normal;\n');
            write('                    FONT-SIZE: 8px;\n');
            write('                    FONT-FAMILY: Arial, sans-serif, Helvetica\n');
            write('                }\n');
        }
        write('            </STYLE>\n');
        write('    </HEAD>\n');
        write('\n');
        write('    <BODY BACKGROUND="../images/strips_bg.gif" RIGHTMARGIN=0 CLASS=FourPt\n');
        write('     MARGINWIDTH=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0 MARGINHEIGHT=0>\n');
        write('\n');
        write('    <DIV ALIGN=center>\n');
        write('        <FORM>\n');
        write('             <TABLE NAME=MyTable ID=MyTable BORDER=0 VALIGN=middle CLASS=FourPt>\n');
        write('                 <TR>\n');
        write('                     <TD ALIGN=center VALIGN=middle>\n');
        write('                        <IMG SRC="' + sImage + '" BORDER=0><BR><BR>\n');
        write('                        <INPUT CLASS="btn_Grey" TYPE="button" VALUE="Close" NAME="btn_Close" onClick="window.close();">\n');
        write('                     </TD>\n');
        write('                 </TR>\n');
        write('            </TABLE>\n');
        write('        </FORM>\n');
        write('    </DIV>\n');
        write('\n');
        write('    </BODY>\n');
        write('</HTML>\n');

    }

    winId.focus();

    //CenterWinEx(winId,nWidth,(nHeight + 50));

    alert(winId.document.MyTable.height: + winId.document.MyTable.height + "\nwinId.document.MyTable.width: " + winId.document.MyTable.width);

}
*/
