$(document).ready( function(){
  
  //  Swap dei box in home page
  
//   $(".box").each( function(){
//     
//     $(this).mouseenter( function(){
//       
//       var b = this
//       $("img", b).css("display", "none")
//       $(".testo", b).css("display", "block")
//                 
//     })
//    
//     $(this).mouseleave( function(){
//       
//       var b = this
//       $(".testo", b).css("display","none")
//       $("img", b).css("display", "block")      
//       
//     });        
//     
//   })
  
});             
function mainmenu(){
jQuery("#nav ul").css({display: "none"}); // Opera Fix
jQuery(" #nav li").hover(function(){
		jQuery(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).slideDown(200);
		},
    function(){
		jQuery(this).find('ul:first').slideUp(200).css({display: "none"});
		}
    );
}

function popupVideo(){

  jQuery(".maschera").click( function(){
      
      scheda = $(this).attr("id").replace("maschera", "scheda");
          
      if( jQuery("#maschera_popup").length == 0){
        jQuery("body").append("<div id='maschera_popup'>&nbsp;</div><div id='scheda_popup'&nbsp;</div>");
      }
      
      jQuery("#maschera_popup").css({
        "background-color": "#000",
        width:      $(window).width() + "px",
        height:     $(document).height() + "px",
        display:    "block",
        position:   "absolute",
        left:       0,
        top:        0,
        "z-index":  100,
        opacity:    0.5
      });
      
      jQuery("#scheda_popup").html("");
                         
      out = "<div class='scheda' style='display:block;text-align:center;'><iframe style='display:block;' width='335' height='275' frameborder='0' allowfullscreen='' src='http://www.youtube.com/embed/" + jQuery(this).attr("rel") + "'></iframe><p><button onclick='javascript:popup_chiudi()'>chiudi</button></p></div>";
      
      jQuery("#scheda_popup").html( out );
      
      jQuery("#scheda_popup").css({
        position: "absolute",
        left: ( $(window).width() - $("#scheda_popup").width() ) / 2 + "px",
        top: $(document).scrollTop() + ( ($(window).height() - $("#scheda_popup").height() ) / 2 ) + "px",
        "z-index": 101,
        "display": "block",
        "background-color": "#FFF"
      });
      
    })
    
}

function popup_chiudi(){
  jQuery("#maschera_popup, #scheda_popup").css("display", "none")
}

function selezionaProdotto( trigger ){
  
  var img = $("#"+trigger).children("img");
  var ul = $("#"+trigger).children("ul");  

  ul.css({height: img.height(), width: img.width() });
  ul.children("li").css({border:0,display:"block",height:"auto"});
  ul.children("li:eq(1)").css({"border-top" : "1px solid #445660"}); 
    
  $("#"+trigger).hover(
    function(){
      img.hide();
      ul.show();      
    },
    function(){
      ul.hide();
      img.show();        
    }
  );
  

  

  

  
}
