var fontsize = 0;
var step = 4;

function onloadhandler() {
	init_font();
		
	document.getElementById('dec_size').onclick = dec_font;	
	document.getElementById('std_size').onclick = std_font;
	document.getElementById('inc_size').onclick = inc_font;
	
	document.getElementById('dec_size').style.backgroundImage = "url('grafik/24px-View-zoom-out.svg.png')";
	document.getElementById('std_size').style.backgroundImage = "url('grafik/24px-View-zoom-std.svg.png')";
	document.getElementById('inc_size').style.backgroundImage = "url('grafik/24px-View-zoom-in.svg.png')";
	
	isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
	if (isIE6) {
		changeImages();
	}	
}
function init_font() {
	var cookie = readCookie("neducation_fontsize");
	step = 4;
	if (cookie)
		fontsize = parseInt(cookie);
	else
		fontsize = 100;
	set_font();
}

function inc_font() {
	if (fontsize < 132) {
		fontsize = fontsize+step;
		set_font();
		createCookie("neducation_fontsize",fontsize,1000);
	}
}
function std_font() {
	fontsize = 100;
	set_font();
	eraseCookie("neducation_fontsize");
}
function dec_font() {
	if (fontsize > 79) {
		fontsize -= step;
		set_font();
		createCookie("neducation_fontsize",fontsize,1000);
	}
}
function get_fontsize() {
	alert(fontsize);
}
function set_font() {
	document.body.style.fontSize = fontsize +"%";
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------
function createCookie(name,value,days) {
	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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

addLoadEvent(onloadhandler);
addLoadEvent(init_font);
