<!-- INIZIALIZZA SHADOWBOX -->
Shadowbox.init({
	overlayOpacity :  0.8,
	continuous     :  true,
	handleOversize : "resize",					
	skipSetup      :  true
});

<!-- SHOW FEATURES -->
function show_features(code) {
    Shadowbox.open({
        content:  "features.php?code=" + code + "&iframe=1",
		player:   "iframe",
        height:   300,
        width:    500
    	});
	}
	
<!-- SHOW FEATURES -->
function show_picture(code,my_title) {
    Shadowbox.open({
        content        : "<img src='images/products/" + code +"_l.jpg' />",
		player         : "html",
		title          : my_title,
		handleOversize : "resize",
        height:   600,
        width:    600
    	});
	}

<!-- SHOW SHEET -->
function show_sheet(code) {
	// LOADING
	$("#sheet_loading").css("display", "block");
	if(code == "accessories") { var my_url = "accessori"; } else { var my_url = "scheda"; }
	// PRODOTTI
	$.ajax({
		type : "POST",
		url  : my_url + ".php",
		data : "code=" + code,
		success: function(response){
			$("#box_wrapper").html(response);
			}
		});
	}

<!-- INIZIALIZZA GALLERY -->
  $(function() {
    var galleries = $('.ad-gallery').adGallery();
    $('#switch-effect').change(
      function() {
        galleries[0].settings.effect = $(this).val();
        return false;
      }
    );
    $('#toggle-slideshow').click(
      function() {
        galleries[0].slideshow.toggle();
        return false;
      }
    );
    $('#toggle-description').click(
      function() {
        if(!galleries[0].settings.description_wrapper) {
          galleries[0].settings.description_wrapper = $('#descriptions');
        } else {
          galleries[0].settings.description_wrapper = false;
        }
        return false;
      }
    );
  });
  
<!-- MARGINI / PADDING -->
$("p:first").css("margin-top","0");
$("p:last").css("margin-bottom","0");
$(".ad-thumbs li:nth-child(3n)").css("padding-right","0");
$(".item:last").css("margin-right", "0");


<!-- PROMO -->
function promo(my_margin) {
	$('#promo_wrapper').animate({ marginLeft: my_margin },500,'swing');
	}
	
<!-- PROMO -->
function thumbs(my_margin) {
	$('.ad-thumbs').animate({ marginTop: my_margin },500,'swing');
	}	
	
<!-- SLIDE -->
      $(function() {        
		//vars
		var conveyor = $(".slider_conveyor", $("#slider_content")), item = $(".item", $("#slider_content"));		
		//set length of conveyor
		conveyor.css("width", item.length * (parseInt(item.css("width")) + 10));				
        //config
        var sliderOpts = {
			max: (8720),
			//max: (item.length * parseInt(item.css("width"))) - parseInt($(".viewer", $("#slider_content")).css("width")),
        	slide: function(e, ui) { conveyor.css("left", "-" + ui.value + "px"); }
        	};
        //create slider
        $("#slider").slider(sliderOpts);
      });

<!-- NEWS LETTER -->
function news_letter() {
	// LOADING
	$("#newsletter_loading").css("display", "block");
	$("#newsletter_box").css("display", "none");
	// RECUPERA DATI DAL FORM
	if(document.newsletter.action[0].checked == true) {
		var action = "iscrizione";
		} else 	if(document.newsletter.action[1].checked == true) {
		var action = "cancellazione";	
		}
	var email  = document.getElementById("email").value;
	//
	$.ajax({
		type : "POST",
		url  : "newsletter.php",
		data : "action=" + action + "&email=" + email,
		success: function(response){
			$("#newsletter_loading").css("display", "none");
			$("#newsletter_result").html(response);
			}
		});
	}		
	
<!-- 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}, 1000, function() {
            $active.removeClass("active last-active");
        });
	}
$(function() { setInterval( "gallery()", 3500 ); });	
	
