var currentLI = null;
var currentIndex = null;

$(function(){
	//Blinking Fields
    
    $('.top-bar li:last, .nav li:last, .column-left ul:last, div#popular li:last,  div#recent li:last').addClass('last');
    $('ul.sf-menu').superfish();
    $('.nav li:first').addClass('active');
    $('.comment:last').addClass('last-comment');
    
    
    $('.column-right .social a:eq(4)').addClass('last');
    $('.column-right .social a:eq(9)').addClass('last');
    $('.column-right .social a:eq(14)').addClass('last');
    $('.column-right .social a:eq(23)').addClass('last');
    $(".tooltip").easyTooltip({
        xOffset: -40,
        yOffset: 30
        
    });
    
    $('.blink').
        focus(function() {
            if(this.title==this.value) {
                this.value = '';
            }
        }).
        blur(function(){
            if(this.value=='') {
                this.value = this.title;
            }
        });
    
        
    $('.nav ul li').hover(function () {
    	$(this).css({'cursor' : 'pointer' });
    });    
        
    //Featured Content Navigation Active State
    $('.nav ul li').click(function() {
        
    	var index = $('.nav ul li').index($(this));
    	
    	next(index);
        
    	return false;
    });
    
    //Featured Content Navigation Hover State
    $('.nav li').hover(
    	function(){ $(this).addClass('hover');
		},
		function(){ $(this).removeClass('hover'); 	
	});
});


function next(index){
    
    var nav = $('.nav ul li');
    
    if (index == undefined){
        index = currentIndex + 1;
        
        if (index >= nav.length){
            index = 0;
        }
    }
    
    currentIndex = index;
    
    var li = nav[index];

    $('.nav li').removeClass('active');
    $(li).addClass('active');
    
    var img_width = 635;
    var l = -1 * img_width * index;
    
    
    $('#featured-content .image .images-container').animate({
        left: l + 'px'
    });
}
    
$(document).ready(function(){
    setInterval('next()',5000);
});
