<!--
/* nur für Datei "gemeindestruktur/person_info.html" (Personen-Info-Fenster) */


var min = 0;
var max = 0;
var person = new Array();
var counter = 0;
var last = 0;
var pics = new Array();
var startShow = null;
var startPic = null;
var timeDiff = 7000;
var time0 = 7000;
var wait = true;

var currentHeight = 0;
var currentWidth = 0;

window.onload = init;


function setPersonConfig(new_timeDiff, new_min, new_max, new_counter ){
	if (new_timeDiff.length>0) timeDiff = new_timeDiff;
  if (timeDiff<0) timeDiff = 7000
  
  if (new_min.length>0) min = new_min;
  if (min<0) min = 0;
  if (min>person.length-1) min = person.length-1;
  
  if (new_max.length>0) max = new_max;
  if (max<min) max = min;
  if (max>person.length-1) max = person.length-1;
  
  if (new_counter.length>0) counter = new_counter;
  if (counter<min) counter = min;
  if (counter>max) counter = max;
  
  if (timeDiff>0) preloadPersonPic();
}

/* Initialisiert alle Personen und lädt alle Einstellungen aus den Cookies */
function initPersons(minPerson, maxPerson)
{
  person.push(new Array("sprecher", "pfarrer", "Pfarrer", "Norbert Stryczek"));
  person.push(new Array("sprecher", "pgrv", "PGRV", "Richard Rudolf", "Pfarrgemeinderatsvorsitzender"));
  person.push(new Array("sprecher", "innen", "Sprecher", "Theresa Schwarzkopf", "Innenausschuss-Vorsitzender"));
  person.push(new Array("sprecher", "technisch", "Sprecher", "Roland Zimm", "Technischer-Ausschuss-Vorsitzender"));
  person.push(new Array("sprecher", "aussen", "Sprecher", "Elisabeth Stöhr", "Aussenausschuss-Vorsitzender"));
  person.push(new Array("sprecher", "newsletter", "Sprecher", "Norbert Manthey", "Newsletter-Verantwortlicher"));

  person.push(new Array("ausschuesse/innen", "et", "ET-Chef", "Robert Drechsel", "ET-Fachkreissprecher"));
  person.push(new Array("ausschuesse/innen", "mts", "MTS-Chef", "Christoph Ringelhann", "MTS-Fachkreissprecher"));
  person.push(new Array("ausschuesse/innen", "njummm", "NJuMMM-Chef", "Nicola Ballhausen", "NJuM³-Fachkreissprecher"));
  person.push(new Array("ausschuesse/innen", "vip", "ViP-Chef", "Eva-Maria Clasen", "ViP-Fachkreissprecher"));

  person.push(new Array("ausschuesse/technisch", "chefgeist", "Chefgeist", "Elisabeth Mieth"));
  person.push(new Array("ausschuesse/technisch", "hausmeister", "Hausmeister", "Stefan Luther"));
  person.push(new Array("ausschuesse/technisch", "biergeist1", "Biergeist", "Tobias Soden"));
  person.push(new Array("ausschuesse/technisch", "biergeist2", "Biergeist", "Marcel Robel"));
  person.push(new Array("ausschuesse/technisch", "struppengeist1", "Struppengeist", "Franziska Lotzmann"));
  person.push(new Array("ausschuesse/technisch", "struppengeist2", "Struppengeist", "Karl Rautschek"));

  person.push(new Array("ausschuesse/aussen", "aussenminister", "Außenminister", "Martin Göring"));
  person.push(new Array("ausschuesse/aussen", "oeffentlichkeit", "Referent", "Tobias Mros", "Referent für Öffenlichkeitsarbeit"));
  person.push(new Array("ausschuesse/aussen", "oekumene", "Ökumenegeist", "Philipp Kraus"));
  person.push(new Array("ausschuesse/aussen", "nachtcafe", "Nacht-Café-Geist", "Elisabeth Stöhr"));
  person.push(new Array("ausschuesse/aussen", "philister", "Philistergeist", "Thomas Seidel"));
  person.push(new Array("ausschuesse/aussen", "webmaster", "Webmaster", "Vinzent Krauße"));

  person.push(new Array("weitere", "auslaender", "Ausländerbeauftr.", "Kerstin Boden"));
  person.push(new Array("weitere", "kuester", "Küster", "Jakob Hohlfeld"));
  person.push(new Array("weitere", "liturgie", "Liturgiegeist", "Roland Zimm"));
  person.push(new Array("weitere", "musik", "Musikgeist", "Benedikt Krüger"));


  min = minPerson;
  if (maxPerson > 0) max = maxPerson;
  else max = person.length-1;

  counter = min;
  
  
  loadCookies();
  setPersonConfig(getCookie("time", true), getCookie("minPerson", true), getCookie("maxPerson", true), getCookie("person", true) );
    
  /*var tmp = getCookie("time", true);
  if (tmp.length>0) timeDiff = tmp;
  if (timeDiff<0) timeDiff = 7000
  
  var tmp = getCookie("minPerson", true);
  if (tmp.length>0) min = tmp;
  if (min<0) min = 0;
  if (min>person.length-1) min = person.length-1;
  
  var tmp = getCookie("maxPerson", true);
  if (tmp.length>0) max = tmp;
  if (max<min) max = min;
  if (max>person.length-1) max = person.length-1;
  
  var tmp = getCookie("person", true);
  if (tmp.length>0) counter = tmp;
  if (counter<min) counter = min;
  if (counter>max) counter = max;
  
  if (timeDiff>0) preloadPersonPic();*/
  
  /*if (document.cookie){
    var cookies = document.cookie.split("; ");
    var j = 0;
    while (j < cookies.length){
      if (cookies[j].substring(0,6).toLowerCase() == "Person"){
        counter = cookies[j].substring(7);
        break;
      }
      if (cookies[j].substring(0,4).toLowerCase() == "time"){
        timeDiff = cookies[j].substring(5);
        break;
      }
      if (cookies[j].substring(0,9).toLowerCase() == "minPerson"){
        min = cookies[j].substring(10);
        break;
      }
      if (cookies[j].substring(0,9).toLowerCase() == "maxPerson"){
        max = cookies[j].substring(10);
        break;
      }
      j++;
    }
  }*/
  
  
}


