//tab effects

var TabbedContent = {
	init: function() {
        var set = 0;	
		$(".info_thumb").mouseover(function() {
		
			var background = $(this).parent().find(".moving_bg");
			
			$(background).stop().animate({
				left: $(this).position()['left']
			}, {
				duration: 300
			});
            $(".info_thumb").click(function(){
                set = 1;    
            });
			TabbedContent.slideContent($(this),set);
			
		});
	},
	
	slideContent: function(obj,set) {

        var margin = $(obj).parent().parent().find(".slide_content").height();  
		margin = margin * ($(obj).prevAll().size() - 1);
		margin = margin * -1;
        
        // set the current thumb after it is clicked
        $(".info_thumb").click(function(){
            margin_click = margin; 
            set = 1;
        }) ;

        $(obj).parent().parent().find(".tabslider").stop().animate({
            marginTop: margin + "px"
        }, {
            duration: 300
        });
        
        $(".info_thumb").mouseout(function(){
            if(set==0) margin_click = 0;
            margin = margin_click;
            $(obj).parent().parent().find(".tabslider").stop().animate({
                marginTop: margin + "px"
            }, {
                duration: 300
            }); 
        });
        
	}
}

$(document).ready(function() {
	TabbedContent.init();
});
