var num_prod=0;
var max_prod=1;

function gira_automatico(){
     
          num_prod= num_prod+1;
          if (num_prod>=max_prod){
               num_prod=0;
          }
          
          $("#wrapper_image_product img").fadeOut('fast');
          $("#wrapper_image_product img").eq(num_prod).fadeIn('fast');
          $(".number_slide").removeClass("label_selected");
          $(".number_slide").eq(num_prod).addClass("label_selected");
     
     setTimeout("gira_automatico()", 5000);
     
}

/*=====================
 
 SLIDESHOW IN HOMEPAGE
 
=======================*/

var current_image = 1;
var total_image =2;
total_image = total_image-1;

function ruotaimmagini () {
$('.slideshow_novita').eq(current_image).fadeOut('slow');	

if (current_image==total_image) {		
     $('.slideshow_novita').eq(0).fadeIn('slow');	
     }
else {
     $('.slideshow_novita').eq(current_image+1).fadeIn('slow');
     }

if(current_image==total_image){
     current_image=0;
     }
else{
     current_image++;	
     }

setTimeout("ruotaimmagini(current_image, total_image)",3500);
}



$(document).ready(function(){
     $('.slideshow_novita').hide();
     ruotaimmagini();
     var altezza_box1;
     var massimo = $(".testo_sx").length;
     
     for (var i=0; i<massimo; i++) {
          altezza_box1 = $(".testo_sx").eq(i).height();
          $(".testo_dx").eq(i).css("height",altezza_box1);
          }
     
     /*slider prodotti interno*/
     max_prod = $("#wrapper_image_product img").length;
     $("#wrapper_image_product img:not(:eq(0))").hide();
     $(".number_slide").eq(0).addClass('label_selected');     
     $(".number_slide").click(function(){
          num_prod= parseInt($(this).text()) -1; 
          $("#wrapper_image_product img").fadeOut('fast');
          $("#wrapper_image_product img").eq(num_prod).fadeIn('fast');
          $(".number_slide").removeClass("label_selected");
          $(this).addClass("label_selected");
          
          });
     
     setTimeout("gira_automatico()", 5000);
     
});



