
var feat = {
	timer : null,
	delay : 6000,
	t : 0,

	init : function()
	{
		feat.triggers = $('#slide-nav a');
		feat.trigger_first = $('#slide-nav a:first');
		feat.trigger_last = $('#slide-nav a:last');
		
		feat.items = $('#feature .slide');

		feat.triggers.mouseover( function(){ feat._slide(this); feat._stop(); return false; });
		feat.triggers.mouseout( function(){ feat._slide(this); return false; });
		
		$('#slide-1').css({"top":"0", "opacity":"1"}); //initializes the first slide to show
		
		
		feat._automate();
	},
	
	_automate : function()
	{
		var most = feat.triggers.length;
		target = $('#slide-nav a:eq('+ feat.t +')'); // sets the target equal to index (0) of list
		feat._slide(target);
		feat.t++;
		if ( feat.t == most )
			feat.t = 0; // resets target index to 0 when reaching end of list
		feat.timer = setTimeout( function(){ feat._automate() }, feat.delay );
	},
	
	_stop : function()
	{
		feat.timer = clearTimeout(feat.timer);
		 
	},

	_slide : function(el)
	{
		var target = $(el).attr('rel'); //sets current target (hidden navigation link)
		feat.triggers.not(el).removeClass('active');

		$(el).addClass('active');
		$(target).animate({'top':'0px', 'opacity':'1'},{queue:false,duration:300});

		$(feat.items).not($(target)).each( function(){
			if( $(this) != $(target) && $(this).is(':visible') ) {
				$(this).animate({'top':'410px', 'opacity':'0'},{queue:false,duration:400});
			}
		})
	}
}
$(document).ready(feat.init);
