if(window.location.href.indexOf("/print.php") < 0) {
	window.onload = loader;
} else {
	window.onload = function() {
		self.focus();
		autoPrint();
	};
}

function loader() {
	/*if(typeof sIFR == "function") {
		sIFR.replaceElement("#content-title h2", named({sFlashSrc: "media/ui/flash/univers-65.swf", sColor: "#336699", sBgColor: "#FFFFFF"}));
		sIFR.replaceElement("#content h2", named({sFlashSrc: "media/ui/flash/univers-65.swf", sColor: "#336699", sBgColor: "#FFFFFF"}));
		sIFR.replaceElement(".box h2", named({sFlashSrc: "media/ui/flash/univers-65.swf", sColor: "#FFFFFF", sBgColor: "#336699"}));
	}*/
	assignPopUps("popUpImg", 500, 500, "no");
	assignPopUps("printPage", 600, 595, "yes");
	resizeImagePopUp("popUpZoomImage");
	fixHomeSideBarHeight();
}

function assignPopUps(cl, w, h, scrl, tTip) {
	var n, nN, i, nC;
	if(document.getElementById) {
		n = document.getElementsByTagName("a");
		nN = n.length;
		if(nN > 0) {
			for(i = 0; i < nN; i++) {
				nC = n[i].getAttribute("class");
				if((nC == null) && (n[i].attributes["class"] != null)) {
					nC = n[i].attributes["class"].nodeValue;
				}
				if(nC == cl) {
					n[i].onclick = function() {
						return openPopUp(this.href, cl + "Win", w, h, scrl);
					}
				}
			}
		}
	}
}

function openPopUp(url, name, w, h, scrl) {
	var lP = (screen.width - w) / 2;
	var tP = (screen.height - h) / 2;
	popUp = window.open(url, name, 'height=' + h + ',width=' + w + ',locationbar=no,menubar=no,toolbar=no,scrollbars=' + scrl + ',resizable=no,top=' + tP + ',left=' + lP + ',status=yes');
	popUp.moveTo(lP, tP);
	popUp.resizeTo(w, h);
	popUp.focus();
	return false;
}

function fixHomeSideBarHeight() {
	var c, ch, s, sh, nh;
	if(document.getElementById) {
		c = document.getElementById("content");
		s = document.getElementById("homeSidebar");
		if((c != null) && (s != null)) {
			if(document.all) {
				ch = document.all.content.offsetHeight;
				sh  = document.all.homeSidebar.offsetHeight;
				nh = ch;
			} else if(document.defaultView) {
				ch = document.defaultView.getComputedStyle(c, "").getPropertyValue("height");
				sh = document.defaultView.getComputedStyle(s, "").getPropertyValue("height");
				nh = parseInt(ch.replace("px", "")) + 150;
			}
			if(nh != null) {
				s.style.height = nh + "px";
			}
		}
	}
}

function autoPrint() {
	var doPrint, c;
	doPrint = true;
	if ((navigator.platform.indexOf("Mac") != -1) || (navigator.userAgent.indexOf("Opera") != -1)) {
		if ((navigator.userAgent.indexOf("MSIE") != -1) || (navigator.userAgent.indexOf("Opera") != -1)) {
			doPrint = false;
			alert("Bitte nutzen Sie den Druck Befehl Ihres Browser!");
		}
	}
	if (doPrint == true) {
		c = confirm("Seite jetzt Drucken?");
		if(c == true) {
			window.print();
			window.setTimeout("window.close()",2500);
		}
	}
}

function resizeImagePopUp(id) {
	var n, bn;
	if(document.getElementById) {
		var n = document.getElementById(id);
		var bn = document.getElementById(id + "Btn");
		if(bn != null) {
			bn.title = "Fenster schliessen";
			bn.innerHTML = "Fenster schliessen";
			bn.onclick = function() {
				self.close();
				return false;
			}
		}
		if(n != null) {
			initWinSize(n.width + 60, n.height + 120);
		}
	}
}

function initWinSize(w, h) {
	var newWidth = w + 20;
	var newHeight = h + 80;
	if(newWidth < 250) {
		newWidth = 250;
	}
	if(newHeight < 250) {
		newHeight = 250;
	}
	if (((screen.height / 2) - h) > screen.height) {
		window.moveTo(10,10);
	} else {
		window.moveTo((screen.width-newWidth)/2,(screen.height-newHeight)/2);
	}
	window.resizeTo(newWidth,newHeight);
	self.focus();
}