/*
	(c) 2002 functionNewMedia, Inc.

	The script may distributed and used freely, provided the above
	copyright notice remains intact and the both the script and this
	readme file are distributed together and unaltered.

	Send bug reports, comments, questions or requests to:

	c.kaminski@function.de
*/

/*
	To implement this script in your Web page, configure this file as
	shown below, then put this file on your Web server.
	
	Next, insert the following at the beginning of the <head> section
	of your Web page:

		<script language="javascript" type="text/javascript" src="[path]fun_fontsize.js"></script>

	where [path] is the path to this file on your server.
	
	Insert the following at the end of the <head> section of your after
	any style declarations (such as <style> tags or <link> tags importing
	external stylesheets):

		<script language="javascript" type="text/javascript">
			if (fun_fontSize) document.write(fun_fontSize.style);
		</script>
	
	Finally, insert the following where you wish the links to change the
	text size to appear: 

		<script language="javascript" type="text/javascript">
			document.write(fun_fontSize.allLinksHtml);
		</script>
*/

/*
	fun_baseSize = font size in pixels
	fun_increment = number of pixels each click increases/decreases size
	fun_bigger = array of properties for 'increase font size' link
	fun_reset = array of properties for 'reset font size' link
	fun_smaller = array of properties for 'decrease font size' link

	properties array format:
		['before HTML',
		 'inside HTML',
		 'title text',
		 'class text',
		 'id text',
		 'name text',
		 'accesskey text',
		 'onmouseover JavaScript',
		 'onmouseout JavaScript',
		 'on focus JavaScript',
		 'after HTML'
		 ]
*/

var fun_baseSize = 12;
var fun_increment = 2;

var fun_bigger = ['<td valign="bottom">',
				  '<div class="roundA"><div class="toprightA"><div class="topleftA"></div></div><p class="gross">A</p><div class="bottomrightA"><div class="bottomleftA"></div></div></div>',
				  'Schrift gr&ouml;sser',
				  '',
				  '',
				  '',
				  'g',
				  '',
				  '',
				  '',
				  '</td><tr></table></div> '
				  ]

var fun_reset = ['<td valign="bottom">',
				 '<div class="roundA"><div class="toprightA"><div class="topleftA"></div></div><p class="normal">A</p><div class="bottomrightA"><div class="bottomleftA"></div></div></div>',
				 'Schriftgr&ouml;&szlig;e zur&uuml;ckstellen',
				  '',
				  '',
				  '',
				  'z',
				  '',
				  '',
				  '',
				  '</td><td><img src="/global/show_picture.asp?id=aaaaaaaaaaaadjt" height="1" width="4"></td>'
				  ]

var fun_smaller = ['<div style="width:100%;" align="left" id="schriften"><table border="0" cellpadding="0" cellspacing="0"><tr><td valign="bottom">',
				   '<div class="roundA"><div class="toprightA"><div class="topleftA"></div></div><p class="klein">A</p><div class="bottomrightA"><div class="bottomleftA"></div></div></div>',
				   'Schrift kleiner',
				   '',
				   '',
				   '',
				   'k',
				   '',
				   '',
				   '',
				   '</td><td><img src="/global/show_picture.asp?id=aaaaaaaaaaaadjt" height="1" width="4"></td>'
				   
				   ]
				   

				   
				   

