var spawn;

function popup(file, name, gx, gy, px, py, options) {
        if (name==null) {
                if (this.name=='opener') {
                        name = 'microsite';
                        gx = 625;        // breite
                        gy = 600;        // hoehe
                        var x=0, y=0, xm=0, ym=0, woff=0, hoff=0;
                        if (window.screenX)    x = window.screenX;
                        if (window.screenLeft) x = window.screenLeft;
                        if (window.screenY)    y = window.screenY;
                        // if (window.screenTop))  y = window.screenTop-20;
                        if (window.screenTop)  y = window.screenTop;



        // url-leiste, tabbars etc. rausrechnen
                        woff = hoff = 0;
                        if (window.outerWidth) {
                                woff = window.outerWidth  - window.innerWidth;
                                hoff = window.outerHeight - window.innerHeight;
                        }

                        x = x + woff + 240;                // x-offset
                        y = y + hoff + 0;                // y-offset


                        xm = screen.width;
                        ym = screen.height;

                        if (x > xm-gx) x = xm-gx;
                        if (y > ym-gy) y = ym-gx;

                        options = 'scrollbars=yes,resizable=yes';
                        px = x;
                        py = y;


                } else {
                        return true;
                }
        }
        spawn = window.open(file, name, 'width=' + gx + ',height=' + gy + ',left=' + px + ',top=' + py + ((options != '') ? ',' + options : ''));
        if (!spawn) {
                if (document.getElementById('seiteninhalt')) {
                        merk = document.getElementById('seiteninhalt').innerHTML;
                        document.getElementById('seiteninhalt').innerHTML =
                                '<h1>Popup-Blocker erkannt</h1><div class="text"><p>Sie haben einen Popup-Blocker installiert. Dieser muss deaktiviert werden, um alle Funktionen dieser Website zu nutzen.<br><br>Bitte klicken Sie <a href="#" onclick="document.getElementById(\'seiteninhalt\').innerHTML=merk; popup(\''+file+'\',\''+name+'\',\''+gx+'\',\''+gy+'\',\''+px+'\',\''+py+'\',\''+options+'\'); return false;">hier</a>, um das gew&uuml;nschte Popup manuell zu &ouml;ffnen.</p><div>';
                }
        } else {
                spawn.resizeTo(gx, gy);
                spawn.moveTo(px, py);
                spawn.focus();
                return false;
        }
}
var merk = '';

function popupModal(pfad, name, gx, gy, px, py, options) {
        if (document.all && !navigator.userAgent.match(/opera/i)) {
                var ausgabe = showModalDialog(pfad, '' ,'resizable:no; scroll:no; center:no; dialogWidth:'+gx+'px; dialogHeight:'+gy+'px; dialogTop:'+py+'px; dialogLeft:'+px+'px; status:no;');
        } else {
                spawn = window.open(pfad, name, 'alwaysRaised=yes,dependent=yes, width=' + gx + ',height=' + gy + ',left=' + px + ',top=' + py + ((options != '') ? ',' + options : ''));
                // spawn.resizeTo(gx, gy);
                spawn.moveTo(px, py);
                spawn.focus();
        }
        return;
}

function confirmModal(pfad, name, gx, gy, px, py, options) {
        if (document.all && !navigator.userAgent.match(/opera/i)) {
                var ausgabe = showModalDialog(pfad, '' ,'resizable:no; scroll:no; center:no; dialogWidth:'+gx+'px; dialogHeight:'+gy+'px; dialogTop:'+py+'px; dialogLeft:'+px+'px; status:no;');
                if (ausgabe) {
                        if (ausgabe=='ja') jaclick();
                        else neinclick();
                }
        } else {
                spawn = window.open(pfad, name, 'alwaysRaised=yes,dependent=yes, width=' + gx + ',height=' + gy + ',left=' + px + ',top=' + py + ((options != '') ? ',' + options : ''));
                spawn.resizeTo(gx, gy);
                spawn.moveTo(px, py);
                spawn.focus();
        }
        return;
}

//<a href="http://www.dlrg.de" onclick="return callUrl('http://www.dlrg.de','true');">DLRG</a>
function callUrl(url, closepopup) {
        if (opener != null){
                opener.top.location = url;
                if (closepopup == 'true') window.close();
                return false;
        } else {
                return true;
        }
}
