<!--
/* für fast alle Dateien */


var http_request = null;
var startShow = null;
var root = null;
var activeNode = null;
var currentNode = null;

var showInf = true;
var showInfType = "klick";
var showNav = true;
var showNavType = "klick";
var showShortNav = true;
var infBoxFixed = false;
var navBoxFixed = false;


window.onload = init;

/* ändert den Ausschuss (zur Zeit nicht benötigt) */
function changeCommission(i)
{
  var commission = new Array("sprecherrunde", "innenausschuss", "technischer_ausschuss", "aussenausschuss", "weitere");
  document.getElementById("cyclic_info").src = "gemeindestruktur/verantwortliche/" + commission[i] + "/info.html";
  i++;
  if (i >= commission.length) i=0;
  window.setTimeout("changeCommission("+i+")",6000);
}


/* fügt einen Link zum oberen Teil der Seite an einer bestimmten Stelle ein */
function addLinkToTop(item){
  var p = document.createElement("p");
  	
  var a = document.createElement("a");
  a.href = "#top";
  	
  a.className = "a_top";
  a.title = "Befehl: nach oben";
  		
  var text = document.createTextNode("oben");
  a.appendChild(text);
  p.appendChild(a);
  item.parentNode.insertBefore(p,item);
}


/* fügt an jeder h2-Überschrift einen Link zum oberen Teil der Seite ein */
function addLinksToTop(){
  var h = document.getElementsByTagName("h2");
  for (var i=0; i<h.length; i++){
  	if(h[i].parentNode.className=="headbox") addLinkToTop(h[i]);
  }
}


/* ändert die Adresse von Bildern */
function changeImg(){
  var img = document.getElementsByTagName("img");
  for (var i=0; i<img.length; i++){
  	var s = img[i].src;
  	if (s.substring(s.length-6).toLowerCase() == "_k.jpg"){
  		img[i].src = s.substring(0,s.length-6) + ".jpg";
  	}
  }
}




/* zeigt die ShortNavigation (Extra-Kasten) */
function showShortNavBox(){
  document.getElementById('shortnav').className ="active";
  startShow = new Date();
  window.setTimeout("hideShortNavBox()",3500);
}


/* versteckt die ShortNavigation (Extra-Kasten) */
function hideShortNavBox(){
  var today = new Date();
  var diff = (today - startShow);
  if (diff >= 3500) document.getElementById('shortnav').className ="inactive";
  else window.setTimeout("hideShortNavBox()",diff);
}


function searchActiveNode(){
	var a = root.getElementsByTagName("a");
	for (var i=0; i<a.length; i++)
		if (a[i].className == "active") return a[i];
	return null;
}

/* gibt nächstes Kind vom Typ typ zurück, überspringt andere Knoten */
function nextChildElement(child, typ){
  if (!child) return null;
  child = child.nextSibling;
  while ((child != null) && (child.nodeName != typ)) child = child.nextSibling;
  return child;
}

/* gibt vorheriges Kind vom Typ typ zurück, überspringt andere Knoten */
function previousChildElement(child, typ){
	if (!child) return null;
  child = child.previousSibling;
  while ((child != null) && (child.nodeName != typ)) child = child.previousSibling;
  return child;
}