function Fun_fontsize(baseSize,increment,bigger,reset,smaller) {
	this.userAgent = navigator.userAgent.toLowerCase();
	this.w3c = (document.getElementById);
	this.ms = (document.all);
	this.isOp = (this.userAgent.indexOf('opera') != -1);
	this.isMacIe5 = ((this.userAgent.indexOf('msie') != -1) && !this.isOp && this.w3c && (this.userAgent.indexOf('mac') != -1));
	this.isOw = (this.userAgent.indexOf('omniweb') != -1);
	
	if ((this.w3c || this.ms)  && !this.isOw) { //&& !this.isOp && !this.isMacIe5
		this.increment = increment;
		this.baseSize = baseSize;
		this.name = "fun_fontSize";
		this.cookieName = "funfontpref=";
		this.expires = this.getExpiresDate();
		this.domain = this.getDomain();
		this.currentSize = this.getFontPref();
		this.biggerLink = this.getLinkHtml(1,bigger);
		this.resetLink = this.getLinkHtml(0,reset);
		this.smallerLink = this.getLinkHtml(-1,smaller);
		window.onload = new Function(this.name + '.init();');
		window.onunload = new Function(this.name + '.storeFontPref();'
		
		);
	} else {
	
		this.biggerLink = '';
		this.resetLink = '';
		this.smallerLink = '';
	}
	
	this.allLinks = this.biggerLink + this.resetLink + this.smallerLink;
	this.style = this.getStyleHtml(baseSize);
	
}
Fun_fontsize.prototype.init = function() {
	this.body = (this.w3c)?document.getElementsByTagName('body')[0].style:document.all.tags('body')[0].style;
	
	
	
	
	//for(var i=1;i<7;i++){
	//  eval('checkclick["menu'+i+'"]')
	//    if(document.all) {
	//     if(i!=6){
	//	   eval('document.all["menu'+i+'"].className="roundnavi"');
	//	 }
	//	 else{
	//	   eval('document.all["menu'+i+'"].className="roundnavigruen"');
	//	 }
		 
	//   }
	//}
	
	
	
}
Fun_fontsize.prototype.getStyleHtml = function(size) {
	var html = '<style type="text/css" media="screen"> body { font-size: ';
	html += (this.currentSize)?this.currentSize:size;
	html += 'px; } table { font-size: 12px; }><' + '/style>';


	
	var html = '<style type="text/css" media="screen"> body { font-size: ';
	html += (this.currentSize)?this.currentSize:size;
	html += 'px; } table { font-size: ';
	html += (this.currentSize)?this.currentSize:size;
	html += 'px; } div.main { font-size: ';
	html += (this.currentSize)?this.currentSize:size;
	html += 'px; }><' + '/style>';


	
}
Fun_fontsize.prototype.getLinkHtml = function(increment,properties) {
	if (properties[1]) {
		var html = properties[0] + '<a href="#" onclick="fun_fontSize.change(' + increment + '); 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] + '"':'';
		
		
	//alert(html)
	
		return html += '>'+ properties[1] + '<' + '/a>' + properties[10];
	
	
	} else return '';
}
Fun_fontsize.prototype.getDomain = function() {
	var href = document.location.href;

	return href.substring(href.indexOf('.'),href.indexOf('/',href.indexOf('.')));
}
Fun_fontsize.prototype.getExpiresDate = function() {
	var expires = new Date();
	expires.setFullYear(expires.getFullYear() + 1);
	return expires
}
Fun_fontsize.prototype.getFontPref = function() {
	var allCookies = document.cookie;
	var start = allCookies.indexOf(this.cookieName);
	if (start != -1) {
		start += this.cookieName.length;
		var end = allCookies.indexOf(';',start);
		end = (end != -1)?end:allCookies.length;
		return parseInt(allCookies.substring(start,end));
	} else return this.baseSize;
}
Fun_fontsize.prototype.storeFontPref = function() {
	document.cookie = this.cookieName + this.currentSize + '; expires=' + this.expires.toGMTString() + ';' + '; path=/; domain=' + this.domain;
}
Fun_fontsize.prototype.change = function(increment) {
	this.currentSize = (!increment)?this.baseSize:this.currentSize + increment;
	this.setFontSize();
}
Fun_fontsize.prototype.setFontSize = function() {
   
    if(this.currentSize < 0){this.currentSize = 2};	

	this.body.fontSize = this.currentSize + 'px';
}


var  fun_fontSize = new Fun_fontsize(fun_baseSize,fun_increment,fun_bigger,fun_reset,fun_smaller);
