$(document).ready(function() {
	
	// tab speed
	var ts = 100;
	// tab init position
	var tip = '-10px';
	// tab hover position
	var thp = '0px';
	// auto scroll speed
	var ass = 100;
	
	// slide nav tabs out/in on hover
	$('.featured_nav a').hover(function(){
			// reset all tab positions
			$('.featured_nav_industrial a').animate({right: tip}, ts);
			$('.featured_nav_erosion a').animate({right: tip}, ts);
			$('.featured_nav_landfill a').animate({right: tip}, ts);
			$('.featured_nav_cellulose a').animate({right: tip}, ts);
			
			// animate currently hovered tab
			$(this).animate({right: thp}, ts);
			
			// Set current tab to a variable number
			if($(this).parent().hasClass('featured_nav_industrial')) {
				var p = 0;
			} else if ($(this).parent().hasClass('featured_nav_erosion')) {
				var p = 1;
			} else if ($(this).parent().hasClass('featured_nav_landfill')) {
				var p = 2;
			} else if ($(this).parent().hasClass('featured_nav_cellulose')) {
				var p = 3;
			}
			
			// move graphic slider to current hovered tab and stop auto scroll
			$(".featured_graphic").scrollable().seekTo(p, ass).stop();
		
		},function(){
			
			// reset tab position on hover off and start auto scroll again
			$(this).animate({right: thp}, ts);
			$(".featured_graphic").scrollable().play();
	
	});
	
	// init scolling and starting tab
	$(".featured_graphic").scrollable({circular: true}).autoscroll({ interval: 5000, autoplay: true });
	$(".featured .items").css('left', '-613px');
	$('.featured_nav_industrial a').animate({right: thp}, ts);
	
	// move tabs out on auto scroll
	$(".featured_graphic").scrollable().onSeek(function(){
    var tab = $(".featured_graphic").scrollable().getIndex();
    if(tab == 0){
        $('.featured_nav_industrial a').animate({right: thp}, ts);
        $('.featured_nav_erosion a').animate({right: tip}, ts);
        $('.featured_nav_landfill a').animate({right: tip}, ts);
        $('.featured_nav_cellulose a').animate({right: tip}, ts);
    } else if (tab == 1) {
			$('.featured_nav_industrial a').animate({right: tip}, ts);
			$('.featured_nav_erosion a').animate({right: thp}, ts);
			$('.featured_nav_landfill a').animate({right: tip}, ts);
			$('.featured_nav_cellulose a').animate({right: tip}, ts);
    } else if (tab == 2) {
			$('.featured_nav_industrial a').animate({right: tip}, ts);
			$('.featured_nav_erosion a').animate({right: tip}, ts);
			$('.featured_nav_landfill a').animate({right: thp}, ts);
			$('.featured_nav_cellulose a').animate({right: tip}, ts);
    } else if (tab == 3) {
			$('.featured_nav_industrial a').animate({right: tip}, ts);
			$('.featured_nav_erosion a').animate({right: tip}, ts);
			$('.featured_nav_landfill a').animate({right: tip}, ts);
			$('.featured_nav_cellulose a').animate({right: thp}, ts);
    }
	});
	
});

