// ---------------------------------------------------------------------------------------	
// scripte fuer www.rumpfinger.de
// author michael schulze, www.jms-design.de, 2011
// ---------------------------------------------------------------------------------------	

	
//---------------------------------------------------------------------------------------	
// Ebenenfunktionen
	// Style setzen
	function setStyle(layerName,stil,wert) {
		if (eval('document.getElementById("'+ layerName + '")')) {eval('document.getElementById("'+layerName+'").style.' + stil + '="' + wert + '"');}
	}
	
	//alle Layer einer Gruppe verbergen
	function hideAll(bereich,anzahl) {
		for(count=1; count <= anzahl; count++){
			eval('setStyle("' + bereich + count + '","display","none");');
		}	
	}
	

//---------------------------------------------------------------------------------------	
// String-Funktion
	function trim(s) {
	  	while (s.substring(0,1) == ' ') {
	    	s = s.substring(1,s.length);
	  	}
	  	while (s.substring(s.length-1,s.length) == ' ') {
	   		s = s.substring(0,s.length-1);
	  	}
	  	return s;
	}
		
		
//---------------------------------------------------------------------------------------	
//Formular-Funktionen
	function clearForm(name){
		if (confirm('Wollen Sie Ihre Angaben wirklich verwerfen?') == true) {
			var ref="document." + name;
			eval(ref + '.reset()');
		}
	}
	
//---------------------------------------------------------------------------------------	
// Schutzfunktionen
	// E-Mail-Adresse sichern
	function writeMail(dom,pre,klasse){
		document.write("<a ");
		if (klasse!='') document.write("class='" + klasse + "' ");
		document.write("href='mailto:" + pre + "@" + dom + "'>" + pre + "@" + dom + "</a>");
	}
	
	
//---------------------------------------------------------------------------------------	
// Seitenspezifische Funktionen
	
	
	// Archivlisten
		function toggleArchive(jahr){
			if (eval('document.getElementById("archiv'+jahr+'").style.display=="block"')){
				setStyle('archiv' + jahr, 'display','none');
				setStyle('archivhead' + jahr, 'background','url(../rum-bilder/rum-listpfeil-zu.gif) no-repeat 0px 14px');
				}
			else {
				setStyle('archiv' + jahr, 'display', 'block');
				setStyle('archivhead' + jahr, 'background','url(../rum-bilder/rum-listpfeil-auf.gif) no-repeat 0px 21px');
			}
		}

	
	// Diashow
		imgAkt = 0;
		containerAlt = 0;
		
		function changeImage(direction){
			if (direction==1){
				imgAkt++;
				if (imgAkt >= bildurl.length) imgAkt=0;
			}
			else {
				imgAkt--;
				if (imgAkt <= 0) imgAkt=bildurl.length-1;
			}
			containerNeu = (containerAlt+1)%2;
			setStyle('imagecontainer' + containerNeu,'background','url(../rum-bilder/' + bildurl[imgAkt] + ') no-repeat');
			opacity('imagecontainer' + containerNeu, 0, 100, 700);
			opacity('imagecontainer' + containerAlt, 100, 0, 700);
			containerAlt = containerNeu;
		}
		
	
	
	// Fade-In / Fade-Out
		function opacity(id, opacStart, opacEnd, millisec) {
		    // speed for each frame
		    var speed = Math.round(millisec / 100);
		    var timer = 0;
		
		    //determine the direction for the blending, if start and end are the same nothing happens
		    if(opacStart > opacEnd) {
		        for(i = opacStart; i >= opacEnd; i--) {
		            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
		            timer++;
		        }
		    } else if(opacStart < opacEnd) {
		        for(i = opacStart; i <= opacEnd; i++) {
		            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
		            timer++;
		        }
		    }
		}
		
		//change the opacity for different browsers
		function changeOpac(opacity, id) {
		    var object = document.getElementById(id).style;
		    object.opacity = (opacity / 100);
		    object.MozOpacity = (opacity / 100);
		    object.KhtmlOpacity = (opacity / 100);
		    object.filter = "alpha(opacity=" + opacity + ")";
		}