function navigationToFirst(){
	return currentNode.parentNode.parentNode.parentNode.getElementsByTagName("li")[0];
}
function navigationToLast(){
	var tmp = nextChildElement(currentNode.parentNode.parentNode,"LI");
	while (nextChildElement(tmp,"LI")) tmp = nextChildElement(tmp,"LI");
	return tmp;
}
function navigationToNext(){
	return nextChildElement(currentNode.parentNode.parentNode,"LI")
}
function navigationToPrevious(){
	return previousChildElement(currentNode.parentNode.parentNode,"LI")
}
function navigationToTop(){
	var li = currentNode.parentNode.parentNode.parentNode.parentNode
	if(li.nodeName != "LI") return null;
	return li;
}
function navigationToDown(){
	var ul = nextChildElement(currentNode.parentNode,"UL");
	if(!ul) return null;
	return ul.getElementsByTagName("li")[0];
}
function navigationToNextVisibleElement(){
	var tmp = navigationToDown();
	//if (tmp) alert(tmp.parentNode.style.display);
	if (tmp && tmp.parentNode && tmp.parentNode.style.display == "block") return tmp;
	tmp = navigationToNext();
	if (tmp) return tmp;
	var old_currentNode = currentNode;
	
	do{
		tmp = navigationToTop();
		if (tmp) currentNode = tmp.getElementsByTagName("a")[0];
		else break;
		tmp = navigationToNext();
	}while (!tmp);
	
	currentNode = old_currentNode;
	return tmp;
}
function navigationToPreviousVisibleElement(){
	var tmp = navigationToPrevious();
	if (!tmp) return navigationToTop();
	var old_currentNode = currentNode;

	currentNode = tmp.getElementsByTagName("a")[0];	
	do{
		tmp = navigationToDown();
		if (!tmp || !tmp.parentNode || tmp.parentNode.style.display != "block")	break;
		currentNode = tmp.getElementsByTagName("a")[0];
		tmp = navigationToLast();
		if (!tmp) break;
		currentNode = tmp.getElementsByTagName("a")[0];
	}while (currentNode);
	
	tmp = currentNode.parentNode;
	currentNode = old_currentNode;
	
	return tmp;
}

function keyPressed(Ereignis) {
	if (!Ereignis) Ereignis = window.event;
	var key = Ereignis.keyCode || window.event.which;
	//alert(key);
  if (root){
  	var li = null;
  	switch(key){
  		case  67: /*Taste C*/
  			//alert(activeNode.firstChild.data);
  			break;
  		case  73: /*Taste I*/
  			toogleShowInfBox();
  			break;
  		case  78: /*Taste N*/
  			toogleShowNavBox();
  			break;
  		case  27: /*Esc*/
  		case  96: /*NumPad 0*/
  			var ul  = activeNode.parentNode.parentNode.parentNode;
  			while (ul && ul.nodeName=="UL"){
  				ul.style.display = "block";
  				ul = ul.parentNode.parentNode;
  			}
  			li  = activeNode.parentNode;
  			break;
  		case 101: /*NumPad 5*/
  			var ul = nextChildElement(currentNode.parentNode,"UL");
  			if (ul.style.display == "block") ul.style.display = "none";
  			else ul.style.display = "block";
  			break;
			case  36: /*Taste Pos1*/
    	//case  70: /*Taste F*/
    	case 103: /*NumPad 7*/ 
    		li = navigationToFirst();
				break;
			case  35: /*Taste Ende*/
			//case  76: /*Taste L*/
			case  97: /*NumPad 1*/ 
				li = navigationToLast();
				break;
			//case  40: /*Pfeil runter*/
			case  98: /*NumPad 2*/ 
				li = navigationToNext();
				break;
			//case  37: /*Pfeil links*/
			case 100: /*NumPad 4*/ 
				li = navigationToTop();
				break;
			//case  39: /*Pfeil rechts*/
			case 102: /*NumPad 6*/ 
				li = navigationToDown();
				break;
			//case  38: /*Pfeil hoch*/
			case 104: /*NumPad 8*/ 
				li = navigationToPrevious();
				break;
			case  34: /*Bild runter*/ 
			case  99: /*NumPad 3*/ 
				li = navigationToNextVisibleElement();
				break;
			case  33: /*Bild hoch*/ 
			case 105: /*NumPad 9*/ 
				li = navigationToPreviousVisibleElement();
				break;
			case  13: /*Enter*/ 
				if (currentNode && currentNode.href) location.href = currentNode.href;
		}
		if(li){
			if (currentNode != activeNode) currentNode.className = "";
			else currentNode.className = "active";
			li.parentNode.style.display = "block";
			currentNode = li.getElementsByTagName("a")[0];
			currentNode.className = "marked";
		}
	}
}

