var sb_default = 90;
var sb_increment = 10;
var sb_bigger = ['',
'<img src="http://cms.monheimer-alb.de/design/corporate_site/images/a_gross.gif" border="0" title="Schrift vergr&ouml;&szlig;ern" alt="Schrift vergr&ouml;&szlig;ern" '+'/>',
'',
'sizeup',
'',
'',
'',
'',
'',
'',
''
]

var sb_smaller = ['',
'<img src="http://cms.monheimer-alb.de/design/corporate_site/images/a_klein.gif" border="0" title="Schrift verkleinern" alt="Schrift verkleinern" '+'/>',
'',
'sizedown',
'',
'',
'',
'',
'',
'',
''
]

function SB_Fontsize(increment, bigger, smaller, def) {
  this.w3c = (document.getElementById);
  this.ms = (document.all);
  this.userAgent = navigator.userAgent.toLowerCase();
  this.isMacIE = ((this.userAgent.indexOf('msie') != -1) && (this.userAgent.indexOf('mac') != -1) && (this.userAgent.indexOf('opera') == -1));
  this.isOldOp = ((this.userAgent.indexOf('opera') != -1)&&(parseFloat(this.userAgent.substr(this.userAgent.indexOf('opera')+5)) <= 7));

  if ((this.w3c || this.ms) && !this.isOldOp && !this.isMacIE) {
    this.name = "sb_fontSize";
    this.cookieName = 'sbSize';
    this.increment = increment;
    this.def = def;
    this.defPx = Math.round(16*(def/100))
    this.base = 1;
    this.pref = this.getPref();
    this.testHTML = '<div id="sbTest" style="position:absolute;visibility:hidden;line-height:1em;">&nbsp;</div>';
    this.biggerLink = this.getLinkHtml(1,bigger);
//    this.resetLink = '&nbsp;&nbsp;<a href="#" onclick="sb_fontSize.setSize(0); return false;" class="sizenormal"><img src="/design/plain/images/a_mittel.gif" border="0" title="zur&uuml;ck zur Grundeinstellung" alt="zur&uuml;ck zur Grundeinstellung" /></a>&nbsp;&nbsp;';
    this.resetLink = '&nbsp;&nbsp;';
    this.smallerLink = this.getLinkHtml(-1,smaller);

  } else {

    this.biggerLink = '';
    this.resetLink = '';
    this.smallerLink = '';
    this.sbInit = new Function('return true;');
  }

  this.allLinks = this.smallerLink + this.resetLink + this.biggerLink;
}

SB_Fontsize.prototype.sbInit = function() {
  document.writeln(this.testHTML);
  this.body = (this.w3c)?document.getElementsByTagName('body')[0].style:document.all.tags('body')[0].style;
  this.sbTest = (this.w3c)?document.getElementById('sbTest'):document.all['sbTest'];
  var h = (this.sbTest.clientHeight)?parseInt(this.sbTest.clientHeight):(this.sbTest.offsetHeight)?parseInt(this.sbTest.offsetHeight):999;
  if (h < this.defPx)
    this.base = this.defPx/h;
  // Die folgende Zeile sorgt für unterschiedliche Grund-Schriftgrößen auf unterschiedlichen Systemen...
  //this.body.fontSize = Math.round(this.pref*this.base) + '%';
  //alert(this.body.fontSize);
}

SB_Fontsize.prototype.getLinkHtml = function(direction, properties) {
  var html = properties[0] + '<a href="#" onclick="sb_fontSize.setSize(' + direction + '); return false;"';
  html += (properties[2])?'title="' + properties[2] + '"':'';
  html += (properties[3])?'class="' + properties[3] + '"':'';
  html += (properties[4])?'id="' + properties[4] + '"':'';
  html += (properties[5])?'name="' + properties[5] + '"':'';
  html += (properties[6])?'accesskey="' + properties[6] + '"':'';
  html += (properties[7])?'onmouseover="' + properties[7] + '"':'';
  html += (properties[8])?'onmouseout="' + properties[8] + '"':'';
  html += (properties[9])?'onfocus="' + properties[9] + '"':'';
  return html += '>'+ properties[1] + '<' + '/a>' + properties[10];
}

SB_Fontsize.prototype.getPref = function() {
  var pref = this.getCookie(this.cookieName);
  if (pref)
    return parseInt(pref);
  else
    return this.def;
}

SB_Fontsize.prototype.setSize = function(direction) {
  this.pref = (direction)?this.pref+(direction*this.increment):this.def;
  this.setCookie(this.cookieName,this.pref);
  this.body.fontSize = Math.round(this.pref*this.base) + '%';
}

SB_Fontsize.prototype.getCookie = function(cookieName) {
  var cookie = cookieManager.getCookie(cookieName);
  return (cookie)?cookie:false;
}

SB_Fontsize.prototype.setCookie = function(cookieName,cookieValue) {
  return cookieManager.setCookie(cookieName,cookieValue);
}

var sb_fontSize = new SB_Fontsize(sb_increment, sb_bigger, sb_smaller, sb_default);
