function styleInit(){
	var contentHeader = document.getElementById("contentHeader");
	var contentBody = document.getElementById("contentBody");
	var size = document.getElementById("size");
	var color = document.getElementById("color");
	var background = document.getElementById("background");
	var sizeClose = document.getElementById("sizeClose");
	var colorClose = document.getElementById("colorClose");
	var backgroundClose = document.getElementById("backgroundClose");
	var topRight = document.getElementById("topRight");
		
	if(document.cookie){
		var cookie = document.cookie;
		var fontSize = cookie.substring(cookie.indexOf("fontSize=") + 9, cookie.indexOf("color") - 1);
		var fontColor = cookie.substring(cookie.indexOf("color=") + 6, cookie.indexOf("backgroundColor") - 1);
		var backgroundColor = cookie.substring(cookie.indexOf("backgroundColor") + 16, cookie.indexOf("sizeTop") - 1);
		var sizeTop = cookie.substring(cookie.indexOf("sizeTop") + 8, cookie.indexOf("sizeLeft") -1);
		var sizeLeft = cookie.substring(cookie.indexOf("sizeLeft") + 9, cookie.indexOf("colorTop") -1);
		var colorTop = cookie.substring(cookie.indexOf("colorTop") + 9, cookie.indexOf("colorLeft") - 1);
		var colorLeft = cookie.substring(cookie.indexOf("colorLeft") + 10, cookie.indexOf("backgroundTop") - 1);
		var backgroundTop = cookie.substring(cookie.indexOf("backgroundTop") + 14, cookie.indexOf("backgroundLeft") - 1);
		var backgroundLeft = cookie.substring(cookie.indexOf("backgroundLeft") + 15, cookie.indexOf("sizeVisibility") - 1);
		var sizeVisibility = cookie.substring(cookie.indexOf("sizeVisibility") + 15, cookie.indexOf("colorVisibility") - 1);
		var colorVisibility = cookie.substring(cookie.indexOf("colorVisibility") + 16, cookie.indexOf("backgroundVisibility") - 1);
		var backgroundVisibility = cookie.substring(cookie.indexOf("backgroundVisibility") + 21, cookie.length);

		contentHeader.style.fontSize = fontSize - 25 + "%";
		contentBody.style.fontSize = fontSize + "%";
		contentHeader.style.color = fontColor;
		contentBody.style.color = fontColor;
		size.style.color = fontColor;
		color.style.color = fontColor;
		background.style.color = fontColor;
		var topRightDivs = topRight.getElementsByTagName("div");
		for(i=0; i<topRightDivs.length; i++){
			topRightDivs[i].style.color = fontColor;
		}
		// Just for IE:
		var hrefs = contentHeader.getElementsByTagName("a");
		for(i=0; i<hrefs.length; i++){
			hrefs[i].style.color = fontColor;
		}
		hrefs = contentBody.getElementsByTagName("a");
		for(i=0; i<hrefs.length; i++){
			hrefs[i].style.color = fontColor;
		}
		
		contentHeader.style.backgroundColor = backgroundColor;
		contentBody.style.backgroundColor = backgroundColor;
		size.style.backgroundColor = backgroundColor;
		color.style.backgroundColor = backgroundColor;
		background.style.backgroundColor = backgroundColor;
		var topRightDivs = topRight.getElementsByTagName("div");
		for(i=0; i<topRightDivs.length; i++){
			topRightDivs[i].style.backgroundColor = backgroundColor;
		}
		
		size.style.top = sizeTop;
		size.style.left = sizeLeft;
		color.style.top = colorTop;
		color.style.left = colorLeft;
		background.style.top = backgroundTop;
		background.style.left = backgroundLeft;
		
		size.style.visibility = sizeVisibility;
		color.style.visibility = colorVisibility;
		background.style.visibility = backgroundVisibility;
		sizeClose.style.visibility = sizeVisibility;
		colorClose.style.visibility = colorVisibility;
		backgroundClose.style.visibility = backgroundVisibility;
}
	else{
		contentHeader.style.fontSize = "75%";
		contentBody.style.fontSize = "100%";
		
		contentHeader.style.color = "#000000";
		contentBody.style.color = "#000000";
		size.style.color = "#000000";
		color.style.color = "#000000";
		background.style.color = "#000000";
		var topRightDivs = topRight.getElementsByTagName("div");
		for(i=0; i<topRightDivs.length; i++){
			topRightDivs[i].style.color = "#000000";
		}
		// Just for IE:
		var hrefs = contentHeader.getElementsByTagName("a");
		for(i=0; i<hrefs.length; i++){
			hrefs[i].style.color = "#000000";
		}
		hrefs = contentBody.getElementsByTagName("a");
		for(i=0; i<hrefs.length; i++){
			hrefs[i].style.color = "#000000";
		}
		
		contentHeader.style.backgroundColor = "#FFFFFF";
		contentBody.style.backgroundColor = "#FFFFFF";
		size.style.backgroundColor = "#FFFFFF";
		color.style.backgroundColor = "#FFFFFF";
		background.style.backgroundColor = "#FFFFFF";
		var topRightDivs = topRight.getElementsByTagName("div");
		for(i=0; i<topRightDivs.length; i++){
			topRightDivs[i].style.backgroundColor = "#FFFFFF";
		}

		size.style.top = "1em";
		size.style.left = "0.5em";
		color.style.top = "1em";
		color.style.left = "6em";
		background.style.top = "1em";
		background.style.left = "11em";
		
		size.style.visibility = "hidden";
		color.style.visibility = "hidden";
		background.style.visibility = "hidden";
		sizeClose.style.visibility = "hidden";
		colorClose.style.visibility = "hidden";
		backgroundClose.style.visibility = "hidden";
	}
}

