
function Cookiemanager() {
	this.name = 'cookieManager';
	this.defaultExpiration = this.getExpiration();
	this.defaultDomain = window.location.host.replace(/((^\w+:\/\/[\w-]+\.)|\/)/, '');
	this.defaultPath = '/';
	this.cookies = new Object();
	this.expiration = new Object();
	this.domain = new Object();
	this.path = new Object();
	window.onunload = new Function (this.name+'.setDocumentCookies();');
	this.getDocumentCookies();
}

Cookiemanager.prototype.getExpiration = function() {
	var date = new Date();
    date.setTime(date.getTime()+(7*24*60*60*1000));
	return date.toGMTString();
}

Cookiemanager.prototype.getDocumentCookies = function() {
	var cookie,pair;
	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('=');
		this.cookies[pair[0]] = pair[1];
	}
}

Cookiemanager.prototype.setDocumentCookies = function() {
	var expires = '';
	var cookies = '';
	var domain = '';
	var path = '';
	for(var name in this.cookies) {
		expires = (this.expiration[name])?this.expiration[name]:this.defaultExpiration;
		path = this.defaultPath;
		domain = this.defaultDomain;
        if(name) {
		    var cookies = name + '=' + this.cookies[name] + '; expires=' + expires + '; path=' + path + '; domain=' + domain;
            if(cookies != '') {
                document.cookie = cookies;
            }
        }
	}
	return true;
}

Cookiemanager.prototype.getCookie = function() {  
	return (this.cookies['fontSize'])?this.cookies['fontSize']:false;
}

Cookiemanager.prototype.setCookie = function(cookieValue) {
    if(!isNaN(cookieValue)) {
    	this.cookies['fontSize'] = parseInt(cookieValue);
    	this.expiration['fontSize'] = this.getExpiration();
    	this.domain['fontSize'] = window.location.host.replace(/^[\w-]+\./, '');
    	this.path['fontSize'] = this.defaultPath;
    	return true;
    }
}

var cookieManager = new Cookiemanager();
var efa_default = 75;
var efa_increment = 10;

var efa_smaller = ['<ul><li>Schriftgr&ouml;&szlig;e:</li><li>',
				   '<img src="fileadmin/templates/graphic/ico_schrift-.gif" style="border:0;" />', //HTML to go before 'smaller' link
				   'Schriftgrad kleiner',							//HTML to go inside 'smaller' anchor tag
				   '',											//class attribute
				   '',											//id attribute
				   '',											//name attribute
				   '',											//accesskey attribute
				   '',											//onmouseover attribute
				   '',											//onmouseout attribute
				   '',											//onfocus attribute
				   '</li>'									//HTML to go after 'smaller' link
				   ]
var efa_reset = ['<li>',
				 '<img src="fileadmin/templates/graphic/ico_schrift=.gif" style="border:0;" />', //HTML to go before 'reset' link
				 'Schriftgrad normal',						//HTML to go inside 'reset' anchor tag
				  '',											//class attribute
				  '',											//id attribute
				  '',											//name attribute
				  '',											//accesskey attribute
				  '',											//onmouseover attribute
				  '',											//onmouseout attribute
				  '',											//onfocus attribute
				  '</li>'											//HTML to go after 'reset' link
				  ]
var efa_bigger = ['<li>',		//HTML to go before 'bigger' link
				  '<img src="fileadmin/templates/graphic/ico_schrift+.gif" style="border:0;" />', //HTML to go inside 'bigger' anchor tag
				  'Schriftgrad gr&ouml;sser',				//title attribute
				  '',											//class attribute
				  '',											//id attribute
				  '',											//name attribute
				  '',											//accesskey attribute
				  '',											//onmouseover attribute
				  '',											//onmouseout attribute
				  '',											//onfocus attribute
				  '</li></ul>'									//HTML to go after 'bigger' link
				  ]






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_fontSize06";
		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);
		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_Fontsize06.prototype.getLinkHtml = function(direction,properties) {
	
	var html = properties[0] + '<a href="#" onclick="efa_fontSize06.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);
	this.body.fontSize = Math.round(this.pref*this.base) + '%';
}

