aperto = true;
	
//Adjust image size
function resizenow() {
	// Opzioni
	var min_width = 1400; //Min width allowed (in pixels)
	var min_height = 744; //Min height allowed (in pixels)
	var fit_landscape = false; //Landscape images will not exceed browser width
	var fit_portrait = false; //Portrait images will not exceed browser height
	var horizontal_center = false; //Horizontally center background
	var vertical_center = false; //Vertically center background
	var image_protect = true; //Disables image dragging and right click with Javascript
	
	
	//Prelevo le dimensioni dell'immagine attuale per la ratio
	img = $("#sfondo").attr('src');
	myImage = new Image();
	myImage.src = img;
	if (myImage.width) {
		img_width = myImage.width
	} else  {
		img_width = min_width
	}
	if (myImage.height) {
		img_height = myImage.height
	} else  {
		img_height = min_height
	}
	//alert(img);
	//var ratio = ($("#sfondo").height()/$("#sfondo").width()).toFixed(2);	//Define image ratio
	var ratio = (img_height/img_width).toFixed(2);	//Define image ratio


	//Gather browser size
	var browserwidth = $(window).width();
	var browserheight = $(window).height();
	var offset;
	
	//Resize image to proper ratio
	if ((browserheight > min_height) || (browserwidth > min_width)){	//If window larger than minimum height or width
		if ((browserheight/browserwidth) > ratio){
			
			if (fit_landscape && ratio <= 1){	//If landscapes are set to fit
				$("#sfondo").width(browserwidth);
				$("#sfondo").height(browserwidth * ratio);
			}else{										//Otherwise handle normally
				$("#sfondo").height(browserheight);
				$("#sfondo").width(browserheight / ratio);
			}
		
		} else {
		
			if (fit_portrait && ratio > 1){	//If portraits are set to fit
				$("#sfondo").height(browserheight);
				$("#sfondo").width(browserheight / ratio);
			}else{										//Otherwise handle normally
				$("#sfondo").width(browserwidth);
				$("#sfondo").height(browserwidth * ratio);
			}
		
		}	//End dynamic resizing
		
	}	//End minimum size check


	//Horizontally Center
	if (horizontal_center){
		$("#sfondo").css('left', (browserwidth - $("#sfondo").width())/2);
	}
	
	//Vertically Center
	if (vertical_center){
		$("#sfondo").css('top', (browserheight - $("#sfondo").height())/2);
	}
		
	//Basic image drag and right click protection
	if (image_protect){
		$("#sfondo").bind("contextmenu",function(){
			return false;
		});
		$("#sfondo").bind("mousedown",function(){
			return false;
		});
	}

	return false;
		
};


// Cambio sfondo e thumb selezionata	
function Cambia_sfondo(img) {
	$("#sfondo").fadeOut("slow", function() {$("#sfondo").attr('src',img); });
	resizenow();
	$("#mycarousel a").click(function() { $("#mycarousel a").removeAttr('class','active_thumb'); $(this).addClass('active_thumb'); });
	$("#sfondo").fadeIn("slow");
}


// Chiusura del content	
function Chiudi_apri_content() {
	$("#content").fadeOut("slow");
}

function Riduci_apri_content() {

	if (aperto) {
		$("#content_resize a").attr('id','content_resize_max');
		$("#content_text").fadeOut("slow");
		//setTimeout('$("#content").addClass("ridotto")', 1000); 
		$("#content").addClass("ridotto"); 
		aperto=false;
	} else {
		$("#content_resize a").attr('id','content_resize_min');
		$("#content").removeClass("ridotto");
		$("#content_text").fadeIn("slow");
		aperto=true;
	}

}

