DOMAssistant.DOMReady(function(){
	// JS-Name aller Popups.
	popupWindowName = 'dsPopup';

	// Popup BE-Tabellen Detailseite
	dsAddPopup('#content table.be tr td:first-child a, #content table.be tr th:first-child a', 530, 733);

	// Popup Adventskalender
	dsAddPopup('ul#adventskalender a', 700, 600);

	// Popup-Inhalt bei Bedarf verarbeiten
	managePopup();
});

// Macht Popup-Links aus allen Links, die mit selector gefunden werden.
function dsAddPopup(selector, width, height) {
	$(selector).addEvent('click', function(){
		window.open(this.href, popupWindowName, 'width='+width+',height='+height+',scrollbars,resizable').focus();
		return false;
	});
}

// Wenn es sich um ein Popup handelt, wird der Inhalt von windowctrl ausgetauscht und alle Breadcrumb-Links
// werden im Haupt-Fenster geöffnet.
function managePopup() {
	if(window.name == popupWindowName) {
		$('#windowctrl').replaceContent('<a href="#" onClick="window.close();return false;">Fenster schließen</a>');
	
		$('#bc a').addEvent('click', function(){
			window.opener.location = this.href;
			window.close();
			return false;
		});
	}
}