function showNavBox(visibility){
		var navi = document.getElementById("navigation");
		var inhalt = document.getElementById("inhalt");
		if (!visibility){
			navi.style.display = "none";
			inhalt.style.marginLeft = "1em"; 
	}
	else{
		navi.style.display = "block";
		inhalt.style.marginLeft = "13.7em";		
	};
}
function toogleShowNavBox(){
		var navi = document.getElementById("navigation");
		var inhalt = document.getElementById("inhalt");
		if (navi.style.display == "block"){
			navi.style.display = "none";
			inhalt.style.marginLeft = "1em"; 
	}
	else{
		navi.style.display = "block";
		inhalt.style.marginLeft = "13.7em";		
	};
}

function showInfBox(visibility){
	var child = document.getElementById("info").childNodes;
	var inhalt = document.getElementById("inhalt");
	for(var i=0;i<child.length; i++){
		if (child[i].nodeType==1 && child[i].id != "showinfo"){
				if (visibility) child[i].style.display = "block";
				else child[i].style.display = "none";
		}
	}
	if (visibility) inhalt.style.marginRight = "14.7em";
	else inhalt.style.marginRight = "1em";
}
function toogleShowInfBox(){
	var child = document.getElementById("info").childNodes;
	var inhalt = document.getElementById("inhalt");
	var showInfoBox;
	for(var i=0;i<child.length; i++){
		if (child[i].nodeType==1 && child[i].id != "showinfo"){
				if (!showInfoBox){
					showInfoBox = (child[i].style.display == "none");
				}
				if (showInfoBox) child[i].style.display = "block";
				else child[i].style.display = "none";
		}
	}
	if (showInfoBox) inhalt.style.marginRight = "14.7em";
	else inhalt.style.marginRight = "1em";
}


function hideBoxes(mode){
	if (document.getElementById("navigation") && showNavType == "dyn" && (mode != 1) && !navBoxFixed) showNavBox(false);
	if (document.getElementById("info") && showInfType == "dyn" &&( mode != 2) && !infBoxFixed) showInfBox(false); 
}

