var cf = 0;

window.onload = function(e) {
	if(document.cookie) {
		var i = document.cookie.search(/cf\=[0-9]{1}/);
		if(i != -1) {
			var f = parseInt(document.cookie.substr(i+3, 1));
			cf = f;
			if(cf > 0) increaseFont(f, true);
		}
	}
}
		
function increaseFont(d, init) {
	if(cf == 5 && !init) return false;
	var f = 0.1;
	if(d && parseInt(d) > 0)
		f = parseFloat(String(parseFloat(parseInt(d)*f)).substr(0,3));
		
	var s = document.styleSheets[0];
	var r = s.cssRules?s.cssRules:s.rules;
	s.deleteRule=s.deleteRule?s.deleteRule:s.removeRule;
	for(i=0;i<r.length;i++) {
		var stxt = r[i].selectorText.toLowerCase();
		switch(stxt) {
			case "#paanavigaatio li":
			case "body":
			case "#apunavi":
				break;
			default:
				if(r[i].style.fontSize) {
					if(r[i].style.fontWeight == "bold")
						bold = true;
					r[i].style.fontSize = String(parseFloat(r[i].style.fontSize)+(bold?(f+0.05):f)).substr(0,3)+"em";
				}
				break;
		}
	}
	
	if(!init && document.cookie != null) {
		cf += parseInt(d)>0?parseInt(d):1;
		document.cookie = "cf="+cf+"; path=/";
	}
	
}

function decreaseFont(d) {
	if(cf == 0) return false;
	var f = 0.1;
	if(d && parseInt(d) > 0)
		f = parseFloat(String(parseFloat(parseInt(d)*f)).substr(0,3));
	var s = document.styleSheets[0];
	var r = s.cssRules?s.cssRules:s.rules;
	s.deleteRule=s.deleteRule?s.deleteRule:s.removeRule;
	for(i=0;i<r.length;i++) {
		var stxt = r[i].selectorText.toLowerCase();
		switch(stxt) {
			case "#paanavigaatio li":
			case "body":
			case "#apunavi":
				break;
			default:
				if(r[i].style.fontSize) {
					if(r[i].style.fontWeight == "bold")
						bold = true;
					r[i].style.fontSize = String(parseFloat(r[i].style.fontSize)-(bold?(f-0.05):f)).substr(0,3)+"em";
				}
				break;
		}
	}
	
	if(d && (cf - parseInt(d)) <= 0)
		cf = 0;
	else if( d )
		cf = parseInt(cf-d);
	else
		cf -= 1;	
	
	if(document.cookie != null) {
		document.cookie = "cf="+cf+"; path=/";
	}
	
}

function openVideo(clip) {
	window.open("Viewer.aspx?Clip="+clip, "_blank", "fullscreen=no, height=390, width=650");
	return false;
}

function openPrint(itemId) {
	window.open("Print.aspx?id="+itemId, "_blank", "fullscreen=no, scrollbars=yes, height=800, width=600");
}