function setFontSize(size){
	var contentHeader = document.getElementById("contentHeader");
	var contentBody = document.getElementById("contentBody");
	var fontSize = parseInt(contentBody.style.fontSize);
	if(size == "return"){
		return fontSize;
	}
	else if(size == "bigger"){
		fontSize += 10;
	}
	else if(size == "reset"){
		fontSize = 100;
	}
	else if(size == "smaller"){
		fontSize -= 10;
	}
	
	contentHeader.style.fontSize = fontSize - 25 + "%";
	contentBody.style.fontSize = fontSize + "%";
}

function setColor(fontColor){
	var contentHeader = document.getElementById("contentHeader");
	var contentBody = document.getElementById("contentBody");
	var size = document.getElementById("size");
	var color = document.getElementById("color");
	var background = document.getElementById("background");
	var topRight = document.getElementById("topRight");
	contentHeader.style.color = "#" + fontColor;
	contentBody.style.color = "#" + fontColor;
	size.style.color = "#" + fontColor;
	color.style.color = "#" + fontColor;
	background.style.color = "#" + fontColor;
	var topRightDivs = topRight.getElementsByTagName("div");
	for(i=0; i<topRightDivs.length; i++){
		topRightDivs[i].style.color = "#" + fontColor;
	}
	// Just for IE:
	var hrefs = contentHeader.getElementsByTagName("a");
	for(i=0; i<hrefs.length; i++){
		hrefs[i].style.color = "#" + fontColor;
	}
	hrefs = contentBody.getElementsByTagName("a");
	for(i=0; i<hrefs.length; i++){
		hrefs[i].style.color = "#" + fontColor;
	}
}

function setBackgroundColor(backgroundColor){
	var contentHeader = document.getElementById("contentHeader");
	var contentBody = document.getElementById("contentBody");
	var size = document.getElementById("size");
	var color = document.getElementById("color");
	var background = document.getElementById("background");
	var topRight = document.getElementById("topRight");
	contentHeader.style.backgroundColor = "#" + backgroundColor;
	contentBody.style.backgroundColor = "#" + backgroundColor;
	size.style.backgroundColor = "#" + backgroundColor;
	color.style.backgroundColor = "#" + backgroundColor;
	background.style.backgroundColor = "#" + backgroundColor;
	var topRightDivs = topRight.getElementsByTagName("div");
	for(i=0; i<topRightDivs.length; i++){
		topRightDivs[i].style.backgroundColor = "#" + backgroundColor;
	}
}

function saveStyle(){
	var contentBody = document.getElementById("contentBody");
	var size = document.getElementById("size");
	var color = document.getElementById("color");
	var background = document.getElementById("background");
	// Überprüfen, ob Cookies erlaubt sind
	if(navigator.cookieEnabled != true){
		alert("Um die die Einstellungen speichern zu können, müssen Cookies erlaubt sein!");
	}
	// Einstellungen ermitteln
	var fontSize = setFontSize("return");
	var fontColor = contentBody.style.color;
	var backgroundColor = contentBody.style.backgroundColor;
	var sizeTop = size.style.top ? size.style.top : "1em";
	var sizeLeft = size.style.left ? size.style.left : "15px";
	var colorTop = color.style.top ? color.style.top : "1em";
	var colorLeft = color.style.left ? color.style.left : "6em";
	var backgroundTop = background.style.top ? background.style.top : "1em";
	var backgroundLeft = background.style.left ? background.style.left : "11.5em";
	var sizeVisibility = size.style.visibility;
	var colorVisibility = color.style.visibility;
	var backgroundVisibility = background.style.visibility;
	
	// Cookie setzen
	document.cookie = "styleSettings=fontSize="+fontSize+" color="+fontColor+" backgroundColor="+backgroundColor+" sizeTop="+sizeTop+" sizeLeft="+sizeLeft+" colorTop="+colorTop+" colorLeft="+colorLeft+" backgroundTop="+backgroundTop+" backgroundLeft="+backgroundLeft+" sizeVisibility="+sizeVisibility+" colorVisibility="+colorVisibility+" backgroundVisibility="+backgroundVisibility+"; expires=Thu, 31 Dec 2099 23:59:59 GMT";
	if(document.cookie){
		alert("Die Einstellungen wurden gespeichert!");
	}
	else{
		alert("Die Einstellungen wurden möglicherweise nicht gespeichert, da Ihr Browser keine Cookies erlaubt!");
	}
}

function resetStyle(){
	document.cookie = "styleSettings=;expires=Thu, 01 Jan 1970 00:00:01 GMT";
	styleInit();
	alert("Die Einstellungen wurden zurückgesetzt!");
}
function checkWindow(styleWindow){
	if(document.getElementById(styleWindow).style.visibility == "visible"){
		switchObject(styleWindow,"");
		switchObject(styleWindow+"Close","");
	}
	else if(document.getElementById(styleWindow).style.visibility == "hidden"){
		switchObject("size","");
		switchObject("color","");
		switchObject("background","");
		switchObject("sizeClose","");
		switchObject("colorClose","");
		switchObject("backgroundClose","");
		switchObject("",styleWindow);
		switchObject("",styleWindow+"Close");
	}
}
