// Activate jCarousel
function dishInit(carousel) {
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
    carousel.startAuto(0);
	});

	carousel.buttonPrev.bind('click', function() {
    carousel.startAuto(0);
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
    carousel.stopAuto();
	}, function() {
    carousel.startAuto();
	});
};

$(function() {
  // Google Analytics
  $.getScript((("https:" == document.location.protocol) ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js", function() {  
    var pageTracker = _gat._getTracker("UA-1215192-3");
    pageTracker._initData();
    pageTracker._trackPageview();
  });

	// User Voice
	// $.getScript("http://localdish.uservoice.com/pages/general/widgets/tab.js");

	// Disqus
	// window.disqus_no_style = false;
	// $.getScript("http://localdish.disqus.com/embed.js");

  // REST
  $.rest();

	// Tools
	$("a.show, a.new, a.edit, a.destroy").tooltip();

	// Buttons
	$(".button").button();

	// Dropdown Menus
	function menu() {
	  $(" #nav ul ").css({display: "none"}); // Opera Fix
	  $(" #nav li").hover(
	    function() { $(this).find('ul:first').css({visibility: "visible", display: "none"}).show(400); },
	    function() { $(this).find('ul:first').css({visibility: "hidden"}); }
	  );
	}
  menu();
  
	// PNG Fix
	$(document).pngFix();
	
	// jCarousel
  $("#dishes").jcarousel({
    auto: 6,
    wrap: "last",
    animation: "slow",
    initCallback: dishInit
  });
});
