function topbarjs( l_homepage, s_mainframe, w, h ) {
	/*
	 * l_homepage -- true/false se assume valore true se siamo in homepage
	 * s_mainframe - stringa - contiene il nome dell'identificatore DIV 
	 * 				 principale contenente il body principale del sito
	 */

	var winW=$(window).width();  //larghezza effettiva del browser
	var winH=$(window).height(); //altezza effettiva del browser
	/*
	if (w){
		var width_bg = winW*100/w ;
	}else{
		var width_bg = 1280;
	}
	*/

	
	/* Calcolo della larghezza del div Centrale della topbar */
	if (winH <= const_height) { winH = const_height; }
	if (winW <= const_width) { winW = const_width; }
	var width_CT= winW - const_WSX - const_WDX;
	
	/* Calcolo posizione dele frecce a bordo schermo */
	if (l_homepage) {
		var arrow_AW= ((winH/2)-const_arrow);
	} else {
		if (winH > 800) { // altezza massima di 800px data dalle immagini di sfondo
			var arrow_AW= ((800/2)-const_arrow);
		} else {
			var arrow_AW= ((winH/2)-const_arrow);
		}	
	}
	
	/* Calcolo della larghezza del div Centrale della topbar */
	var width_CT_bottom = winW - const_WSX_bottom - const_WDX_bottom;

	/* Setto le altezze degli elementi del container principale -- INIZIO */
	if (l_homepage) {
		$("#"+s_mainframe+"").css("width",$(window).width()+"px");
		$("#"+s_mainframe+"").css("height",$(window).height()+"px");
		$("#"+s_mainframe+" .customScrollBox .content").css("height",($(window).height()-(const_height_bottom*2))-10+"px");
		$("#"+s_mainframe+" .customScrollBox").css("width",$(window).width()+"px");
		$("#"+s_mainframe+" .dragger_container").css("width",($(window).width()-30)+"px"); // larghezza max della scrollbar
	} else {
		// per le pagine interne la risoluzione è PRE-FISSATA a 1280x800 
		if (w)
			$("#"+s_mainframe+"").css("width",100+"%");
		else
			$("#"+s_mainframe+"").css("width",1280+"px");
		//$("#"+s_mainframe+"").css("height",height_bg+"%");
		
		if (h){	
			var height_bg = h*100/winW;
			$("#"+s_mainframe+" .background").css("height",100+"%");
		}else{
			var height_bg = 800;
			$("#"+s_mainframe+" .background").css("height",800+"px");
		}
		
		$("#"+s_mainframe+" .background").css("width",100+"%");
	}
	
	/*
	var backgroundset=false;
function fixedBackground(url){
    if(!backgroundset)
    {
      document.body.style.overflow = 'hidden';
      document.body.style.padding  = '0px';
      document.body.style.margin   = '0px';

      var overlay = document.createElement('DIV');
      overlay.style.position    = 'absolute';
      overlay.style.top         = '0px';
      overlay.style.left        = '0px';
      overlay.style.height      = '100%';
      overlay.style.width       = '100%';
      overlay.style.overflow    = 'auto';

      overlay.innerHTML         = document.body.innerHTML;
      document.body.innerHTML   = '<img id="background" height="100%"  width="100%" src="' + url + '" style="left: 0; bottom: 0; right: 0; top: 0; z-index: 0" />';

      document.body.appendChild(overlay);

      backgroundset=true;
    }
    else
      background.src=url;
  }*/
	
	
	/* Setto le altezze... -- FINE */

	/* Setto l'altezza della topbar -- INIZIO */ 
	$("#nav_topbar").css("height",const_height+"px");
	$("#nav_topbar-container").css("height",const_height+"px");
	$("#nav_topbarSX").css("height",const_height+"px");
	$("#nav_topbarDX").css("height",const_height+"px");
	$("#nav_topbarCT").css("height",const_height+"px");
	$("#nav_topbar-menu").css("height",const_height+"px");
	/* Setto l'altezza... -- FINE */ 

	/* Setto l'altezza della bottombar -- INIZIO */ 
	$("#nav_bottombar").css("height",const_height_bottom+"px");
	$("#nav_bottombar-container").css("height",const_height_bottom+"px");
	$("#nav_bottombarSX").css("height",const_height_bottom+"px");
	$("#nav_bottombarDX").css("height",const_height_bottom+"px");
	$("#nav_bottombarCT").css("height",const_height_bottom+"px");
	$("#nav_bottombar-menu").css("height",const_height_bottom+"px");
	/* Setto l'altezza... -- FINE */ 
	
	/* Setto la posizione delle frecce a bordo schermo -- INIZIO */ 
	if (l_homepage) {
		$("#mcs_container .scrollDownBtn").css("top",(arrow_AW-(const_height_bottom*2))+"px");
		$("#mcs_container .scrollUpBtn").css("top",(arrow_AW-(const_height_bottom*2))+"px");
	} else {
		$("#nav_arrowSX").css("top",(arrow_AW+const_offset_arrow)+"px"); // Questi saranno abilitati solo per le pagine interne
		$("#nav_arrowDX").css("top",(arrow_AW+const_offset_arrow)+"px"); // Questi saranno abilitati solo per le pagine interne 
		$("#fascia").css("top",arrow_AW+"px"); // Questi saranno abilitati solo per le pagine interne 
	}
	/* Setto la posizione... -- FINE */ 
	
	/* Setto la larghezza della topbar e dei suoi elementi-- INIZIO */ 
	$("#nav_topbar").css("width",winW+"px");
	$("#nav_topbar-container").css("width",winW+"px");
	$("#nav_topbarSX").css("width",const_WSX+"px");
	$("#nav_topbarDX").css("width",const_WDX+"px");
	$("#nav_topbarCT").css("width",width_CT+"px");
	$("#nav_topbar-menu").css("width",(winW-const_share)+"px");
	/* Setto la larghezza... -- FINE */ 			

	/* Setto la larghezza della bottombar e dei suoi elementi-- INIZIO */ 
	$("#nav_bottombar").css("top",(winH-const_height_bottom)+"px");
	$("#nav_bottombar").css("width",winW+"px");
	$("#nav_bottombar-container").css("width",winW+"px");
	$("#nav_bottombarSX").css("width",(const_WSX_bottom)+"px"); //padding-left di 8px
	$("#nav_bottombarDX").css("width",const_WDX_bottom+"px");
	$("#nav_bottombarCT").css("width",width_CT_bottom+"px");
	/* Setto la larghezza... -- FINE */ 			
}