Efa_Fontsize06.prototype.getCookie = function() {
	var cookie = cookieManager.getCookie();
	return (cookie)?cookie:false;
}

Efa_Fontsize06.prototype.setCookie = function(cookieValue) {
	return cookieManager.setCookie(cookieValue);
}

var  efa_fontSize06 = new Efa_Fontsize06(efa_increment,efa_bigger,efa_reset,efa_smaller,efa_default);
var Stil = "Standard";
var Keks = "Layout";
var Tage = 30;

// Style Switcher

function switchStyle(s) {
  if (!document.getElementsByTagName) return;
  var el = document.getElementsByTagName("link");
  for (var i = 0; i < el.length; i++ ) {
    if (el[i].getAttribute("rel").indexOf("style") != -1 && el[i].getAttribute("title")) {
      el[i].disabled = true;
      if (el[i].getAttribute("title") == s) el[i].disabled = false;
    }
  }
}

function loadStyle() { 
  var c = getStyleCookie();
  if (c && c != Stil) {
    switchStyle(c);
    Stil = c;
  }
}

function setStyleNeu(s) {
  if (s != Stil) {
    switchStyle(s);
    Stil = s;
  }
  delStyleCookie();
  setStyleCookie();
}

// Cookie-Funktionen

function setCookie(name, value, expdays) {   // gültig expdays Tage
  var now = new Date();
  var exp = new Date(now.getTime() + (1000*60*60*24*expdays));
  document.cookie = name + "=" + escape(value) + ";" +
                    "expires=" + exp.toGMTString() + ";" +
                    "path=/";
}

function delCookie(name) {   // expires ist abgelaufen
  var now = new Date();
  var exp = new Date(now.getTime() - 1);
  document.cookie = name + "=;" +
                    "expires=" + exp.toGMTString() + ";" + 
                    "path=/";
}

function getCookie(name) {
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    var start = dc.indexOf(cname);
    if (start != -1) {
      start += cname.length;
      var stop = dc.indexOf(";", start);
      if (stop == -1) stop = dc.length;
      return unescape(dc.substring(start,stop));
    }
  }
  return null;
}

function setStyleCookie() {
  setCookie(Keks, Stil, Tage);
}

function getStyleCookie() {
  return getCookie(Keks);
}

function delStyleCookie() {
  delCookie(Keks);
}
//## Laden der Scripte ###
if(window.onload)
{
	var temp = window.onload;
    window.onload=function(e) {
		temp(e);
		loadStyle();
  };
}
else
{
	
	window.onload=function(e) {
    	loadStyle();
  	};
}
if(window.onunload) {
    var temp = window.onunload;
    window.onunload=function(e){
	temp(e);
	setStyleNeu(Stil);
    }
}
else {
    window.onunload=function(e) {
	setStyleNeu(Stil);
    }
}

			// decrypt helper function
		function decryptCharcode(n,start,end,offset) {
			n = n + offset;
			if (offset > 0 && n > end) {
				n = start + (n - end - 1);
			} else if (offset < 0 && n < start) {
				n = end - (start - n - 1);
			}
			return String.fromCharCode(n);
		}
			// decrypt string
		function decryptString(enc,offset) {
			var dec = "";
			var len = enc.length;
			for(var i=0; i < len; i++) {
				var n = enc.charCodeAt(i);
				if (n >= 0x2B && n <= 0x3A) {
					dec += decryptCharcode(n,0x2B,0x3A,offset);	// 0-9 . , - + / :
				} else if (n >= 0x40 && n <= 0x5A) {
					dec += decryptCharcode(n,0x40,0x5A,offset);	// A-Z @
				} else if (n >= 0x61 && n <= 0x7A) {
					dec += decryptCharcode(n,0x61,0x7A,offset);	// a-z
				} else {
					dec += enc.charAt(i);
				}
			}
			return dec;
		}
			// decrypt spam-protected emails
		function linkTo_UnCryptMailto(s) {
			location.href = decryptString(s,-1);
		}
		
        function clearText(inputfield){if (inputfield.defaultValue==inputfield.value){inputfield.value = ""}}
        function clear_inputfield(){window.document.forms[0].USR.value="benutzername";window.document.forms[0].PWD.value="passwort";}
