// -- start:Zooming stuff --------------------------------------------------------

// variable for ie browsers
var defaultZoomFactor = 1;

// variables for non-ie browsers (the zooming is done by setting the body.font-size)
var defaultFontSize = 62.5;
var fontSizeChangeSteps = 21;
var maxFontSize = 300;
var minFontSize = 10;

//Ausgangs-Zoomfaktor setzen (sind entweder schon im cookie, ansonsten nehmen wir die defaults values)
var size=get_ZoomCookie();

// schreiben des zoom style-Elements
writeStyleSize();

// Ausgabe des zoom style-Elements direkt in die html-seite
function writeStyleSize() {
  document.writeln('<style type="text/css">');
  if (isIE()) {
    document.writeln('body{zoom:'+size+';}');
  } else  {
    document.writeln('body{font-size:'+size+'%;}');
    //document.writeln('.large{font-size:'+size+'%;}');
  }
  document.writeln('</style>');
}

// hineinzoomen (vergrössern)
function increaseFontSize() {
  if (isIE()) {
    // IE (use body.style.zoom)
    // increase
    size *= 1.2;
    document.body.style.zoom=size;
    // save new val in cookie
    set_ZoomCookie(size);
  } else {
    // non IE (use body.style.fontSize)
    // increase
    if (size < maxFontSize) {
      size += fontSizeChangeSteps;
      document.body.style.fontSize = size+"%"
      // save new val in cookie
      set_ZoomCookie(size);
    }
  }
}

// herauszoomen (verkleinern)
function decreaseFontSize() {
  if (isIE()) {
    // IE (use body.style.zoom)
    // decrease
    size /= 1.2;
    document.body.style.zoom=size;
    // save the new (zoom, bzw. fontSize) val in cookie
    set_ZoomCookie(size);
  } else {
    // non IE
    // decrease (use body.style.fontSize)
    if (size > minFontSize) {
      size -= fontSizeChangeSteps;
      document.body.style.fontSize = size+"%"
      // save the new (zoom, bzw. fontSize) val in cookie
      set_ZoomCookie(size);
    }
  }

}

// sets the cookie 'zoom' with the zooming factor
function set_ZoomCookie(size) {
  objNow=new Date();
  intExp=2592000000;
  objExp=new Date(objNow.getTime()+intExp);
  document.cookie='zoom='+size+'; path=/; expires='+objExp.toGMTString()+';';
}

// reads the value of the cookie 'zoom' (contains the zooming factor)
// if no cookie is set yet, return the default value
function get_ZoomCookie() {
  // set the default values
  (isIE())?size=defaultZoomFactor:size=defaultFontSize;

  // try to read value out of the cookie
  if(strCookie=document.cookie) {
    if(arrCookie=strCookie.match(/zoom=\d+\.?\d*/)) {
      arrZoomCookie=arrCookie[0].split('=');
      size=Number(arrZoomCookie[1]);
    }
  }
  return(size);
}

function isIE() {
  //return (document.all && !window.opera);
  // im moment nutzen wir die zoom-strategie via font-size, weil es via zoom
  // probleme mit wicket gibt: dort wird das automatische dropdown an die falsche
  // stelle gerendert, weil es mittels fixer pixel positioniert wird.
  return false;
}

// -- end:Zooming stuff --------------------------------------------------------
