$(document).ready(function() {
       $('#imgHeader').hide();
       
    
       $('#imgHeader').fadeIn( 'slow');
       // hides the slickbox as soon as the DOM is ready
        $('#content1').hide();
        $('#content2').show();
        $('#content3').hide();
        $('#content4').hide();
        $('#content5').hide();
        $('#content6').hide();

var content1 = "close";
var content2 = "open";
var content3 = "close";
var content4 = "close";
var content5 = "close";
var content6 = "close";


  $("#toggleContent1").click(function() {
      $('#content1').toggle('slow');
      var fotoNew = "monteforte-alpone.jpg";
          if(content1 == "close"){
              chiudiTutti();
              changeBgHeader(fotoNew);
              content1 = "open";
          }else{
              content1 = "close";
          }
          showHideMenuVini();
     return false;
   });
   $("#toggleContent2").click(function() {
      $('#content2').toggle('slow');
      var fotoNew = "mezzane-lessini.jpg";
          if(content2 == "close"){
              chiudiTutti();
              changeBgHeader(fotoNew);
              content2 = "open";
          }else{
              content2 = "close";
          }
          showHideMenuVini();
      return false;
   });
   $("#toggleContent3").click(function() {
      $('#content3').toggle('slow');
      var fotoNew = "uve-bianche-soave.jpg";
          if(content3 == "close"){
              chiudiTutti();
              changeBgHeader(fotoNew);
              content3 = "open";
          }else{
              content3 = "close";
          }
          showHideMenuVini();
      return false;
   });
   $("#toggleContent4").click(function() {
      $('#content4').toggle('slow');
      var fotoNew = "uve-nere-bio.jpg";
          if(content4 == "close"){
              chiudiTutti();
              changeBgHeader(fotoNew);
              content4 = "open";
          }else{
              content4 = "close";
          }
          showHideMenuVini();
      return false;
   });
   $("#toggleContent5").click(function() {
      $('#content5').toggle('slow');
      var fotoNew = "emozioni-giallo.jpg";
          if(content5 == "close"){
              chiudiTutti();
              changeBgHeader(fotoNew);
              content5 = "open";
          }else{
              content5 = "close";
          }
          showHideMenuVini();
      return false;
   });
   $("#toggleContent6").click(function() {
      $('#content6').toggle('slow');
      var fotoNew = "energia-della-vigna.jpg";
          if(content6 == "close"){
              chiudiTutti();
              changeBgHeader(fotoNew);
              content6 = "open";
          }else{
              content6 = "close";
          }
          showHideMenuVini();
      return false;
   });
   
   function changeBgHeader(fotoNew){
     // $("#result").html(fotoOld + "<br />" + fotoNew);
        $('#imgHeader').fadeOut( 'slow', function(){
                $(this).css("background-image","url(media/header/"+ fotoNew +")").fadeIn('slow');
             }) ; 
   }
   function chiudiTutti(){

       if(content1=="open"){
            $('#content1').toggle('fast');
            content1 = "close";
       }
        if(content2=="open"){
            $('#content2').toggle('fast');
             content2 = "close";
       }
        if(content3=="open"){
            $('#content3').toggle('fast');
             content3 = "close";
       }
        if(content4=="open"){
            $('#content4').toggle('fast');
             content4 = "close";
       }
        if(content5=="open"){
            $('#content5').toggle('fast');
             content5 = "close";
       }
        if(content6=="open"){
            $('#content6').toggle('fast');
             content6 = "close";
       }
   }       

   function showHideMenuVini(){
         if(content1 == "close" && content2 == "close"  && content3 == "close"  && content4 == "close"  && content5 == "close"  && content6 == "close"){
                $('#valpolicella').hide('slow');
                  $('#soave').hide('slow');
            }else{
                $('#valpolicella').show('slow');
                  $('#soave').show('slow');
            }
   }
  
   /* MENU VINI  */
$(".btnValpoMenu").fancybox({
        'width': '95%',
        'height': '95%',
        'autoScale': true,
        'opacity':true,
        'margin':'0',
        'padding':'0',
        'overlayColor':'#fff',
        'overlayOpacity':'0.7',
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'type'	: 'iframe',
        'showCloseButton':true
});
$(".btnSoaveMenu").fancybox({
        'width': '95%',
        'height': '95%',
        'autoScale': true,
        'opacity':true,
        'margin':'0',
        'padding':'0',
        'overlayColor':'#fff',
        'overlayOpacity':'0.7',
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'type'	: 'iframe',
        'showCloseButton':true
});

$(function(){
    $("#ottonome").stop().animate({bottom:"-30px",right:"80px",width:"0px",opacity:"0"}, {duration:0})
    $('#ottoimg')
        .mouseover(function(){
                $("#ottonome").stop().animate({bottom:"0px",right:"80px",width:"120px",opacity:"1"}, {duration:400})
        })
        .mouseout(function(){
                $("#ottonome").stop().animate({bottom:"-30px",right:"80px",width:"0px",opacity:"0"}, {duration:200})
        })
});

$('#superiore').hide();
$('#ripasso').hide();
$('#amarone').hide();
$('#otto').hide();
$('#staforte').hide();
$('#montegrande').hide();
$('#sanantonio').hide();
$('#recioto').hide();


});

function mostraNomeVino(riferimento){
   $("#"+riferimento).show();
}
function nascondiNomeVino(riferimento){
   $("#"+riferimento).hide();
}

