$(document).ready(function() {

if($('#myList').length){
  $('#myList').listnav();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//QUICK JUMP FUNCTIONALITY
/////////////////////////////////////////////////////////////////////////////////////////////////////////

    //set up tab options
	var tabOpts = {
	  fx: {
		opacity: "toggle",
		duration: "fast" 
	  }, 
	  collapsible: true, 
	  selected: null
	};
	
	$(function() {
		
		$("#tabs").tabs(tabOpts);
		$("#tabs-2").tabs(tabOpts);
		$('#tabs-2" > ul').tabs();				
	});

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//SEARCH FUNCTIONALITY
/////////////////////////////////////////////////////////////////////////////////////////////////////////


	//hide the search box 
	$('#form').children().hide();
	$('#close').hide();
	
	//search box down on hover
	$('#search').hover(function() {
									
			$(this).animate({height: "85px"}, 350);
			$('#searchBackground').animate({height: "85px"}, 340, 
				
				function(){ 
				
				$('#form').children().fadeIn(150);
				$('#close').fadeIn(150);
				
			});
				
	});
	
	//close the search box
	$('#close').click(function() {
			
			$('#search').animate({height: "9px"}, 250);
			
			$('#close').fadeOut(50, 
				
				function(){ 
				
				$('#searchBackground').animate({height: "38px"}, 250);
			$('#form').children().fadeOut(110);
				
			});
			
	});
	
	
	
	//clear default values on search form
	(function($){
		$.fn.clearDefault = function(){
			return this.each(function(){
				var default_value = $(this).val();
				$(this).focus(function(){
					if ($(this).val() == default_value) $(this).val("");
				});
				$(this).blur(function(){
					if ($(this).val() == "") $(this).val(default_value);
				});
			});
		};
	})(jQuery);

	$('input.txtSearchC').clearDefault();
	
	
	
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//VARIOUS CYCLERS
/////////////////////////////////////////////////////////////////////////////////////////////////////////

//homepage recipes
	$('#cycler').cycle({ 
		fx:     'scrollHorz', 
		speed:  600, 
		next:   '#next', 
		prev:   '#prev', 
		timeout: 5000, 
		//change back to 7000 to start automatic scroll
		cleartypeNoBg: true,
		// callback fn to remove auto pager anchors
		pagerAnchorBuilder: function(idx, slide) { return ''; }
		
	});

//homepage heros images
	$('#cyclerHero').cycle({ 
		fx:     'fade', 
		speed:  500, 
		next:   '#next', 
		prev:   '#prev', 
		timeout: 5000, 
		//change back to 7000 to start automatic scroll
		cleartypeNoBg: true,
		cleartype:  1,
		// callback fn to remove auto pager anchors
		pagerAnchorBuilder: function(idx, slide) { return ''; }
		 
	});
	
//product landing page products 
	$('#cyclerProducts').cycle({ 
		fx:     'scrollHorz', 
		speed:  600, 
		next:   '#next', 
		prev:   '#prev', 
		timeout: 5000, 
		//change back to 7000 to start automatic scroll
		cleartypeNoBg: true,
		// callback fn to remove auto pager anchors
		pagerAnchorBuilder: function(idx, slide) { return ''; }
		
	});


/////////////////////////////////////////////////////////////////////////////////////////////////////////
//SORT RECIPES BY PRODUCT DROP DOWN
/////////////////////////////////////////////////////////////////////////////////////////////////////////

	$('#productList').hide();

	$('#sort').hover(function() {
		 
		 $('#productList').slideDown('fast');
		
		 }, function() {
		 
		 $('#productList').slideUp('fast');
		 
	});
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//VOTING STARS
/////////////////////////////////////////////////////////////////////////////////////////////////////////

	$('.star').hover(function() {
		 
		 $(this).fadeTo('fast', .5);
		
		 }, function() {
		 
		 $(this).fadeTo('fast', 1);
		 
	});

});
