/* 'Popup (mit Fallback) 240307' (c) cybaer@binon.net - http://Coding.binon.net/Popup */
/* Lizenz CC <http://creativecommons.org/licenses/by-nc-sa/2.5/> */
/* Aufruf: popup(URL/A-Objekt[,Breite[,Hoehe[,X-Pos[,Y-Pos]]]][,Fensterparameter]); */
/* Rueckgabe: Fensterobjekt oder false bei Nichtgelingen */
/* Beispiel: <a target="_blank" href="http://example.org" onclick="return !popup(this,300,300,false);">300*300-Popup (ohne Zusatzelemente)</a> */
function popup(src,w,h,x,y) {
var options="", popupURL, popupName, popupWin, aboutBlank=(window.opera)?"":"about:blank";
if(typeof(x)=="number") options+=",left="+x;
if(typeof(y)=="number") options+=",top="+y;
if(typeof(w)=="number") options+=",width="+w;
if(typeof(h)=="number") options+=",height="+h;
lastParam=popup.arguments[popup.arguments.length-1];
if(typeof(lastParam)=="string") {
options+=","+lastParam;
} else {
if(typeof(lastParam)=="boolean" && lastParam) {
options+=",menubar=no"
} else if(typeof(lastParam)!="boolean" || (typeof(lastParam)!="boolean" && !lastParam)) {
options+=",menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes";
}
}
if(options) { options=options.substring(1); }
if(typeof(src)=="object") {
popupURL=(src.href)?src.href:aboutBlank;
popupName=(src.target)?src.target:"_blank";
} else if(typeof(src)=="string") {
popupURL=(src)?src:aboutBlank;
popupName="_blank";
} else {
popupURL=aboutBlank;
popupName="_blank";
}
popupWin=window.open(popupURL,popupName,options);
if(popupWin && !popupWin.closed) {
if(popupWin.focus) { popupWin.focus(); }
} else {
popupWin=null;
}
return popupWin;
}