/**
	BEGIN Popup-Fenster
*/

var XpPopup = {
	myWindow: null,
	
	closeMyWindow: function () {
		if (this.myWindow && !this.myWindow.closed) this.myWindow.close();
	},

	/**
	 * Oeffnet ein Popup-Fenster
	 * @param object	object: Das Anker-Objekt. Wird mit "this" referenziert.
	 * @param int		w: Optionale Breitenangabe des Fensters (default: 150px)
	 * @param int		h: Optionale Hoehenangabe des Fensters (default: 150px)
	 * @param int		t: Optionale Angabe des Abstandes nach oben zum Bildschirmrand (default: Screen-Berechnung mit Quotient)
	 * @param int		l: Optionale Angabe des Abstandes nach links zum Bildschirmrand (default: Screen-Berechnung mit Quotient)
	 * @param int		q: Optionaler Quotient fuer die horizontale Position (default: 2)
	 * @param int		q2: Optionaler Quotient fuer die vertikale Position (default: 2)
	 * @return boolean	false, wenn Fenster existiert (Link wird nicht ausgefuehrt)
	 *
	 * Beispiele:
	 * <a href="http://google.de" onclick="return XpPopup.openWindow(this, 400, 200);" target="_blank">google</a>
	 * <a href="http://google.de" onclick="return XpPopup.openWindow(this, 400, 200, 10, 10);" target="_blank">google</a>
	 * <a href="http://google.de" onclick="return XpPopup.openWindow(this, 400, 200, 0, 0, 4, 4);" target="_blank">google</a>
	 */
	openWindow: function (obj, w, h, t, l, q, q2) {
		// URL
		var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
		if (!url) return true;
		
		// Groesse
		w = (w) ? w : 150;
		h = (h) ? h : 150;
		var args = 'width='+w+',height='+h+',resizable';
		
		// Position
		q = (q) ? q : 2;
		q2 = (q2) ? q2 : 2;
		t = (t) ? t : screen.height / q - h / q;
		l = (l) ? l : screen.width / q2 - w / q2;
		
		// altes schliessen
		this.closeMyWindow();
		
		// neues oeffnen
		this.myWindow = window.open(url,'',args);
		if (navigator.appVersion.indexOf("MSIE") == 0){
			this.myWindow.moveTo(l,t);
		}
		this.myWindow.focus();
		return (this.myWindow) ? false : true;
	}
}

window.onunload = function () {
	XpPopup.closeMyWindow();
}
window.onfocus = function () {
	XpPopup.closeMyWindow();
}

/**
	END Popup-Fenster
*/

