$(document).ready(function() {

  $("#header-bg").click(function() {
    window.location = '/';
    //$(this).css("cursor","pointer");
  });
  $("#header-bg").hover(function() { 
    $(this).css("cursor","pointer");
  });

  $("#main-nav li:first-child").not('.sub_first').not('.sub_last').addClass("first");
  $("#main-nav li:last-child").not('.sub_last').not('.sub_first').addClass("last");
  
  // SLIDER VINI HOME
  $('#slider').movingBoxes({
    startPanel   : 1,      // start with this panel
    width        : 206,    // overall width of movingBoxes (not including navigation arrows)
  panelWidth   : 0.9,       // current panel width adjusted to 50% of overall width
    imageRatio   : 1/3,      // Image ration set to 1:1 (square image)
    wrap         : false,   // if true, the panel will "wrap" (it really rewinds/fast forwards) at the ends
    buildNav     : false,   // if true, navigation links will be added
    panelType    : '> li', // selector to find the immediate ">" children "li" of "#slider" in this case
  fixedHeight  : false
   });
   
 /*  if($('ul#main-nav li ul li.sub_active').length ){
    $('ul#main-nav li ul li.sub_active').parent().fadeToggle('slow','swing');
   }*/
   if($('ul#main-nav li.active').length){
     $('ul#main-nav li.active ul').fadeToggle('slow','swing');
   }
   
  // SUBMENU TOGGLE EFFECT
 /* $('ul#main-nav li:not(.active)').not('ul li.sub_active').hover(
    function(){
    if($(this).find('ul').length){
      if(!$(this).hasClass('active')){
      
        $(this).addClass('active hover');
      }
        $(this).find('ul').fadeToggle('slow','swing');
     //$(this).find('ul').toggle('slow');
      }
    },
  function () {
     $(this).parent().find('li.active.hover').find('ul').hide();
   if($(this).hasClass('hover')){
       $(this).removeClass('active hover');
   }
  });*/
  
   $('.central-column p').each(function (i) {
      if (i != 0) $(this).addClass("no-mini");
     });
     
   
  
    $('.news-list-item a').each(function (i) {
       if($(this).attr('rel')!=''){
          $(this).attr("rel","lightbox[lb1]");
       }     
   });

  
   $(".central-column p").not('.no-mini').miniature();
  
   $(".bottle a").click(function(){
     $('.bottle').unbind('mouseenter mouseleave');
     var pos = $(this).parent().position().left+30+'px';     
     $('.speech-arrow').animate({marginLeft: pos}, 'slow');
    var index = $(this).parent().parent().index();
    $('.speech ul li').each(function(i) {
      $(this).hide();
      if(i == index){
        $(this).fadeIn('slow');
      }
      });
      
     return false;
   });
   
/*   $(".bottle").hover(
   function(){    
       var pos = $(this).position().left+30+'px';
      $('.speech-arrow').animate({marginLeft: pos}, 'slow');
    var index = $(this).parent().index();
    $('.speech ul li').each(function(i) {
      $(this).hide();
      if(i == index){
        $(this).fadeIn('slow');
      }
      });

     
     return false;
   },
   function(){
     return false;
   });
   */
   
});

jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle', height: ['toggle', 'swing']}, speed, easing, callback);

}; 

