// JavaScript Document
function eventHandlerRegistration(){
	if ($("#news-list-inner").parent().height() < $("#news-list-inner").height()) {
		var headlineCount = $('div.headline').length;
		var headlineTimeout;
		var totalspace = 0;
		var currentHeadline = 0, oldHeadline = 0;
		var goforward = true;	
		
		var headlineRotate = function() {
			if (goforward || totalspace <= 0) {
				if (($("#news-list-inner").height() - totalspace) > $("#news-list-inner").parent().height() ) {
					currentHeadline = (oldHeadline + 1);
					goforward = true;
				} else {
					oldHeadline = currentHeadline - 1;
					currentHeadline = oldHeadline - 1;
					goforward = false;
				}
			} else
				currentHeadline = (oldHeadline - 1);
			
			hh = $('div.headline:eq(' + oldHeadline + ')').height() + 9;
			totalspace = totalspace + (hh * (goforward ? 1 : -1));			
			
			//alert("TOT MOVE: "+totalspace+" current: "+oldHeadline+" current height: "+hh);			
			
			$("#news-list-inner").animate({top: -totalspace}, 30 * hh, function() {
				headlineTimeout = setTimeout(headlineRotate, 4000);
			});
			if (currentHeadline < 0) {
				goforward = true;
				totalspace = 0;
				currentHeadline = 0;
			}
			
			oldHeadline = currentHeadline;
		
		
		};
		headlineTimeout = setTimeout(headlineRotate, 4000);

	}
	
	var defaultFontSize =  100;
	var minimumFontSize =  85;
	var maximumFontSize = 130;
	var currentFontSize = defaultFontSize;
	
	$debug_this_script = false;
	
	function changeFontSize(sizeDelta){
		if (sizeDelta == 0)
			currentFontSize = defaultFontSize;
		else
			currentFontSize = parseInt(currentFontSize) + parseInt(sizeDelta * 5);
	
		if(currentFontSize > maximumFontSize){
			currentFontSize = maximumFontSize;
		}else if(currentFontSize < minimumFontSize){
			currentFontSize = minimumFontSize;
		}
		setFontSize(currentFontSize);
	}

	function setFontSize(fontSize){
		if($debug_this_script){alert ('fontsize is being set: ' + fontSize);}
		$('#center-col').css("font-size", fontSize+"%");		
	}	
	
	//Incrementa il Font della pagina
	$('#access-plus').click(function() {
		changeFontSize(1);	
		return false;			
	});	
	$('#access-minus').click(function() {
		changeFontSize(-1);				
		return false;		
	});
	$('#access-normal').click(function() {
		changeFontSize(0);	
		return false;					
	});	
	// Elimina la colonna destra
	$('#access-print').click(function() {
		alert("Funzione di stampa - non ancora abilitata ...");				
		return false;					
	});		

}