var efa_default = 63;
var efa_increment = 10;
var efa_maxsteps = 10;
var efa_max = efa_default+(efa_increment*efa_maxsteps);

var efa_bigger = ['&nbsp;',
				  '<img src="'+rel2rootweb+'img/v07/basics/icon_fontsize_bigger.gif" alt="Schrift gr&ouml;&szlig;er stellen" />',
				  'Schrift gr&ouml;&szlig;er stellen',
				  'font-bigger',
				  '',
				  '',
				  '',
				  '',
				  '',
				  '',
				  '</p>'
				  ]

var efa_reset = ['',
				 '=',
				 'Schriftgr&ouml;&szlig;e normal',
				  'font-reset',
				  '',
				  '',
				  '',
				  '',
				  '',
				  '',
				  ''
				  ]

var efa_smaller = ['<p class="fontsizer">Schriftgr&ouml;&szlig;e:</p> <p>',
				   '<img src="'+rel2rootweb+'img/v07/basics/icon_fontsize_smaller.gif" alt="Schrift kleiner stellen" />',
				   'Schrift kleiner stellen',
				   'font-smaller',
				   '',
				   '',
				   '',
				   '',
				   '',
				   '',
				   ''
				   ]

var efa_biggerNL = ['&nbsp;',
				  '<img src="'+rel2rootweb+'img/newsletter/icon_font_bigger.gif" alt="Schrift gr&ouml;&szlig;er stellen" width="13" height="13" style="border:0;" />',
				  'Schrift gr&ouml;&szlig;er stellen',
				  'font-bigger',
				  '',
				  '',
				  '',
				  '',
				  '',
				  '',
				  ''
				  ]
var efa_smallerNL = ['Schriftgr&ouml;&szlig;e: ',
				   '<img src="'+rel2rootweb+'img/newsletter/icon_font_smaller.gif" alt="Schrift kleiner stellen" width="13" height="13" style="border:0;" />',
				   'Schrift kleiner stellen',
				   'font-smaller',
				   '',
				   '',
				   '',
				   '',
				   '',
				   '',
				   ''
				   ]


function Efa_Fontsize(increment,bigger,reset,smaller,biggerNL,smallerNL,def,max) {
	this.w3c = (document.getElementById);
	this.ms = (document.all);
	this.userAgent = navigator.userAgent.toLowerCase();
	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 = "efa_fontSize";
		this.cookieName = 'watSize';
		this.increment = increment;
		this.def = def;
		this.max = max;
		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);
		this.biggerLinkNL = this.getLinkHtml(1,biggerNL);
		this.smallerLinkNL = this.getLinkHtml(-1,smallerNL);
	} else {
		this.biggerLink = '';
		this.resetLink = '';
		this.smallerLink = '';
		this.biggerLinkNL = '';
		this.smallerLinkNL = '';
		this.efaInit = new Function('return true;');
	}
	this.allLinks = this.smallerLink  + this.biggerLink; // + this.resetLink
	this.allLinksNL = this.smallerLinkNL  + this.biggerLinkNL;
}
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;
		if (h < this.defPx) this.base = this.defPx/h;
		this.body.fontSize = Math.round(this.pref*this.base) + '%';
}
Efa_Fontsize.prototype.getLinkHtml = function(direction,properties) {
	var html = properties[0] + '<a href="#" onclick="efa_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];
}
Efa_Fontsize.prototype.getPref = function() {
	var pref = this.getCookie(this.cookieName);
	if (pref) return parseInt(pref);
	else return this.def;
}
Efa_Fontsize.prototype.setSize = function(direction) {
	if (this.pref<this.max || direction<=0) {
		this.pref = (direction)?this.pref+(direction*this.increment):this.def;
		this.setCookie(this.cookieName,this.pref);
		// set the text size
		this.body.fontSize = Math.round(this.pref*this.base) + '%';
	}
}
Efa_Fontsize.prototype.getCookie = function(cookieName) {
	var back 	= false;
	var cookies = document.cookie.split(';');
	var len = cookies.length;
	for(var i=0;i < len;i++) {
		cookie = cookies[i];		
		while (cookie.charAt(0)==' ') cookie = cookie.substring(1,cookie.length);
		pair = cookie.split('=');
		if (pair[0] == this.cookieName) back = pair[1];		
	}
	return back;
}
Efa_Fontsize.prototype.setCookie = function(cookieName,cookieValue) {
	//cookies = document.cookie;
	var date = new Date();
	date.setTime(date.getTime()+(7*24*60*60*1000));	
	cookies = cookieName + '=' + cookieValue + '; path=/; expires=' + date.toGMTString();
	document.cookie = cookies;
}
var  efa_fontSize = new Efa_Fontsize(efa_increment,efa_bigger,efa_reset,efa_smaller,efa_biggerNL,efa_smallerNL,efa_default,efa_max);