function init() {
  if (self.checkIcon) checkIcon();
  if (self.textSizeOnLoad) textSizeOnLoad();
  if (self.languageNavOnLoad) languageNavOnLoad();
  try {
    document.execCommand("BackgroundImageCache", false, true);
  } catch(err) {}
}
function uninit() {
  if (self.textSizeOnUnload){textSizeOnUnload();}
}
function textSizeOnUnload() {
  var currentStyleSheet = getActiveStyleSheet();
  createCookie("currentStyleSheet", currentStyleSheet, 365);
}
{
  textminus0 = new Image();
  textminus0.src = "http://www.serengeti.ch/docroot/pics/text-minus-null.gif";
  textminus1 = new Image();
  textminus1.src = "http://www.serengeti.ch/docroot/pics/text-minus.gif";

  textplus0 = new Image();
  textplus0.src = "http://www.serengeti.ch/docroot/pics/text-plus-null.gif";
  textplus1 = new Image();
  textplus1.src = "http://www.serengeti.ch/docroot/pics/text-plus.gif";
}
//initialize pictures
var styleSheet1 = 'A--';
var styleSheet2 = 'A-';
var styleSheet3 = 'A';

//initialize to default style sheet when there is no cookie
function getPreferredStyleSheet() {
  return (styleSheet1);
}
function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}
function createCookie(name,value,days) {
  var date, expires;
  if (days) {
    date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
//read cookie
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  var c;
  
  for(var i=0;i < ca.length;i++) {
    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;
}
//check cookie is there or not
var cookie = readCookie("currentStyleSheet");
var currentStyleSheet = cookie ? cookie : getPreferredStyleSheet();
if (currentStyleSheet == 'null') {
  currentStyleSheet = getPreferredStyleSheet();
}
function setActiveStyleSheet(title) {
  var i, a, main;
  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;
    }
  }
}
//body onload functions
function checkIcon() {
//alert("currentStyleSheet:"+currentStyleSheet+"\n"+"styleSheet1:"+styleSheet1);
 if (currentStyleSheet == styleSheet1) {
    document.images['text-minus'].src = textminus0.src;
	document.images['text-plus'].src = textplus1.src;
  }
  if (currentStyleSheet != styleSheet1) {
    document.images['text-minus'].src = textminus1.src;
	document.images['text-plus'].src = textplus1.src;
  }
  if (currentStyleSheet == styleSheet3) {
    document.images['text-plus'].src = textplus0.src;
  }
}
function textSizeOnLoad() {
  var cookie = readCookie("currentStyleSheet");
  var currentStyleSheet = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(currentStyleSheet);
}
function fontSizeUp() {
  var active = getActiveStyleSheet();
  switch (active) {
    case styleSheet1 :
      setActiveStyleSheet(styleSheet2);
      document.images['text-minus'].src = textminus1.src;
      document.images['text-plus'].src = textplus1.src;
      break;
    case styleSheet2 :
      setActiveStyleSheet(styleSheet3);
      document.images['text-minus'].src = textminus1.src;
      document.images['text-plus'].src = textplus0.src;
      break;
    case styleSheet3 :
      document.images['text-minus'].src = textminus1.src;
      document.images['text-plus'].src = textplus0.src;
      break;
    default :
      setActiveStyleSheet(styleSheet1);
      document.images['text-minus'].src = textminus0.src;
      document.images['text-plus'].src = textplus1.src;;
      break;
  }
}
function fontSizeDown() {
  var active = getActiveStyleSheet();
  switch (active) {
    case styleSheet3 :
      setActiveStyleSheet(styleSheet2);
      document.images['text-minus'].src = textminus1.src;
      document.images['text-plus'].src = textplus1.src;
      break;
    case styleSheet2 :
      setActiveStyleSheet(styleSheet1);
      document.images['text-minus'].src = textminus0.src;
      document.images['text-plus'].src = textplus1.src;
      break;
    case styleSheet1 :
      document.images['text-minus'].src = textminus0.src;
      document.images['text-plus'].src = textplus1.src;
       break;
    default :
      setActiveStyleSheet(styleSheet1);
      document.images['text-minus'].src = textminus0.src;
      document.images['text-plus'].src = textplus1.src;
      break;
  }
}
setActiveStyleSheet(currentStyleSheet);