function getElementsByTagNameAndClassName(tag, name) {
	var results = new Array();
	var elems = document.getElementsByTagName(tag);
	for (var i=0; i<elems.length; i++) {
		if (elems[i].className.indexOf(name) != -1) {
			results[results.length] = elems[i];
		}
	}
	return results;
}

function blurLinkFocus() {
	var linkelems = document.getElementsByTagName("A");
	for (var i=0; i<linkelems.length; i++) {
		linkelems[i].onfocus = function() {
			this.blur();
		}
	}
}

function bilderGalerieZaehler() {
	var bapfeillinks = getElementsByTagNameAndClassName("A", "ba_pfeil");
	if (bapfeillinks.length>0) {
		if (document.getElementById("ba_bildanzahl")) {
			document.getElementById("ba_bildanzahl").innerHTML = (bapfeillinks.length+1);
			if (document.getElementById("ba_abblink")) {
				if (document.getElementById("ba_aktbild")) {
					if(parseInt(document.getElementById("ba_aktbild").className) != parseInt(bapfeillinks.length+1)) {
						document.getElementById("ba_abblink").href = bapfeillinks[0].href + "&nur_abbildung_nummer=" + parseInt(parseInt(document.getElementById("ba_aktbild").className)+1);
					} else {
						document.getElementById("ba_abblink").href = bapfeillinks[0].href + "&nur_abbildung_nummer=1";
					}
					document.getElementById("ba_abblink").onclick = function() {
						this.blur();
					}
					document.getElementById("ba_abblink").title = "";
				}
			}
		}
	}
}
function bilderGalerieFenster() {
	if (document.getElementById("id_abbzoom")) {
		var offsetHoehe = 125;
		var offsetBreite = 35;
		var minBreite = 230;
		//if (document.getElementById('id_bilderauswahl')) offsetHoehe += 15;
		if (document.getElementById('id_abbzoom').width < minBreite) offsetBreite += 30;
		//self.resizeTo((document.getElementById("id_abbzoom").width+offsetBreite), (document.getElementById("id_abbzoom").height+offsetHoehe));
		/*
		var hoehe;
		if (document.getElementById("id_abbzoom").height>(screen.availHeight-offsetHoehe)) {
			document.getElementById("id_abbzoom").style.width = "auto";
			document.getElementById("id_abbzoom").style.height = (screen.availHeight-offsetHoehe-25)+"px";
			hoehe = screen.availHeight-10;
		} else {
			hoehe = document.getElementById("id_abbzoom").height+offsetHoehe;
		}
		*/
		hoehe = document.getElementById("id_abbzoom").height+offsetHoehe;
		if (navigator.userAgent.search(/MSIE 7./) != -1) hoehe = hoehe + 22;
		self.resizeTo(640, hoehe);
	} else {
		self.close();
	}
}

function initFunctions() {
	blurLinkFocus();
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

window.onload = initFunctions;