/* ersetzt alle Umlaute durch gleiche HTML-Tags */
function toHref(str)
{
  var arr = new Array(2);
  arr[0] = new Array("&Ouml;", "&ouml;", "&Auml;", "&auml;", "&Uuml;", "&uuml;", "&szlig;", "&eacute;", " ");
  arr[1] = new Array("Oe", "oe", "Ae", "ae", "Ue", "ue", "ss", "e", "_");
  for (var i=0; i < arr[0].length; i++){
    //myRegExp = new RegExp(arr[0][i],"g");
    str = str.replace(arr[0][i]+"g", arr[1][i]);
  }
  return str.toLowerCase();
}


/* function changePicSize(){
	document.getElementById("pic").width = currentWidth * document.pic.offsetHeight / currentHeight;
  document.getElementById("pic").height = document.pic.offsetHeight;
  //alert(currentWidth + " x " + currentHeight + " -> " + document.getElementById("pic").width + " x " + document.getElementById("pic").height);	
} */


/* lädt das nächste Bild (im Voraus) */
function preloadPersonPic()
{
  if (counter > max) counter = min;
  if (counter < min) counter = max;
  
  changeCookie("person", counter, true);
  //document.cookie = "person=" + counter;
  
  last = counter;
  startPic = new Date();
  var pic = document.getElementById("pic");
  if (pics[counter] == null){

		//pics[counter] = document.getElementById("pic").cloneNode(false);
		//pics[counter].height = 0;
		//pics[counter].width = 0;
    pics[counter] = new Image();
    
    /* var attr = document.createAttribute("id");
	  attr.nodeValue = "pic";
	  pics[counter].setAttributeNode(attr);
	  var attr = document.createAttribute("name");
	  attr.nodeValue = "pic";
	  pics[counter].setAttributeNode(attr);
	  var attr = document.createAttribute("title");
	  attr.nodeValue = "";
	  pics[counter].setAttributeNode(attr);
	  var attr = document.createAttribute("alt");
	  attr.nodeValue = "	";
	  pics[counter].setAttributeNode(attr); */
	  //pics[counter].style.height = "100%";

    //alert("./foto/" + person[counter][1] + "_k.jpg\n" + "./foto/" + person[counter][1] + ".jpg");
    //if (document.getElementById("pic").width<150) 
    pics[counter].src = "./foto/" + person[counter][1] + "_k.jpg";
    //else pics[counter].src = "./foto/" + person[counter][1] + ".jpg";
   
   	//currentHeight = pics[counter].height;
    //currentWidth = pics[counter].width;	
    
    //if (!pics[counter].complete){
      pics[counter].onload = changePersonPic;
      //pics[counter].onerror = function(){counter++; preloadPersonPic();};
    //}
  } 
  else changePersonPic();
}


