function fontSelect(idEl, fontsize){
	$('content').setStyle({fontSize : fontsize+'%'});	
	$$('#ul_font .font_selezionato').each(
		function(htmlEl){
			htmlEl.removeClassName('font_selezionato');	
		});
	$(idEl).addClassName('font_selezionato');
	BartoliniRemote.saveFontSize(fontsize);	
    setUpToolbar('tb_2Level');
	return false;
};

function changeContrasto(el , idEl, color){
	// Opero sul contrasto del color-font
	$('bodyBartolini').setStyle({color: '#'+color});
	var img = $('img_'+el.id);
	img.writeAttribute({src:'/fe-web/img/ico_checked.gif'});	
	var otherImg = $('img_'+idEl);
	otherImg.writeAttribute({src: '/fe-web/img/ico_no_checked.gif'});	
	BartoliniRemote.saveColorContrast(color);	
	return false;
}

function displayHideLanguage(mode){
	if ('display' == mode){
		$('img_open').hide();
		$('img_close').show();
		$$('#scelta_lingua li.hideLang').each(function(item){item.show();});
	} else {
		$('img_close').hide();
		$('img_open').show();
		$$('#scelta_lingua li.hideLang').each(function(item){item.hide();});
	}
	return false;
}


/**
 * Imposta le voci presenti nella toolbar menu
 * Se la somma delle voci del menu è inferione a 700px 
 * 		-> Menu su una riga e ul class toolbar_2level
 * Altrimenti Menu su due righe e ul con class toolbar_2level_double 
 * @param ulId
 * @return
 */
function setUpToolbar(ulId){	
	var ulElement = $(ulId);
	var maxWidth = 690;
	if (ulElement){
		var liElements = ulElement.childElements();
		if (liElements != null){			
			var currentSumWidth = 0;
			var isGreater = false;						
			var prevLiEl = null;
			
			liElements.each(
				function(liHtml, i){																				
					if (Prototype.Browser.IE7 ){
						liHtml.setStyle({marginRight: '0px'});
					}
					var liWidth = liHtml.getWidth();					
					currentSumWidth  = 	currentSumWidth + liWidth;		
					
					if (currentSumWidth > maxWidth){						
						isGreater = true;						
						prevLiEl = liElements[i-1];
						if (!prevLiEl.hasClassName('end_toolbar_2level')){
							prevLiEl.addClassName('end_toolbar_2level');
						}
					} 
					
			});				
			if (isGreater){								
				ulElement.removeClassName('toolbar_2level');
				ulElement.addClassName('toolbar_2level_double');
			} else {				
				ulElement.addClassName('toolbar_2level');
				ulElement.removeClassName('toolbar_2level_double');				
			}
		}
	}
	return false;
}

function setTime() {
	var time;
	var x = new Date();
	h = x.getHours();
	m = x.getMinutes();
	if ( m <= 9){ m = "0" + m };
	if ( h <= 9){ h = "0" + h };
	time = h + ":" + m;
	$('time').update(time);		
}

