// JavaScript-Funktionen zur Steuerung der Schriftgroesse in einem HTML-Dokument
// Copyright (C) 2005 Alexander Mueller
// Autor: Alexander Mueller
// Web:   http://www.EvoComp.de/
// Datei: fontsize.js
// The copyright notice must stay intact for use!
// You can obtain this and other scripts at http://www.EvoComp.de/scripts/skripte.html
//
// This program is distributed in the hope that it will be useful,
// but without any warranty, expressed or implied.

var initial_font_size = 0.9;
var font_unity = 'em';
var delta = 0.1;

var global_newsize = initial_font_size;

var fsize = initial_font_size;


function incFontSize ()
{
	if (!isNaN(delta))
		setFontSize (Math.round((parseFloat(fsize) + parseFloat(delta)) * 100) / 100);
}

function decFontSize ()
{
	if (!isNaN(delta))
		setFontSize (Math.round((parseFloat(fsize) - parseFloat(delta)) * 100) / 100);
}

function setFontSize (newsize)
{
	if (!isNaN(newsize))
	{
		if(newsize>=0.8 && newsize<=1.2){
			if(newsize>=1.1) document.getElementById('kopfservice').style.marginLeft='170px';
			if(newsize<=1.0) document.getElementById('kopfservice').style.marginLeft='220px';
			global_newsize=newsize;
			fsize = Math.round((parseFloat(newsize)) * 100) / 100;
			document.getElementsByTagName('body')[0].style.fontSize = fsize + font_unity;
			createCookie("a2010textsizestyle", fsize, 365);
		}
	}
}

function createCookie(name,value,days) {
	//return true;
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

var kontrastCookie=readCookie("kontrast");
if(kontrastCookie!=null){
  document.write ('<link rel="stylesheet" type="text/css" href="fileadmin/templates/stylesheets/'+kontrastCookie+'.css" media="screen, projection,print" />');
}

var textSizeCookie = readCookie("a2010textsizestyle");
if(textSizeCookie!=null){
	document.write('<style>');
	document.write('body{');
	document.write('font-size:'+ textSizeCookie + 'em');
	document.write('}');
	if(parseFloat(textSizeCookie)>=1.1) document.write('#kopfservice { margin-left:170px; }');
	//if(parseFloat(textSizeCookie)<=1.0) document.write('#kopfservice { margin-left:220px; }');
	document.write('</style>')
	fsize=textSizeCookie;
	global_newsize=textSizeCookie;

}