/* ändert das Bild */
function changePersonPic()
{
  var today = new Date();
  var diff = timeDiff - (today - startPic);
 
  if (wait == false){
    diff = 0;
    wait = true;
  }
  if (counter == last && diff > 0){
    if (diff > 4000) window.setTimeout("changePersonPic()",2000);
    else if (diff > 2000) window.setTimeout("changePersonPic()",1000);
    else if (diff > 1000) window.setTimeout("changePersonPic()",500);
    else window.setTimeout("changePersonPic()",diff);
  }
  else if(counter == last){
    
    //if (document.getElementById("pic").width<150) document.getElementById("pic").src = "./foto/" + person[counter][1] + "_k.jpg";
    //else document.getElementById("pic").src = "./foto/" + person[counter][1] + ".jpg";
    document.getElementById("pic").src = pics[counter].src;
    
    /*if (currentHeight<=0) currentHeight = pics[counter].height;
    if (currentWidth<=0) currentWidth = pics[counter].width;	
    var pic = document.getElementById("pic");
    pic.parentNode.replaceChild(pics[counter], pic);
    changePicSize();*/

    document.getElementById("pic").onmouseover   = showBar;
    //document.getElementById("pic").style.height = "100%";
    
    if (timeDiff>2000) window.setTimeout("changeName("+counter+")",500);
    else if (timeDiff>1000) window.setTimeout("changeName("+counter+")",200);
    else changeName(counter);
  //} else {
  //  setTimeout("changePersonPic("+i+")", 100);
  }
}


/* ändert den Namen */
function changeName(cc){
  var c = person[cc][1].charAt(person[cc][1].length-1);
  if (c == "0" || c == "1" || c == "2" || c == "3") document.getElementById("adr").href = toHref(person[cc][0]) + ".html#" +person[cc][1].substring(0,person[cc][1].length-1)+"er";
  else document.getElementById("adr").href = toHref(person[cc][0]) + ".html#" +person[cc][1];  
  
  document.getElementById("head").innerHTML = person[cc][2];
  if (person[counter].length > 4) var label = "Antlitz von " + person[cc][3] + ", " + person[cc][4];
  else var label = "Antlitz von " + person[cc][3] + ", " + person[cc][2];
  document.getElementById("name").innerHTML = person[cc][3];
  var pic = document.getElementById("pic");
  pic.alt = label;
  pic.title = "Interner Link: "+label;
  
  //pic.left = (document.body.offsetWidth - pic.width) / 2;
  if (counter == last && counter == cc && timeDiff > 0 && min<max){
	  counter++;
	  preloadPersonPic();
  }
}


/* verringert die Änderungsgeschwindigkeit der Personen */
function slow(){
  if(timeDiff > 0){
    timeDiff = timeDiff + 250;
    if (timeDiff > 100000) timeDiff = 0;
    changeCookie("time", timeDiff, true);
  	//document.cookie = "time=" + timeDiff;
  }
  else{
    time0 = time0 + 250;
    if (time0 > 100000) time0 = 0;
    changeCookie("time", time0, true);
  	//document.cookie = "time=" + time0;
  }
}


