var efa_default = 101;  // = Ausgangsgröße in % / sh. body-Definition
var efa_increment = 10;	//  %-Schritte, um die die Schriftgr. vergrößert / verkleinert wird
var efa_bigger = ['',  //  HTML: li-Anfang steht schon in der Seite
				  'Schrift gr&ouml;sser', //HTML - Text
				  'Schrift vergr&ouml;&szlig;ern / plus',	//HTML inside anchor tag: title attribute
				  '',											//class
				  '',											//id
				  '',											//name
				  '+',									//accesskey
          '',											//tabindex
				  '',											//onmouseover
				  '',											//onmouseout
				  '',											//onfocus
					'&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;</li>'	//HTML nach Link -> Abstand zum nächsten Link
				  ]
var efa_reset = ['<li>',
				 'Schrift normal',
				 'Schriftgr&ouml;&szlig;en zur&uuml;cksetzen auf Ausgangsgr&ouml;&szlig;e',
				  '',											//
				  '',											//id
				  '',											//name
				  '=',										//accesskey
          '',											//tabindex
				  '',											//onmouseover
				  '',											//onmouseout
				  '',											//onfocus
				  '&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;</li>'	//HTML nach 'normal' (reset) Link
				  ]
var efa_smaller = ['<li>',
				   'Schrift kleiner',
				   'Schrift verkleinern / minus',
				   '',											//class attribute
				   '',											//id attribute
				   '',											//name attribute
				   '-',											//accesskey attribute
           '',											//tabindex attribute
				   '',											//onmouseover attribute
				   '',											//onmouseout attribute
				   '',											//onfocus attribute
           ''						//HTML nach Link (Ende) steht schon in der Seite
				   ]
function Efa_Fontsize(increment,bigger,reset,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.isOldOpfake = ((this.userAgent.indexOf('opera') != -1)&&(parseFloat(this.userAgent.substr(this.userAgent.indexOf('opera')+5)) <= 7));
//for proper Opera dedection if Operas User Agent Switching is aktive - added by grishan Jan. 2006
	this.isOldOpreal = ((this.userAgent.indexOf('opera') != -1)&&(parseFloat(this.userAgent.substr(this.userAgent.indexOf('opera')+6)) <= 7));
  if ((this.w3c || this.ms) && !this.isOldOpfake && !this.isMacIE && !this.isOldOpreal) {
		this.name = "efa_fontSize";
		this.cookieName = 'efaSize';
		this.increment = increment;
		this.def = def;
		this.defPx = Math.round(16*(def/100))
		this.base = 1;
		this.pref = this.getPref();
		this.testHTML = '<div id="efaTest" style="position:absolute;visibility:hidden;line-height:1em;">&nbsp;</div>';
		this.biggerLink = this.getLinkHtml(1,bigger);
		this.resetLink = this.getLinkHtml(0,reset);
    this.smallerLink = this.getLinkHtml(-1,smaller);
	} // set up an onlunload handler to save the user's font size preferences:
  else {
/* set link html properties to an empty string so the links don't show up in unsupported browsers: */
		this.biggerLink = '';
		this.resetLink = '';
    this.smallerLink = '';
		this.efaInit = new Function('return true;');
	}
	this.allLinks = this.biggerLink + this.resetLink + this.smallerLink;
}
Efa_Fontsize.prototype.efaInit = function() {
	document.writeln(this.testHTML);
	this.body = (this.w3c)?document.getElementsByTagName('body')[0].style:document.all.tags('body')[0].style;
	this.efaTest = (this.w3c)?document.getElementById('efaTest'):document.all['efaTest'];
	var h = (this.efaTest.clientHeight)?parseInt(this.efaTest.clientHeight):(this.efaTest.offsetHeight)?parseInt(this.efaTest.offsetHeight):999;
/* check that the current base size is at least as large as the browser default (16px) adjusted by our base percentage; if not, divide 16 by the base size and multiply our base multiplier by the result to compensate */
	if (h < this.defPx) this.base = this.defPx/h;
/* set the body font size to the appropriate percentage so the user gets the font size they selected or our default if they haven't chosen one */
	this.body.fontSize = Math.round(this.pref*this.base) + '%';
}
Efa_Fontsize.prototype.getLinkHtml = function(direction,properties) {
	var html = properties[0] + '<a href="javascript:void(0);" onclick="efa_fontSize.setSize(' + direction + '); return false;"';
// attribute + value verknüpfen:
	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])?'tabindex="' + properties[7] + '"':'';
	html += (properties[8])?'onmouseover="' + properties[8] + '"':'';
	html += (properties[9])?'onmouseout="' + properties[9] + '"':'';
	html += (properties[10])?'onfocus="' + properties[10] + '"':'';
	return html += '>'+ properties[1] + '<' + '/a>' + properties[11];
}
// get the saved preferences out of the cookie, if any
Efa_Fontsize.prototype.getPref = function() {
	var pref = this.getCookie(this.cookieName);
	if (pref) return parseInt(pref); // if no cookie value, return the default:
	else return this.def;
}
// change the text size; expects a direction parameter of 1 (increase size), -1 (decrease size)
// or 0 (reset to default):
Efa_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) + '%';
}
Efa_Fontsize.prototype.getCookie = function(cookieName) {
	var cookie = cookieManager.getCookie(cookieName);
	return (cookie)?cookie:false;
}
Efa_Fontsize.prototype.setCookie = function(cookieName,cookieValue) {
	return cookieManager.setCookie(cookieName,cookieValue);
}
var efa_fontSize = new Efa_Fontsize(efa_increment,efa_bigger,efa_reset,efa_smaller,efa_default);
