var $sCookieName = 'gamerawet_font_size';
var $sDivId = 'container';

var $iStart = 100;
var $iMin = 90;
var $iActualValue = null;
var $iMax = 110;
var $iStep = 20;

/**
 * Incrementa la dimensione della font
 */
function gamerawet_upFontSize() {
	$iNewValue = $iActualValue + $iStep;
	if ($iNewValue<=$iMax) {
		$iActualValue = $iNewValue;
		gamerawet_setCookie($sCookieName, $iActualValue, null);
		gamerawet_setFontSize();
	}
}
/**
 * Decrementa la dimensione della font
 */
function gamerawet_downFontSize() {
	$iNewValue = $iActualValue - $iStep;
	if ($iNewValue>=$iMin) {
		$iActualValue = $iNewValue;
		gamerawet_setCookie($sCookieName, $iActualValue, null);
		gamerawet_setFontSize();
	}
}
/**
 * Imposta la dimensione della fonte
 */
function gamerawet_setFontSize(){
	try {
		document.getElementById($sDivId).style.fontSize=$iActualValue + "%";
		document.getElementById($sDivId).style.lineHeight=($iActualValue+10) + "%";
	} catch ($oEx) {
		//alert($oEx);
	}
}
/**
 * Inizializza la pagina impostando la fonte sulla base del cookie
 */
function gamerawet_startUpFontSize() {
	if (gamerawet_getCookie($sCookieName)!=null) {
		$iActualValue = parseInt(gamerawet_getCookie($sCookieName));
		gamerawet_setFontSize();
	} else {
		$iActualValue = $iStart;	
	}
}
// getCookie value
function gamerawet_getCookie(Name) {
	var search = Name + "="
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search)

		if (offset != -1) { // if cookie exists
			offset += search.length

			// set index of beginning of value
			end = document.cookie.indexOf(";", offset)

			// set index of end of cookie value
			if (end == -1) {
				end = document.cookie.length
			}
			return unescape(document.cookie.substring(offset, end))
		}
	}
}
// Sets cookie values. Expiration date is optional
function gamerawet_setCookie(name, value, expire) {
   document.cookie = name + "=" + escape(value)
      + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
      + ";domain=" + window.location.host
      + ";path=/";
}

// expandtab sw=4 ts=4 sts=4
var targetId = 'body';
var idToExpand = new Array('body');
var heightOffset = -1;
function adjustHeight() {
	try {
		if (document.getElementById) {
			var viewportHeight = document.documentElement.clientHeight;
			var bodyHeight = document.documentElement.getElementsByTagName('body').item(0).clientHeight;
			if (viewportHeight>bodyHeight) {
				var contentHeight=document.getElementById(targetId);
/*				alert(contentHeight.clientHeight
					+ '\n' + contentHeight.style.height);*/
				iToSum = viewportHeight-bodyHeight;
				for (i in idToExpand) {
					var oRif = document.getElementById(idToExpand[i]);
/*					alert(
						+ i
						+ '\n' + idToExpand[i]
						+ '\n' + iToSum
						+ '\n - ' + oRif.clientHeight
						+ '\n - ' + oRif.style.height
						);*/
					oRif.style.height = (oRif.clientHeight+iToSum+heightOffset)+'px';
/*					alert(
						'\n' + oRif.clientHeight
						);*/
				}
			}
		}
	} catch (ex) {
		alert(ex.message);
	}
}

function gamera_startUp() {
	gamerawet_startUpFontSize();
	adjustHeight();
}
window.onresize = adjustHeight;
window.onload = gamera_startUp;