$(function(){
	$(document).pngFix();
	$("a").focus(function(){
		$(this).blur();
	});
	
	var cookie_value = readCookie("pk_cookie_font");
	
	if(cookie_value){
		set_font(cookie_value);
	}
	
	$('#fontNormal').click(function(){
		set_font('small');
	});
	$('#fontLarger').click(function(){
		set_font('medium');
	});
	$('#fontLargest').click(function(){
		set_font('large');
	});
});

/* new window handler */
var win = null;
function popup(url,urlname,w,h,scroll){
	if(!w) {
		w = 625;	
	}
	if(!h){
		h = 450;	
	}
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0; //'+scroll+'
	settings ='menubar=yes,height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable'
	win = window.open(url,urlname,settings)
}

function clickclear(thisfield, defaulttext) {
	if(thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if(thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

function set_font(type){
	if(type == 'small'){
		$("div, span, h1, h2, h3, h4, label, b, i, ul, li, p, table, tr, td", '.centercontent').css('font-size', '12px');
		$('h4, h3, h2, h1').children().css('font-size', '13px');
		$('div#pagination').children().css('font-size', '9px');
	}
	
	if(type == 'medium'){
		$("div, span, h1, h2, h3, h4, label, b, i, ul, li, p, table, tr, td", '.centercontent').css('font-size', '14px');
		$('h4, h3, h2, h1').children().css('font-size', '15px');
		$('div#pagination').children().css('font-size', '9px');
	}
	
	if(type == 'large'){
		$("div, span, h1, h2, h3, h4, label, b, i, ul, li, p, table, tr, td", '.centercontent').css('font-size', '16px');
		$('h4, h3, h2, h1').children().css('font-size', '17px');
		$('div#pagination').children().css('font-size', '9px');
	}
	
	createCookie("pk_cookie_font", type, 1);
}

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;
}
