// JavaScript Document
var standardFontSize = "73"
var fontSizeChangeDiff = "20"
var currentContrast = "standard";
function setFontSizeCookie(fontSize){
	document.cookie="fontSize="+fontSize+"; expires="+new Date().getTime() + (5 * 24 * 60 * 60 * 1000);
}

function getFontSizeCookie(){
	var size = document.cookie.match(/fontSize=(\d{1,3});/);
	if(size){
		return size[1];
	}
	else {
		return false;
	}
}

function setContrastCookie(contrast){
	document.cookie="contrast="+contrast+"; expires="+new Date().getTime() + (5 * 24 * 60 * 60 * 1000);		
}

function getContrastCookie(){
	var contrast = document.cookie.match(/contrast=(\w*);/);
	if(contrast){
		return contrast[1];
	}
	else {
		return false;
	}
}	

kontrastSS = false;

window.onload = function()
{
	selectedFontSize = getFontSizeCookie()?getFontSizeCookie():standardFontSize;
	if(selectedFontSize != standardFontSize)
	{
		document.body.style.fontSize = selectedFontSize + "%";
	}
	else {
		document.body.style.fontSize = standardFontSize+"%";	
	}

	cookieContrast = getContrastCookie();
	if(cookieContrast){
		var i, a, main;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel")==null)continue;
		 if(a.getAttribute("rel").indexOf("style") != -1
			&& a.getAttribute("title")) {
		   a.disabled = false;
		   if(a.getAttribute("title") == cookieContrast) a.disabled = false;
		   if(a.getAttribute("title") != cookieContrast) a.disabled = true;
		 }
		}
	}
}
function schriftVerkleinern()
{
	var newFontSize = parseFloat(document.body.style.fontSize)-10;
	document.body.style.fontSize = newFontSize + "%"
	setFontSizeCookie(newFontSize);
}
function schriftVergroessern()
{
	var newFontSize = parseFloat(document.body.style.fontSize)+10;
	document.body.style.fontSize = newFontSize + "%"
	setFontSizeCookie(newFontSize);
}

function kontrastAendern(){
	currentContrast = currentContrast =='weiss' ? 'schwarz' : currentContrast == 'standard' ? 'weiss' : 'standard';
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	if(a.getAttribute("rel")==null)continue;
	 if(a.getAttribute("rel").indexOf("style") != -1
		&& a.getAttribute("title")) {
	   a.disabled = true;
	   if(a.getAttribute("title") == currentContrast) a.disabled = false;
	 }
	}
	setContrastCookie(currentContrast);
}
