var zaehler = null;
var title;

function styleswitch(count){
 var styles = new Array("standard","mittel","gross", "groesser");
 if (title != "default"){
  for(var i=0;i < styles.length;i++){
   if (title == styles[i]){
    zaehler = i;
   }
  }
 }
 
 if (count=="pos"){
     if (zaehler >= 3)
     {zaehler=3;}
  else 
         {zaehler++;}
   }
   if (count == "neg"){
     if (zaehler <= 0)
     {zaehler=0;}
  else 
         {zaehler--;}
 }
        title= styles[zaehler];
 setActiveStyleSheet(title);
}

function setActiveStyleSheet(title) {
  var i, a, main;
  document.getElementById("display").src="http://www.nvv.de/fileadmin/nvv/layout/schriftgoesse_mitte_"+title+".gif";

  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title ) a.disabled = false;
    }
  }
  createCookie("style",title,365)
}


function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}


function readCookie(name) {
    var ca = document.cookie.split(';');
    var found = -1;
    for(var i=0; i < ca.length; i++) {
        if (ca[i].match(/\bstyle=\b/g)) {
            found = i;
        }
    }
    if(found >= 0 && ca[found]) {
        var c = ca[found];
        var wert = c.split('=');
        if ((wert[1] == "mittel") || (wert[1] == "gross") || (wert[1] == "groesser")) {
            title = wert[1];
        } else{
            title = "standard";
        }
        setActiveStyleSheet(title);
    }
    return null;
} 