var SubWin, iMaxDY;


SubWin  = 0;
iMaxDX  = screen.width;
iMaxDY  = screen.height - 80;


function GetSubWinWidth ( iDX )
{
    if ( iDX > iMaxDX )
    {
        iDX = iMaxDX;
    }

    return ( iDX );
}


function GetSubWinXPos ( iDX )
{
    return ( (iMaxDX - iDX) / 2 );
}


function GetSubWinHeight ( iDY )
{
    if ( iDY > iMaxDY )
    {
        iDY = iMaxDY;
    }

    return ( iDY );
}


function GetSubWinYPos ( iDY )
{
    return ( (iMaxDY - iDY) / 2 );
}


function OpenSubWin ( iInfoNum )
{
    var iDY, iY;
    

    CloseSubWin ( );

    switch ( iInfoNum )
    {
        case 1 :
            iDY = GetSubWinHeight   ( 1400 );
            iY  = GetSubWinYPos     ( iDY );
            
            SubWin = open ( "test.htm" , "subwin" , "left=60,top=" + iY + ",width=700,height=" + iDY + ",scrollbars=yes" );
            break;
            
        default :
            iInfoNum = 0;
            break;
    }
}


function CloseSubWin ( )
{
    if ( SubWin && !SubWin.closed )
    {
        if ( navigator.appName.indexOf ( "Internet Explorer" ) != -1 )
        {
            while ( !SubWin.closed )
            {
                SubWin.close ( );
            }
        }
        else
        {
            SubWin.close ( );
        }
        
        SubWin = 0;
    }
}


function OpenPopup ( )
{
    var heute, iD, iM, iY, iLastD, iLastM, iLastY;
    
    
    if ( SubWin && !SubWin.closed )
    {
        return;
    }
    
    iLastD  = 10;
    iLastM  = 4;
    iLastY  = 2009;
    
    heute   = new Date ( );
    iD      = heute.getDate ( );
    iM      = heute.getMonth ( ) + 1;
    iY      = heute.getFullYear ( );

    if ( (iY > iLastY) || (iM > iLastM) )
    {
        return;
    }
    
    if ( (iM == iLastM) && (iD > iLastD) )
    {
        return;
    }

    iDX = GetSubWinWidth    ( 650 );
    iX  = GetSubWinXPos     ( iDX );
    iDY = GetSubWinHeight   ( 750 );
    iY  = GetSubWinYPos     ( iDY );

    SubWin = open ( "popup.htm" , "subwin" , "left=" + iX + ",top=" + iY + ",width=" + iDX + ",height=" + iDY + ",scrollbars=yes" );
}
