
$(document).ready(function(){
	$("ul li:first-child").addClass("first");
	$("ul li:last-child").addClass("last");
	setupHomeNav();
	$('#related_products').jcarousel();
  setupGallery();
  $(".recipeLink").colorbox({iframe:true, innerWidth:"630px", height:"344px", scrolling: false});
});

function setupHomeNav() {
  $(".home-nav li").mouseover(function() {
	  $(this).animate({
	    width: "375px"
	    },
	    { queue:false, duration:500 }
	    );
	  $(this).siblings().animate({
  	    width: "142px"
  	    }, 
  	  { queue:false, duration:500 }
  	  );
	});
	
  $(".home-nav").mouseout(function() {
    $(".home-nav li").animate({
      width: "188px"
      },
    { queue:false, duration:500 }
    );
  });
  
  $(".product-nav li").mouseover(function() {
   // var linkClass = this.className;
  //  var linkName = linkClass.match(/page-item-[0-9]+/);
    var index = $(".product-nav li").index(this);
    var item = $(".home-nav li").get(index)
    $(item).trigger("mouseover");
  });
  
  $(".product-nav").mouseout(function() {
    $(".home-nav").trigger("mouseout");
  });
  
}

function setupGallery() {
  $('#product_gallery .thumbnails li:not(.embed_link)').click(function() {
    var source = $(this).children('img').attr('src');
    var alt = $(this).children('img').attr('alt');
    $('#product_gallery .main_image img').attr('src', source).attr('alt', alt).show();
    $('#product_gallery .embed').hide();
  });
  $('#product_gallery .thumbnails li.embed_link').click(function() {
    $('#product_gallery .embed').show();
    $('#product_gallery .main_image img').hide();
  });
}