window.onload = loader

function loader() {
	assignPopUps("popUpImg", 400, 400, "no");
	assignPopUps("popUpLink", 400, 400, "yes");
	resizeImagePopUp("popUpZoomImage");
}

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 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 + 50, n.height + 100);
		}
	}
}

function initWinSize(w, h) {
	var newWidth = w + 20;
	var newHeight = h + 50;
	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);
}