$(function() {
		   
	// NAVIGATION - active	
	$('.navigation ul li a, .sub-nav ul li a').each(function() {
		if(this.href == window.location) {
			$(this).parent("li").addClass("current");	
		}
	});
	if((window.location+"").indexOf("Cat-Infographic.html") > -1) {
		$(".navigation > ul > li:eq(2)").addClass("current");	
	}
	
	$('.navigation ul li').hover(function() {
		$(this).addClass('active')						  
		$(this).find('ul').show()
		  }, function() {
		$(this).removeClass('active')
		$(this).find('ul').hide();
	});
	
	// Main media 
	$(".slides .slide").removeClass("active").fadeOut(0);
	$(".slides .slide:first").addClass("active").fadeIn(0);	
	$(".slides .controls div[class^='cont']").live("click",function() {
		if(!$(this).is(".active")) {
			$(".slides .slide").removeClass("active").fadeOut();
			$(".slides .slide:eq(" + $(this).index() + ")").addClass("active").fadeIn();
			$(".slides .controls div[class^='cont']").removeClass("active");
			$(this).addClass("active");
		}
	});
	
	// how can nutri-vet help: tabs
	$(".left-column .tabs .tab").live("click",function() {
		$(".left-column .tabs .tab").removeClass("active");
		$(".left-column .tabs .tab ul").hide();
		$(this).find("ul").show();		
		$(this).addClass("active");		
	});
	
	// featured products
	totalProducts = $(".products .overflow .product").length;	
	currentLeft = 0;
	function fadeControls() {
		currentLeft = parseInt($(".products .overflow").css("left"));		
		if(currentLeft > (totalProducts-5)*-120) { $(".products .right").fadeTo("fast",1);} else {$(".products .right").fadeTo("fast",.5);}
		if(currentLeft < 0) {$(".products .left").fadeTo("fast",1);} else {$(".products .left").fadeTo("fast",.5);}
	}; fadeControls();
	$(".products .overflow").css({width:totalProducts*120});
	$(".products .left").live("click",function() {
		if(currentLeft < 0) {$(".products .overflow").stop().animate({left:currentLeft+115},fadeControls)}
	});
	$(".products .right").live("click",function() {	// use 5 because its 1 higher than the total displayed at once
		if(currentLeft > (totalProducts-5)*-120) { $(".products .overflow").stop().animate({left:currentLeft-115},fadeControls)	}
	});
	
	// ticker
	$(".ticker .tick").hide();
	$(".ticker .tick:first").show();
	$(".ticker .controls span").live("click",function() {
		tickerActivate($(this).index()) 	;
		clearInterval(tickerLoop);
	});
	tickerIndex = 1;
	function tickerActivate(i) {
	$(".ticker .controls span").removeClass("active");
		$(".ticker .tick").hide();		
		$(".ticker .tick:eq(" + i + ")").show();
		$(".ticker .controls span:eq(" + i + ")").addClass("active");		
	}
	tickerLoop = setInterval(function() {
		tickerActivate(tickerIndex);
		tickerIndex = tickerIndex < $(".ticker .tick").length-1 ? tickerIndex+1:0;		
	},3000);
	
	
	// BACK TO TOP
	$('.back-to-top a').click(function(){
     	$('html, body').animate({scrollTop: '0px'}, 300);
    	return false;
	});
	
	// BREADCRUMBS {
	$('#breadcrumbs p a').after('<span>/</span>');	
	
	// CATEGORY PRODUCT IMAGES
	$('.item a img').attr('border' , '0');
	
});