function mCustomScrollbars(s_mainframe,l_parallasse){
	/*
	 * s_mainframe -- stringa - contiene il nome dell'identificatore DIV 
	 * 				  principale contenente il body principale del sito
	 * l_parallasse - true/false - Gestione della parallasse a 3 livelli
	 *                             item1, item2 e item3 (solo item3 può 
	 *                             contenere strutture XHTML.
	 */

	/* 
	Custom Scrollbar function parameters: 
	1) scroll type (values: "vertical" or "horizontal")
	2) scroll easing amount (0 for no easing)  - duration
	3) scroll easing type
	4) extra bottom scrolling space for vertical scroll type only (minimum value: 1)
	5) scrollbar height/width adjustment (values: "auto" or "fixed")
	6) mouse-wheel support (values: "yes" or "no")
	7) scrolling via buttons support (values: "yes" or "no")
	8) buttons scrolling speed (values: 1-20, 1 being the slowest)
	9) parallax - true/false
	*/
	if (l_parallasse) {
		$("#"+s_mainframe).mCustomScrollbar("horizontal",1000,"linear",1,"fixed","yes","yes",20,true); 
	} else {
		$("#"+s_mainframe).mCustomScrollbar("vertical",400,"easeOutCirc",1.05,"fixed","yes","yes",10,false); 
	}
}

// Cambia la foto della gallery - Pagina sfilata
function changeShowImage (folder,prefix,ext,imgID,duration) {
	/*
	 * folder --- cartella contenete le immagini
	 * prefix --- prefisso del nome dell'immagine (img01.jpg --> prefix="img")
	 * ext ------ estensione dell'immagine
	 * imgID ---- numero immagine corrente (contatore)
	 * duration - durata dell'animazione
	 */
	var fade_duration=duration;
	if ((imgID >= 1 ) && (imgID <= 9 )) { imgID='0'+imgID }
	$("#gallery").hide().css('background-image','url(../../'+folder+'/'+prefix+imgID+'.'+ext+')').show();
	$("#numID").hide().html(imgID).show();
			//$("#gallery").hide().css('background-image','url(../'+folder+'/'+prefix+imgID+'.'+ext+')').fadeIn(fade_duration);
	//$("#numID").hide().html(imgID).fadeIn(fade_duration);
}

// Cambia la foto della gallery - Pagina sfilata
function changeShowImageComunication (folder,prefix,ext,imgID,duration,txt) {
	/*
	 * folder --- cartella contenete le immagini
	 * prefix --- prefisso del nome dell'immagine (img01.jpg --> prefix="img")
	 * ext ------ estensione dell'immagine
	 * imgID ---- numero immagine corrente (contatore)
	 * duration - durata dell'animazione
	 */
	var fade_duration=duration;
	if ((imgID >= 1 ) && (imgID <= 9 )) { imgID='0'+imgID }
	$("#gallery").hide().css('background-image','url(../../'+folder+'/'+prefix+imgID+'.'+ext+')').show();
	$("#txt_archivio").html('<p>'+txt+'</p>').show();
	$("#ax").hide().html(txt.slice(0,2)).show();
	$("#ay").hide().html(txt.slice(2,4)).show();
	$("#numID").hide().html(imgID).show();
	
			//$("#gallery").hide().css('background-image','url(../'+folder+'/'+prefix+imgID+'.'+ext+')').fadeIn(fade_duration);
	//$("#numID").hide().html(imgID).fadeIn(fade_duration);
}
// Cambia la foto della gallery - Pagina catalogo
function changeSlideImage (folder,prefix,ext,imgID,duration,tasto) {
	/*
	 * folder --- cartella contenete le immagini
	 * prefix --- prefisso del nome dell'immagine (img01.jpg --> prefix="img")
	 * ext ------ estensione dell'immagine
	 * imgID ---- numero immagine corrente (contatore)
	 * duration - durata dell'animazione
	 * tasto ---- assume valore SX o DX a seconda di quale è premuto
	 */
	var effect_duration=duration;
	if ((imgID >= 1 ) && (imgID <= 9 )) { imgID='0'+imgID }
 	if (tasto=="SX") {
		$("#mcs_container").hide('slide', {direction: 'right'}, (effect_duration/2), function() {
			$(this).css('background','url(../../'+folder+'/'+prefix+imgID+'.'+ext+') center center no-repeat').show('slide', {direction: 'left'}, effect_duration);
		})
	}else{
		$("#mcs_container").hide('slide', {direction: 'left'}, (effect_duration/2), function() {
			$(this).css('background','url(../../'+folder+'/'+prefix+imgID+'.'+ext+') center center no-repeat').show('slide', {direction: 'right'}, effect_duration);
		})
	}
	$("#numID").hide().html(imgID).fadeIn(effect_duration);
}

