$(document).ready(function(){
		// Cycle the home tabs
		$('#featured-tabs-container') 
		.after('<ul id="featured-tabs-selectors">') 
		.cycle({ 
			 	cleartype:  1, 
				timeout: 10000, 
				effect: 'fade',
				speed: 500,
				pause: true,
		    pager:  '#featured-tabs-selectors',
				pagerEvent:   'click',
		    pagerAnchorBuilder: function(idx, slide) { 
		        return '<li class="' + jQuery(slide).attr("id") + ' "><a href="#"><span class="wrap">' + jQuery(slide).find("div.tab-text").html() + '</span></a></li>'; 
		    }
		});
		
		var randomSlide = Math.ceil(Math.random() * ($('#voices-wrapper .voices-cycle').length));		
		$('#voices-wrapper').cycle({ 
				 	cleartype:  1, 
					timeout: 10000, 
					effect: 'fade',
					speed: 500,
					next:   '#next-voice', 
			    prev:   '#prev-voice',
			    pause: true,
    			startingSlide: randomSlide
		 });
		
		var randomNutritionSlide = Math.ceil(Math.random() * ($('#nutrition-tips').length));		
		$('#nutrition-cycle').cycle({ 
				 	cleartype:  1, 
					timeout: 10000, 
					effect: 'fade',
					speed: 500,
					next:   '#next-nutrition', 
			    prev:   '#prev-nutrition',
			    pause: true,
		    	startingSlide: randomNutritionSlide
		 });
		
		$('#featured-recipe-image').cycle({ 
					timeout: 8000, 
					effect: 'fade',
					speed: 500,
			    pause: true
		 });

		$('#featured ul').hover(function(){
			$('#featured-tabs-container').cycle("pause");
		}, function(){
			$('#featured-tabs-container').cycle("resume");
		});
		
		//Rotate ads in Shop Healthy

		$('#wrapper-shop-ad-main').innerfade({ 
			speed: 1000, 
			timeout: 7000, 
			type: 'sequence', 
			containerheight: '349px' 
		});
		$('#wrapper-sub-ad').innerfade({ 
			speed: 1000, 
			timeout: 7000, 
			type: 'sequence', 
			containerheight: '167px' 
		});
	  //IE drop down fix
	  if (document.all) {
	    $("#nav > li").hoverClass("sfHover");
	  }
  // POPUPS
  $(".popup").click(function(){        
    window.open($(this).attr("href"), "popup1","width=550, height=500, toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes"); 
    return false;     
  });
  $(".popupMini").click(function(){        
      window.open($(this).attr("href"), "popup2","width=400, height=200, toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes"); 
      return false;     
  });
  $(".popupLarge").click(function(){        
        window.open($(this).attr("href"), "popup3","width=700, height=500, toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes"); 
        return false;     
  });

	$('#search-categories-container').hide();
	$('#search-categories-bar-container').hide();
	$('#btn-categories').click(function () {
    $(this).parent().next().toggle();
    $(this).toggleClass('open');
    return false;
	});

});
$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c); }
        );
    });
};

  