<!-- INIZIALIZZA SHADOWBOX -->
Shadowbox.init({
	overlayOpacity :  0.8,
	continuous     :  true,
	handleOversize : "resize",					
	skipSetup      :  true
});

<!-- NEWSLETTER AJAX -->
function newsletter() {	
    $("#loading").css("display", "block");
	$("#message").css("display", "none");
	//
	$.ajax({
		type: "POST",
		url: "newsletter.php",
		data: "email=" + document.getElementById("email").value,
		success: function(response){
		$("#message").fadeIn();
		$("#message").html(response);
		$("#loading").css("display", "none");
		}
	});	
	}

<!-- GALLERY -->	
function gallery() {
    var $active = $("#slideshow IMG.active");
    if ( $active.length == 0 ) $active = $("#slideshow IMG:last");
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $("#slideshow IMG:first");
    // uncomment the 3 lines below to pull the images in random order    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );
    $active.addClass("last-active");
    $next.css({opacity: 0.0})
        .addClass("active")
        .animate({opacity: 1.0}, 2000, function() {
            $active.removeClass("active last-active");
        });
	}
$(function() {
	// SE CI SONO PIU' DI DUE IMMAGINI PARTE LO SLIDE
	if($("#slideshow IMG").length > 1) { setInterval( "gallery()", 4000 ); }
});

$(document).ready(function() {
	// RESET INPUT FIELD
	$("input[type=text]").focus(function(){
	  $(this).attr("value","");
	});	
	$("textarea").focus(function(){
	  $(this).attr("value","");
	});
	// ROLLOVER	
	$(".section_button_a").mouseover(function() { $(this).parent("li").addClass("current"); $(this).css("color", "#FFF"); });
	$(".section_button_a").mouseout(function() { $(this).parent("li").removeClass("current"); $(this).css("color", "#999"); });
	// ROLLOVER M4U
	if($("#m4u_wrapper").length > 0) {
		$("#m4u_wrapper").mouseover(function() { $("#m4u_out").fadeOut("slow")});
		$("#m4u_wrapper").mouseleave(function()  { $("#m4u_out").fadeIn("slow")});
		}
	// FIRST PARAGRAPH
	$("#section p").first().css("margin", "0");
	$(".subsection p:first-child").css("margin", "0");
	// CURTAIN
	$("#market_button").hoverIntent({
		timeout: 10,
		over: function () { $("#curtain").slideDown(200); },
		out: function ()  { $("#curtain").fadeOut(200);   }
	});
	// FIRST CHOICE
	if($("#profilo").length > 0) {
		$("#profilo").children("a").css("color", "#006FB7");
		}
	// SUBNAV BUTTON
	$(".subnav_button").click(function(event) {
		// ABBASSA IL SOTTOMENU
  		$(this).children("ul").slideDown(300);
		var count_subsections = $(this).children("ul").length;
		// SE NON CI SONO SOTTOSEZIONI MOSTRA DIRETTAMENTE LA SEZIONE PADRE
		if(count_subsections == 0) {
			// COLORA TASTO CORRENTE
			$(".subnav_button").children("a").css("color", "#999999");
			$(".subsubnav_button").children("a").css("color", "#999999");
			$(this).children("a").css("color", "#006FB7");		 
		// MOSTRA SEZIONE			
			$(".subsection").css("display", "none");
			var div_to_show = this.id + "_content";
  			$("#" + div_to_show).css("display", "block");
			// NASCONDE TESTO INTRODUTTIVO
			$("#intro").css("display", "none");
			}
		});
	// SUBSUBNAV BUTTON
	$(".subsubnav_button").click(function(event) {
		// COLORA TASTO CORRENTE
		$(".subnav_button").children("a").css("color", "#999999");
		$(".subsubnav_button").children("a").css("color", "#999999");
		$(this).children("a").css("color", "#006FB7");
		// NASCONDE TESTO INTRODUTTIVO
		$("#intro").css("display", "none");		
		// MOSTRA LE SOTTOSEZIONI
		$(".subsection").css("display", "none");
		var div_to_show = this.id + "_content";
  		$("#" + div_to_show).css("display", "block");
		});			
	});

// CHANGE REGION
function change_region(picture,label) {
	//
	$("#region_intro").css("display", "none");
	$("#region_form").css("display", "block");
	//
	var image_url = "images/map/" + picture + ".jpg";
	$("#italy").attr("src",image_url);
	//
	document.getElementById("region_picture").value = picture;
	document.getElementById("region_label").value = label;
	}