/* erhöht die Änderungsgeschwindigkeit der Personen */
function fast(){
  if(timeDiff > 0){
    timeDiff = timeDiff - 250;
    if (timeDiff <= 0) timeDiff = 750;
    changeCookie("time", timeDiff, true);
  	//document.cookie = "time=" + timeDiff;
    //preloadPersonPic();
  }
  else{
    time0 = time0 - 250;
    if (time0 <= 0) time0 = 0;
    changeCookie("time", time0, true);
  	//document.cookie = "time=" + time0;
  }
}


/* Pausieren der Personen-Diashow */
function pause(){
  document.getElementById("stop").className = "blind";
  document.getElementById("play").className = "";
  time0 = timeDiff;
  timeDiff = 0;
  //preloadPersonPic();
}


/* Starten der Personen-Diashow */
function play(){
  document.getElementById("play").className = "blind";
  document.getElementById("pause").className = "";
  document.getElementById("stop").className = "";
  timeDiff = time0;
  preloadPersonPic();
}


/* Stoppen der Personen-Diashow */
function stop(){
  counter = min;
  pause();
  time0 = 7000;
}


/* vorige Person zeigen */
function previous(){
  if (timeDiff > 0) counter--;
  counter--;
  wait = false;
  preloadPersonPic();
}


/* nächste Person zeigen */
function next(){
  if (timeDiff == 0) counter++;
  wait = false;
  preloadPersonPic();
}


/* zeigt die Kontroll-Leiste (für eine gewisse Zeit) */
function showBar(toggle){
  startShow = new Date();
  document.getElementById("leiste").className = "";
  window.setTimeout("hideBar(true)",3500);
}


/* versteckt die Kontroll-Leiste (automatisch) */
function hideBar(control){
  var today = new Date();
  var diff = (today - startShow);
  if (control==false || control==true && diff >= 3500)
  document.getElementById("leiste").className = "blind";
}


