var _helpWindow = null;

function openHelp(url) {

    var form = document.forms[0];
    var isNewWindow = _helpWindow == null ? (form.elements['isHelpWindowOpen'].value != 'true') : _helpWindow.closed;

    var border = 5;
    var titleHeight = 23;
    var scrollbarWidth = 21;
    var width = 400;
    var height = 600;

    if (document.all && document.body.clientHeight > 0) { // IE
        height = document.body.clientHeight;
    }
    else if (document.all && self.outerHeight > 0) { // Opera 5
        height = self.outerHeight - 37;
    }

    // alert("width=" + width + ", height=" + height);

    _helpWindow = window.open(url, "_helpWindow", "width=" + width + ",height=" + height + ",locationbar=no,menubar=no,status=no,hotkeys=no,scrollbars=yes,resizable=yes");

    if (isNewWindow) {
        var x, y, screenX, screenY, outerWidth;

        if (document.all) {
            screenX = self.screenLeft - border;
            screenY = self.screenTop - border - titleHeight;
            outerWidth = document.body.clientWidth + 2 + 2*border + scrollbarWidth;
        }
        else {
            screenX = self.screenX;
            screenY = self.screenY;
            outerWidth = self.outerWidth;
        }

        x = screenX + outerWidth;
        y = screenY;

        if (x+width > screen.width)
            x = self.screenLeft - width - 3*border - 4;

        if (x > 0)
            _helpWindow.moveTo(x, y);

        // alert("New help window!");
    }
    else {
        _helpWindow.focus(); // TO DO: Gibt es raise ohne focus?
        // alert("Existing help window!");
    }
}


