var efa_default = 63;
var efa_increment = 10;
var efa_smaller = ['<div class=\"sub-b\">Schrift: ',
				   'kleiner',								//HTML to go before 'smaller' link
				   'Schrift kleiner stellen',			//HTML to go inside 'smaller' anchor tag
				   '',										//class attribute
				   '',										//id attribute
				   '',										//name attribute
				   '',										//accesskey attribute
				   '',										//onmouseover attribute
				   '',										//onmouseout attribute
				   '',										//onfocus attribute
				   ' | '									//HTML to go after 'smaller' link
				   ]

var efa_reset = ['',
				 'zur&uuml;cksetzen',					//HTML to go before 'reset' link
				 'Schriftgr&ouml;&szlig;e normal',	//HTML to go inside 'reset' anchor tag
				  '',											//class attribute
				  '',											//id attribute
				  '',											//name attribute
				  '',											//accesskey attribute
				  '',											//onmouseover attribute
				  '',											//onmouseout attribute
				  '',											//onfocus attribute
				  ' | '											//HTML to go after 'reset' link
				  ]
				  				   

				  

var efa_bigger = ['',		//HTML to go before 'bigger' link
				  'gr&ouml;&szlig;er',				//HTML to go inside 'bigger' anchor tag
				  'Schrift gr&ouml;sser stellen',	//title attribute
				  '',										//class attribute
				  '',											//id attribute
				  '',											//name attribute
				  '',											//accesskey attribute
				  '',											//onmouseover attribute
				  '',											//onmouseout attribute
				  '',											//onfocus attribute
				  '</div>'											//HTML to go after 'bigger' link
				  ]
				  
// MP20071116: so erweitert, dass der fontsizer in mehreren documents greift (noetig fuer frameset)
if (!efa_changetargets){
	var efa_changetargets = new Array('document');
}





function Efa_Fontsize06(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.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 = 'fontSize';
		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);
	} else {
		this.biggerLink = '';
		this.resetLink = '';
		this.smallerLink = '';
		this.efaInit = new Function('return true;');
	}

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

Efa_Fontsize06.prototype.efaInit = function() {
		document.writeln(this.testHTML);
		// MP20071116: frameset-erweiterung
		this.body = this.getBodyRef(eval(efa_changetargets[0]));
		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) + '%';
}

// MP20071116: toolfunktion fuer frameset-erweiterung
Efa_Fontsize06.prototype.getBodyRef = function(doc){
	return (this.w3c)?doc.getElementsByTagName('body')[0].style:doc.all.tags('body')[0].style;
}

// MP20071116: toolfunktion fuer frameset-erweiterung
// kann aus fremdem frame (ohne anpassen-links) aufgerufen werden zum nachtraeglichen initialisieren
Efa_Fontsize06.prototype.initForeignFrame = function(doc) {	
	this.getBodyRef(doc).fontSize = Math.round(this.pref*this.base) + '%';
}

Efa_Fontsize06.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_Fontsize06.prototype.getPref = function() {
	var pref = this.getCookie();
	if (pref) return parseInt(pref);
	else return this.def;
}

Efa_Fontsize06.prototype.setSize = function(direction) {
	this.pref = (direction)?this.pref+(direction*this.increment):this.def;
	this.setCookie(this.pref);
	
	// MP20071116: frameset-erweiterung
	for (i=0; i<efa_changetargets.length; i++){
		this.getBodyRef(eval(efa_changetargets[i])).fontSize = Math.round(this.pref*this.base) + '%';
	}
	//this.body.fontSize = Math.round(this.pref*this.base) + '%';
}

Efa_Fontsize06.prototype.getCookie = function() {
	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_Fontsize06.prototype.setCookie = function(cookieValue) {
	var date = new Date();
	date.setTime(date.getTime()+(7*24*60*60*1000));	
	cookies = this.cookieName + '=' + cookieValue + '; path=/; expires=' + date.toGMTString();
	document.cookie = cookies;
}

var  efa_fontSize = new Efa_Fontsize06(efa_increment,efa_bigger,efa_reset,efa_smaller,efa_default);