/* beim Laden wird je nach Seite eventuell weitergeleitet, die nächsten Veranstaltungen angefügt oder/und die Emailadressen geändert und die Links zum oberen Teil der Seite hinzugefügt */
function init(){
	if (self.init_bottom) init_bottom();		
	else if (self.addEmailAddress) addEmailAddress();		// evtl. Mail-Adressen automatisch erzeugen
	if (self.init_top) init_top();
	
	addLinksToTop();
	
	if (self.loadCookies){
		var adr0 = parent.location.href;
		var ind = adr0.indexOf("?");
		if (ind>0){
			var params = adr0.substr(ind+1);
			if (params.indexOf("ignore=true")<0) importCookies(params, true, true);
			saveCookies();
			
			if (frames['person_f']) frames['person_f'].setPersonConfig(getCookie("time", true), getCookie("minPerson", true), getCookie("maxPerson", true), getCookie("person", true) );
		}
		
		showInf = getCookie("showInf", true);
		if (showInf == "") showInf = true;
		else if (showInf.length>0){
			if (showInf == "false") showInf = false;
			else showInf = true;
		}
		showInfType = getCookie("showInfType", true);
		showNav = getCookie("showNav", true);
		if (showNav == "") showNav = true;
		else if (showNav.length>0){
			if (showNav == "false") showNav = false;
			else showNav = true;
		}
		showNavType = getCookie("showNavType", true);
		showShortNav = getCookie("showShortNav", true);
		if (showShortNav == "") showShortNav = true;
		else if (showShortNav.length>0){
			if (showShortNav == "false") showShortNav = false;
			else showShortNav = true;
		}
	}
	
	if (self.setBreadcrumbs) setBreadcrumbs();		// evtl. Breadcrumbs automatisch erzeugen
	
	if (self.sndReqForEvents) sndReqForEvents();		// evtl. nächsten Veranstaltungen laden
	else if (self.initPlans) initPlans("../../pic/", -1);		// evtl. Fahrplanauskünfte laden
	if (self.initSemesters) initSemesters();		// evtl. Bild-Markierungen der alten Sprecherrunden erzeugen
	if (self.addPhotoLinks) addPhotoLinks();		// evtl. Foto-Links zur Bidler-Show erzeugen
	
	if (self.loadConfig) loadConfig();					// evtl. Konfiguration laden
	if (self.initPicShow) initPicShow();				//evtl. Bildershow laden
	
	
	if (document.getElementById("navigation") && showNav==false) showNavBox(false);
	
	if (document.getElementById("navigation") && showNavType != "stat"){
		var div = document.createElement("div");
		var attr = document.createAttribute("id");
	  attr.nodeValue = "shownav";
	  div.setAttributeNode(attr);
	  if (showNavType == "dyn"){
	  	div.onmouseover = function(){showNavBox(true)};
			div.onclick = function(){
				navBoxFixed = !navBoxFixed; 
				if (navBoxFixed) showNavBox(true);
			};
			if (showNav==true) navBoxFixed = true;
	  }
		else div.onclick = function(){toogleShowNavBox()};
		div.title = "Navigation ein- oder ausblenden";
		var main = document.getElementById("main");
		main.insertBefore(div, main.firstChild);
	}
	
	if (document.getElementById("info") && showInfType != "stat"){
		var div = document.createElement("div");
		var attr = document.createAttribute("id");
	  attr.nodeValue = "showinfo";
	  div.setAttributeNode(attr);
		if (showInfType == "dyn"){
	  	div.onmouseover = function(){showInfBox(true)};
			div.onclick = function(){
				infBoxFixed = !infBoxFixed; 
				if (infBoxFixed) showInfBox(true);
			};
			if (showInf==true) infBoxFixed = true;
	  }
		else div.onclick = function(){toogleShowInfBox()};
		div.title = "Info-Box ein- oder ausblenden";
		var info = document.getElementById("info");
		info.insertBefore(div, info.firstChild);
	}
	if (document.getElementById("info") && showInf==false	) showInfBox(false);
	
	if (showShortNav){
		document.getElementById("top").onmouseover = function(){showShortNavBox(); hideBoxes();};
		//frames['navigation_f'].document.onmouseover = function(){showShortNavBox()};
		document.getElementById("top").onmouseout = function(){hideShortNavBox()};
		//frames['navigation_f'].document.onmouseout = function(){hideShortNavBox()};
	}
	else if (showNavType == "dyn" || showInfType == "dyn") document.getElementById("top").onmouseover = function(){hideBoxes()};
	if (showNavType == "dyn" || showInfType == "dyn"){
		if (document.getElementById("inhalt")) document.getElementById("inhalt").onmouseover = function(){hideBoxes(0)};
		if (document.getElementById("bottom")) document.getElementById("bottom").onmouseover = function(){hideBoxes(0)};
		//if (document.getElementById("navigation")) document.getElementById("navigation").onmouseover = function(){hideBoxes(1)};
		//if (document.getElementById("info")) document.getElementById("info").onmouseover = function(){hideBoxes(2)};
	}
	
	try{
		if (frames && frames['navigation_f'] && frames['navigation_f'].document){				//evtl. Tastendrücke an Navigation weitergeben
			root = frames['navigation_f'].document.getElementById("root");
			activeNode = searchActiveNode();
			currentNode = activeNode;
			document.onkeydown = keyPressed;		
			frames['navigation_f'].document.onkeydown = keyPressed;		
			if (frames['bottom_f'] && frames['bottom_f'].document) frames['bottom_f'].document.onkeydown = keyPressed;
			if (frames['top_f'] && frames['top_f'].document) frames['top_f'].document.onkeydown = keyPressed;
		}
	}
	catch(err){
  
	}
		
	
	
	changeImg();
	
	//initFocus();
}


/* nicht benötigte Funktionen */
/*
function initFocus(){
  var img = document.getElementsByTagName("img");
  for (var i=0; i<img.length; i++){
	if (img[i].className=="litpic" || img[i].className=="norpic" || img[i].className=="bigpic"){
		//alert(img[i].src);
		img[i].onmouseover = focusImg(img[i]);//"node.className += '_f'";//focusImg(img[i]);
		img[i].onmouseout = blurImg(img[i]);
  	}
  }
}
function blurImg(node){
  var str = node.className;
  node.className = str.substring(0,str.length-2);
}
function focusImg(node){
  node.className += "_f";
  //alert(node.className);
}
*/

//-->