var fontSizeCookieName = 'preferences_fontsize';
var smallFontButtonTitle = 'Kisebb fontok';
var normalFontButtonTitle = 'Normál fontok';
var largeFontButtonTitle = 'Nagyob fontok';

function initFontResize( ) {
	var div = document.getElementById("fontresize");
	if (div == null) {
		return;
	}
	drawFontResizeButtons( );
	var sheetName = getCookie( fontSizeCookieName );

	if ( ! sheetName ) sheetName = 'normal';

	activateStyleSheet( sheetName ) ;
}

function drawFontResizeButtons( ) {
	var div = document.getElementById("fontresize");
	var aSmall = document.createElement("a");
	var aNormal = document.createElement("a");
	var aLarge = document.createElement("a");
	aSmall.onclick = function() { activateStyleSheet('small'); return(false); };
	aSmall.href = "#";
	aSmall.className = "small";
	aSmall.title = smallFontButtonTitle;
	aSmall.appendChild(document.createTextNode('A'));
	aNormal.onclick = function() { activateStyleSheet('normal'); return(false); };
	aNormal.href = "#";
	aNormal.className = "normal";
	aNormal.title = normalFontButtonTitle;
	aNormal.appendChild(document.createTextNode('A'));
	aLarge.onclick = function() { activateStyleSheet('large'); return(false); };
	aLarge.href = "#";
	aLarge.className = "large";
	aLarge.title = largeFontButtonTitle;
	aLarge.appendChild(document.createTextNode('A'));
	div.appendChild( aSmall );
	div.appendChild( aNormal );
	div.appendChild( aLarge );

	/*var pButton = document.createElement("a");
	pButton.onclick = function() { setStyleSheet('print'); return(false); };
	pButton.href = "#";
	pButton.className = "print";
	pButton.title = smallFontButtonTitle;
	pButton.appendChild(document.createTextNode('P'));
	div.appendChild( pButton );*/
}

function _activateStyleSheet( sheetName ) {
	if (sheetName == '') {
		return;
	}

	var i, lnk;

	for( i = 0; (lnk = document.getElementsByTagName('link')[i]); i++ ) {
		if ( lnk.getAttribute('rel').indexOf('stylesheet') != -1 && lnk.getAttribute('title') ) {
			lnk.disabled = true;
			if ( lnk.getAttribute('title') == sheetName ) {
				lnk.disabled = false;
				/*setCookie( fontSizeCookieName, sheetName );*/
			}
		}
	}
}

/**
* Activating style sheet and set it in cookie for future using
*
*
*/
function activateStyleSheet( sheetName ) {
	if (sheetName == '') {
		return;
	}

	_activateStyleSheet( sheetName );
	setCookie( fontSizeCookieName, sheetName, '', '/');
}

/**
* This function set style sheet temporary.
*
*
*/
function setStyleSheet( sheetName ) {
	if (sheetName == '') {
		return;
	}

	_activateStyleSheet( sheetName );
}

