var prefsLoaded = false;
var defaultFontSize = 100;
if (document.cookie){
  cookie_values = document.cookie;
  
  arr_cookie_values = cookie_values.split('; ');
  
  el_count = arr_cookie_values.length;
  for (i=0; i<=(el_count-1); i++){
    var_cookie = arr_cookie_values[i].split('=');
    var_cookie_name = var_cookie[0];
    var_cookie_value = var_cookie[1];
    if (var_cookie_name == 'currentFontSize') defaultFontSize = var_cookie_value;
  } //for
} //if
var currentFontSize = defaultFontSize;
function revertStyles(){
    currentFontSize = defaultFontSize;
    changeFontSize(0);
}
function changeFontSize(sizeDifference){
    
  
// alert(currentFontSize);
  if (sizeDifference ==  1) {
    document.getElementsByName("font_down")[0].src = "/seerenaden/app/z_system_images/font_minus.gif";
    if (currentFontSize < 170) {currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5); }
    if (currentFontSize >= 170) {
      currentFontSize = parseInt(currentFontSize) - parseInt(sizeDifference * 5);
      document.getElementsByName("font_up")[0].src = "/seerenaden/app/z_system_images/font_plus_inaktiv.gif";
    }
  }
  if (sizeDifference == -1) {
    document.getElementsByName("font_up")[0].src = "/seerenaden/app/z_system_images/font_plus.gif";
    if (currentFontSize > 95) {currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);}
    if (currentFontSize <= 95) {
      currentFontSize = parseInt(currentFontSize) - parseInt(sizeDifference * 5);
      document.getElementsByName("font_down")[0].src = "/seerenaden/app/z_system_images/font_minus_inaktiv.gif";
    }
  }
  
    setFontSize(currentFontSize);
    var datum = new Date();
    var ablauf = datum.getTime() + (180 * 60 * 1000);
    datum.setTime(ablauf);
  
    var cookie_string = "expires="+datum.toGMTString(); 
    document.cookie = cookie_string;
  
    cookie_string = "currentFontSize="+currentFontSize;
    document.cookie = cookie_string;
};
function setFontSize(fontSize){
/*
    var stObj = (document.getElementById) ? document.getElementById('maincontent') : document.all('maincontent');
    document.body.style.fontSize = fontSize + '%';
*/
    d_style('maincontent').fontSize = fontSize + '%';
    
    //alert (document.body.style.fontSize);
};
/* 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 nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
};
window.onload = setUserOptions;
function setUserOptions(){
    if(!prefsLoaded){
        cookie = readCookie("fontSize");
        currentFontSize = cookie ? cookie : defaultFontSize;
        setFontSize(currentFontSize);
        
        prefsLoaded = true;
    }
}
window.onunload = saveSettings;
function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
}*/