/*
file: /scripts/popup.js
dsc: Variablen und Funktionen (z.B. fuer Popups, ...)
*/

/* Variablen initialisieren */
var bDOM = (document.getElementById && document.createTextNode);
var oPW = '';

/* groesseres Bild in neuem Fenster (Popup) laden */
function popup(sUrl, iWidth, iHeight) {
	var sProperties = 'width=' + iWidth + ',height=' + iHeight;
	sProperties += ',status=no,resizable=yes,menubar=no,locationbar=no,scrollbars=yes,dependent=yes';
	var sPopupHref = sUrl;
	if (!oPW.closed && oPW.location) {
		var iOldWidth=0, iOldHeight=0;
		if (oPW.innerWidth && oPW.innerHeight) {
			// alle ausser MSIE
			iOldWidth = oPW.innerWidth;
			iOldHeight = oPW.innerHeight;
		} else if (oPW.document.documentElement && oPW.document.documentElement.clientHeight) {
			// MSIE 6 im Strict Mode
			iOldWidth = oPW.document.documentElement.clientWidth;
			iOldHeight = oPW.document.documentElement.clientHeight;
		} else if (oPW.document.body) {
			// sonstige MSIE
			iOldWidth = oPW.document.body.clientWidth;
			iOldHeight = oPW.document.body.clientHeight;
		}
		oPW.location.href = sPopupHref;
		oPW.resizeBy(iWidth-iOldWidth,iHeight-iOldHeight);
	} else {
		oPW = window.open(sPopupHref, 'PopUp', sProperties);
	}
	if (window.focus) {
		oPW.focus();
	}
	return false;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
mustInitImg = true;
function initImgID() {var di = document.images; if (mustInitImg && di) { for (var i=0; i<di.length; i++) { if (!di[i].id) di[i].id=di[i].name; } mustInitImg = false;}}
function findElement(n,ly) {
	var d = document;
	if (browserVers < 4) return d[n];
	if ((browserVers >= 6) && (d.getElementById)) {initImgID; return(d.getElementById(n))}; 
	var cd = ly ? ly.document : d;
	var elem = cd[n];
	if (!elem) {
		for (var i=0;i<cd.layers.length;i++) {
			elem = findElement(n,cd.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}
function changeImagesArray(array) {
	if (preloadFlag == true) {
		var d = document; var img;
		for (i=0;i<array.length;i+=2) {
			img = null; var n = array[i];
			if (d.images) {
				if (d.layers) {img = findElement(n,0);}
				else {img = d.images[n];}
			}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (!img && d.getElementsByName) {
				var elms = d.getElementsByName(n);
				if (elms) {
					for (j=0;j<elms.length;j++) {
						if (elms[j].src) {img = elms[j]; break;}
					}
				}
			}
			if (img) {img.src = array[i+1];}
		}
	}
}
function changeImages() {
	changeImagesArray(changeImages.arguments);
}

