// IE Browser-Detection
function getIEVersionNumber() {
	var ua = navigator.userAgent;
	var MSIEOffset = ua.indexOf("MSIE ");
	if (MSIEOffset == -1) {
		return 0;
	} else {
		return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
	}
}

//var ie55 = getIEVersionNumber() >= 5.5;


function popup(mylink, winname,w,h) {
	var breit = (w)? "width=" + (w + 40) : "width=700";
	var hoch = (h)? "height=" + (h + 40) : "height=500";

	if (!window.focus) return true;
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else
		href=mylink.href;
	window.open(href, winname, breit + ',' + hoch + ',scrollbars=yes, resizable=yes, menubar=yes').focus();
	return false;
}
var newWin;
function imgPopUp(cont, winname,w,h) {
	var width = (w)? (w) : 700;
	var height = (h)? (h) : 500;


	width += 70;
	height += 135;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var param = "width=" + width +  ", height=" + height + ", left=" + left + ", top=" + top;

		newWin = window.open("", winname, param + ',scrollbars=no, resizable=yes, menubar=no');
		newWin.resizeTo(width, height);
		setTimeout("putInWindow('" + cont + "')", 50);
		newWin.focus();

	return false;
}
function putInWindow(cont) {
	var newCont = "<html><head><title>Zoomansicht</title></head>";
	newCont += "<style type='text/css'>a img {border: solid 1px #000;} a:hover img {border: solid 1px #fff;}</style>"
	newCont += "<body style='background: #A5AAB0;margin: 0; padding: 30px 30px 45px 30px; height: 100%'>"
	newCont += "<div style='position: absolute; z-index: 1; font: 11px Verdana, sans-serif; color:#8A8A8A; margin-top: 30%; text-align: center;'>Bild wird geladen...</div>"
	newCont += "<div style='position: relative; z-index: 100;'><a href='#' onclick='self.close();'><img src='"+ cont + "'></a></div>";
	newCont += "<div style='position: relative; z-index: 100;padding-top: 10px;  text-align: center; color: #606060; font-size: 11px; font-family: Arial, Helvetica, sans-serif;'>Zum Schließen bitte auf das Bild klicken</div>";
	newCont += "</body></html>";
	newWin.document.write(newCont);
	newWin.document.close();
}

function checkChangeForm() {
	if(window.top.topFrame.changeForm == true) {
		if (confirm("Es wurden anscheinend Änderungen am Formular durchgeführt.\n Klicken Sie Abbrechen um die Änderungen speichern zu können.\n Klicken Sie OK wenn Sie die Änderungen nicht speichern möchten")) {
			return true;
		} else {
			return false;
		}
	}
	return false;
}


function openHide(id) {
	obj = document.getElementById(id);
	obj.style.display = (obj.style.display == "block")? "none" : "block";
}

// 	FadeFunktion:
//	cId:	id des umgebenen div's
//	imgId:	id des Bildes
//	txtId:	id des Textes der ausgetauscht werden soll
//	aImgs:	array der Bilder
//		var aImgs =[['md6118D.jpg', 'Name1'],
//					['md6254D.jpg', 'Name2'],
//					...
//					]
//  fadeInt:	Standdeuer der Bilder (int)
//	fadeSpeed:	Überblendgeschwindigkeit (int)
//  fadeIt:		Faden Ja oder Nein (true, false)
//
/*	**********************************
//	BeispielCode:
//
//	<!-- Bildercontainer -->
//	<span id="c6254" style="background: transparent url(images/md9797D.jpg); width:90px; height: 60px; display: block;"><img src="images/md9797D.jpg" width="90" height="60" alt="" title=""  id="pv6254" /></span>
//	<!-- Textcontainer -->
//	<span id="t6254">Kurt Heinen<br />Fritz-Hüsgen</span>
//
//	<script type="text/javascript">
//	var aImgs =[
//				['images/md9797D.jpg', 'Text zum Bild 1'],
//				['images/md9799D.jpg', 'Text zum Bild 2'],
//				['images/md9373D.jpg', 'Text zum Bild 3']
//			];
//	initFading("c6254", "pv6254", "t6254", aImgs, 5000, 2, true);
//	<\/script>
 */

var count=0
function initFading(cId, imgId,txtId, aImgs, fadeInt, fadeSpeed, fadeIt) {
	var img = document.getElementById(imgId);
	var cont = document.getElementById(cId);
	var txt = document.getElementById(txtId);
	var dBS=document.body.style;
	var op;
	var i = 0;
	if(typeof(dBS.MozOpacity)=='string')op='moz';
	if(typeof(dBS.opacity)=='string')op='css3';
	if(typeof(dBS.filter)=='string')op='ie';
	img.op = op;

	if(!img.op) return;

	if (aImgs.length <= 1) return false;

	img.aImgs = aImgs;
	img.txt = txt;
	img.actImg = 0;
	img.imgsCount = aImgs.length;
	img.oc = 100;
	cont.style.backgroundImage = "url(" + img.aImgs[img.actImg][0] + ")";
	img.setOpacity = function() {
		switch(img.op) {
			case 'ie' : img.style.filter = "Alpha(opacity=100)"; break;
			case 'css3' : img.style.opacity = 1; break;
			case 'moz' : img.style.MozOpacity = 1; break;
		}
		setTimeout(img.fader, fadeInt);
	}

	img.faderOut = function () {
		img.oc-= fadeSpeed;

		switch(img.op) {
			case 'ie' : img.style.filter = "Alpha(opacity="+img.oc+")";; break;
			case 'css3' : img.style.opacity = img.oc/100; break;
			case 'moz' : img.style.MozOpacity = img.oc/100; break;
		}

		if (img.oc <= 0) {
			clearInterval(img.fd);
			img.src = img.aImgs[img.actImg][0];
			img.alt = img.aImgs[img.actImg][1];
			img.title = img.aImgs[img.actImg][1];
			setTimeout(img.setOpacity, fadeInt/2);
			img.oc = 100;
			if (txtId != "") {
				img.txt.innerHTML = img.aImgs[img.actImg][1];
			}
		}
	}


	img.fader = function(){
		if (img.actImg < img.imgsCount-1){
			img.actImg++ ;
		} else {
			img.actImg = 0;
		}
		if (fadeIt)	{
			clearInterval(img.fd);
			var bgImg = new Image();
			bgImg.onload = function() {
				img.fd = setInterval(img.faderOut, 10);
			};
			bgImg.src = img.aImgs[img.actImg][0];
			cont.style.backgroundImage = "url(" + bgImg.src + ")";
		} else {
			img.src = img.aImgs[img.actImg][0];
			img.alt = img.aImgs[img.actImg][1];
			img.title = img.aImgs[img.actImg][1];
		}
	};



	setTimeout(img.fader, fadeInt);
}
