function WindowPopup( sUrl, iWidth, iHeight, sOptions, sName, iLeft, iTop )
{
    // Options=Defaultwerk
    // dependent        // close the parent, close the popup, omit if you want otherwise
    // resizable=no     // yes|no
    // menubar=no       // yes|no
    // toolbar=no       // yes|no
    // location=no      // yes|no
    // status=no        // yes|no
    // scrollbars=no    // yes|no
    // directories=no   // yes|no

	var iMaxWidth = screen.availWidth - 11;
	var iMaxHeight = screen.availHeight - 50;

    // Scrollbar einschalten, wenn Fenster zu groß.
    if ( iWidth > iMaxWidth || iHeight > iMaxHeight )
    {
        if ( !sOptions.indexOf( 'scrollbars' ) )
        {
            if ( sOptions )
                sOptions = sOptions + ',';
            sOptions = sOptions + 'scrollbars=yes';
        }

        if ( iWidth > iMaxWidth )
            iWidth = iMaxWidth;
        if ( iHeight > iMaxHeight )
            iHeight = iMaxHeight;
    }

    // Fenster zentrieren.
    if ( !iLeft )
    {
        iLeft = parseInt( ( iMaxWidth - iWidth ) / 2 );
        if ( iLeft < 0 )
            iLeft = 0;
    }
    if ( !iTop )
    {
        iTop = parseInt( ( iMaxHeight - iHeight ) / 2 );
        if ( iTop < 0 )
            iTop = 0;
    }

    oWindow = window.open( sUrl, sName, 'width=' + iWidth + ',height=' + iHeight + ",left=" + iLeft + ',top=' + iTop + ',' + sOptions );
    oWindow.focus();

    return( oWindow );
}

function WindowResize( oWindow, iWidth, iHeight, fCenter )
{
	var iMaxWidth = screen.availWidth;
	var iMaxHeight = screen.availHeight;

    if ( iWidth > iMaxWidth )
        iWidth = iMaxWidth;
    if ( iHeight > iMaxHeight )
        iHeight = iMaxHeight

    oWindow.resizeTo( iWidth, iHeight );

    if ( fCenter )
    {
        iLeft = parseInt( ( iMaxWidth - iWidth ) / 2 );
        iTop = parseInt( ( iMaxHeight - iHeight ) / 2 );
        WindowMove( oWindow, iLeft, iTop );
    }
}

function WindowMove( oWindow, iLeft, iTop )
{
    oWindow.moveTo( iLeft, iTop );
}