/* beim Laden werden die Personen initialisiert (mit dem automatischen Starten der Personen-Diashow), die Kontroll-Leiste erzeugt und die Ereignisse registriert */
function init(){
  initPersons(0, 0);
  
  var div = document.createElement("div");
  var attr = document.createAttribute("id");
  attr.nodeValue = "leiste";
  div.setAttributeNode(attr);
  
  var div2 = document.createElement("div");
  
  var a = document.createElement("a");
  var attr = document.createAttribute("id");
  attr.nodeValue = "slow";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("href");
  attr.nodeValue = "javascript:slow()";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Befehl: Langsamer";
  a.setAttributeNode(attr);
  var img = document.createElement("img");
  var attr = document.createAttribute("src");
  attr.nodeValue = "../pic/control/slow_b.gif";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("alt");
  attr.nodeValue = "Langsamer";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Langsamer";
  img.setAttributeNode(attr);  
  a.appendChild(img);
  div2.appendChild(a);
  
  var span = document.createElement("span");
  span.className = "blind";
  var text = document.createTextNode(" . ");
  span.appendChild(text);
  div2.appendChild(span);
  
  var a = document.createElement("a");
  var attr = document.createAttribute("id");
  attr.nodeValue = "fast";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("href");
  attr.nodeValue = "javascript:fast()";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Befehl: Schneller";
  a.setAttributeNode(attr);
  var img = document.createElement("img");
  var attr = document.createAttribute("src");
  attr.nodeValue = "../pic/control/fast_b.gif";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("alt");
  attr.nodeValue = "Schneller";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Schneller";
  img.setAttributeNode(attr);  
  a.appendChild(img);
  div2.appendChild(a);
  
  var span = document.createElement("span");
  span.className = "blind";
  var text = document.createTextNode(" . ");
  span.appendChild(text);
  div2.appendChild(span);
  
  var a = document.createElement("a");
  var attr = document.createAttribute("id");
  attr.nodeValue = "pause";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("href");
  attr.nodeValue = "javascript:pause()";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Befehl: Bildershow pausieren";
  a.setAttributeNode(attr);
  var img = document.createElement("img");
  var attr = document.createAttribute("src");
  attr.nodeValue = "../pic/control/pause_b.gif";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("alt");
  attr.nodeValue = "Bildershow pausieren";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Bildershow pausieren";
  img.setAttributeNode(attr);  
  a.appendChild(img);
  div2.appendChild(a);
  
  var span = document.createElement("span");
  span.className = "blind";
  var text = document.createTextNode(" . ");
  span.appendChild(text);
  div2.appendChild(span);
  
  var a = document.createElement("a");
  var attr = document.createAttribute("id");
  attr.nodeValue = "play";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("href");
  attr.nodeValue = "javascript:play()";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Befehl: Bildershow fortsetzen";
  a.setAttributeNode(attr);
  var img = document.createElement("img");
  var attr = document.createAttribute("src");
  attr.nodeValue = "../pic/control/play_b.gif";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("alt");
  attr.nodeValue = "Bildershow fortsetzen";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Bildershow fortsetzen";
  img.setAttributeNode(attr);  
  a.appendChild(img);
  div2.appendChild(a);
  
  var span = document.createElement("span");
  span.className = "blind";
  var text = document.createTextNode(" . ");
  span.appendChild(text);
  div2.appendChild(span);
  
  var a = document.createElement("a");
  var attr = document.createAttribute("id");
  attr.nodeValue = "stop";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("href");
  attr.nodeValue = "javascript:stop()";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Befehl: Bildershow stoppen";
  a.setAttributeNode(attr);
  var img = document.createElement("img");
  var attr = document.createAttribute("src");
  attr.nodeValue = "../pic/control/stop_b.gif";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("alt");
  attr.nodeValue = "Bildershow stoppen";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Bildershow stoppen";
  img.setAttributeNode(attr);  
  a.appendChild(img);
  div2.appendChild(a);
  
  var span = document.createElement("span");
  span.className = "blind";
  var text = document.createTextNode(" . ");
  span.appendChild(text);
  div2.appendChild(span);
  
  var a = document.createElement("a");
  var attr = document.createAttribute("id");
  attr.nodeValue = "previous";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("href");
  attr.nodeValue = "javascript:previous()";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Befehl: Vorherige Person";
  a.setAttributeNode(attr);
  var img = document.createElement("img");
  var attr = document.createAttribute("src");
  attr.nodeValue = "../pic/control/prev_b.gif";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("alt");
  attr.nodeValue = "Vorherige Person";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Vorherige Person";
  img.setAttributeNode(attr);  
  a.appendChild(img);
  div2.appendChild(a);
  
  var span = document.createElement("span");
  span.className = "blind";
  var text = document.createTextNode(" . ");
  span.appendChild(text);
  div2.appendChild(span);
  
  var a = document.createElement("a");
  var attr = document.createAttribute("id");
  attr.nodeValue = "next";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("href");
  attr.nodeValue = "javascript:next()";
  a.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Befehl: Nächste Person";
  a.setAttributeNode(attr);
  var img = document.createElement("img");
  var attr = document.createAttribute("src");
  attr.nodeValue = "../pic/control/next_b.gif";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("alt");
  attr.nodeValue = "Nächste Person";
  img.setAttributeNode(attr);
  var attr = document.createAttribute("title");
  attr.nodeValue = "Nächste Person";
  img.setAttributeNode(attr);  
  a.appendChild(img);
  div2.appendChild(a);
  
  div.appendChild(div2);
  
  document.getElementById("person").appendChild(div);
  
  document.getElementById("play").className = "blind";
  hideBar(false);
  
  document.getElementById("pic").onmouseover   = showBar;
  document.getElementById("leiste").onmouseover   = showBar;
  document.onblur = hideBar;
  //window.onresize = function(){changePicSize();}
  document.getElementById("adr").onmouseout  = hideBar;
}

//-->