//addonload function
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
;
//funktion hover
function zeigen (bild) {
if(window.navigator.systemLanguage && !window.navigator.language) {
document.getElementById(bild).firstChild.firstChild.firstChild.style.visibility = "visible";
}
}
function weg (bild) {
if(window.navigator.systemLanguage && !window.navigator.language) {
document.getElementById(bild).firstChild.firstChild.firstChild.style.visibility = "hidden";
}
}
//menuehover,
if(window.navigator.systemLanguage && !window.navigator.language) {
  function hoverIE() {
    var LI = document.getElementById("menue").firstChild;
    do {
      if (sucheUL(LI.firstChild)) {
        LI.onmouseover=einblenden; LI.onmouseout=ausblenden;
      }
      LI = LI.nextSibling;
    }
    while(LI);
  }

  function sucheUL(UL) {
    do {
      if(UL) UL = UL.nextSibling;
      if(UL && UL.nodeName == "UL") return UL;
    }
    while(UL);
    return false;
  }

  function einblenden() {
    var UL = sucheUL(this.firstChild);
    UL.style.display = "block"; UL.style.backgroundColor = "#FFFFFF";
  }
  function ausblenden() {
    sucheUL(this.firstChild).style.display = "none";
  }

  addLoadEvent(hoverIE);
}
//funktion fuer externen Link
function blanktarget (externerlink) {
  blank1 = window.open(externerlink, "Externerlink", "location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes");
  blank1.focus();
}

// variablen fuern Styleswitcher
var Stil = "Standard";
var Keks = "Layout";
var Tage = 365;

// Style Switcher

function switchStyle(s) {
  if (!document.getElementsByTagName) return;
  var el = document.getElementsByTagName("link");
  for (var i = 0; i < el.length; i++ ) {
    if (el[i].getAttribute("rel").indexOf("style") != -1 && el[i].getAttribute("title")) {
      el[i].disabled = true;
      if (el[i].getAttribute("title") == s) el[i].disabled = false;
    }
  }
}

function loadStyle() {
  var c = getStyleCookie();
  if (c && c != Stil) {
    switchStyle(c);
    Stil = c;
  }
}

function setStyle(s) {
  if (s != Stil) {
    switchStyle(s);
    Stil = s;
    setStyleCookie();
  }
}

addLoadEvent(loadStyle);


// Cookie-Funktionen

function setCookie(name, value, expdays) {   // gültig expdays Tage
  var now = new Date();
  var exp = new Date(now.getTime() + (1000*60*60*24*expdays));
  document.cookie = name + "=" + escape(value) + ";" +
                    "expires=" + exp.toGMTString() + ";" +
                    "path=/";
}

function delCookie(name) {   // expires ist abgelaufen
  var now = new Date();
  var exp = new Date(now.getTime() - 1);
  document.cookie = name + "=;" +
                    "expires=" + exp.toGMTString() + ";" + 
                    "path=/";
}

function getCookie(name) {
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    var start = dc.indexOf(cname);
    if (start != -1) {
      start += cname.length;
      var stop = dc.indexOf(";", start);
      if (stop == -1) stop = dc.length;
      return unescape(dc.substring(start,stop));
    }
  }
  return null;
}

function setStyleCookie() {
  setCookie(Keks, Stil, Tage);
}

function getStyleCookie() {
  return getCookie(Keks);
}

function delStyleCookie() {
  delCookie(Keks);
}
//Startfunktion
function setStartCookie(sprache) {
  setCookie(sprachkeks, sprache, sprachzeit);
}

function getStartCookie() {
  return getCookie(sprachkeks);
}

function delStartCookie() {
  delCookie(sprachkeks);
}

var sprache = "keine";
var sprachkeks = "Sprache";
var sprachzeit = 365;
function sprachcookie() {
  if ((document.URL == 'http://www.franzenshoehe.com/') || (document.URL == 'http://www.franzenshoehe.com/index.php') || (document.URL == 'http://franzenshoehe.com/index.php') || (document.URL == 'http://franzenshoehe.com/')) {
    language = getStartCookie();
    if (language != null) {sprache = language;}
    if (sprache != 'keine') {
          window.location.href = "./"+sprache+"/index.php";
    }
  }
}
addLoadEvent(sprachcookie);
