$(function() {

	$(".characters li .handle_bg").fadeIn(800);

	$(".characters li").each(function() {
		
		$(this).find(".thumbs").each(function() {
			$(this).find("a").lightBox({fixedNavigation:true});
		});


		$(this).click(function() {
							   
			if ($(this).parent().find("li.active").length == 0)
			{
				$(this).parent().find("li .handle_bg").animate({ opacity: 0 }, { queue: true });
			}
				
			if ($(this).hasClass("active"))
			{
				
				// Return to initial view if closing this tab
				$(this).removeClass("active");
				$(this).parent().find("li[class], li .handle, li .handle_bg").animate({ width: "101px" });
				$(this).parent().find(".handle_bg, .handle").animate({ opacity: 1 }, { queue: false });
				$(this).parent().find(".handle_bg_small").hide();
				
			}
			else
			{
				
				// Reset inactive tabs
				$(this).parent().find("li.active").removeClass("active");
				$(this).parent().find("li[class]:not(.active), li:not(.active) .handle, li:not(.active) .handle_bg, li:not(.active) .handle_bg_small").animate({ width: "39px" });
				$(this).parent().find("li:not(.active) .content").animate({ opacity: 0 }, { queue: false });
				$(this).parent().find("li:not(.active) .handle, li:not(.active) .handle_bg_small").animate({ opacity: 1 }, { queue: false });
				
				// Open up this tab
				$(this).addClass("active")
				$(this).animate({ width: "597px" }, { queue: false });
				$(this).find(".handle").animate({ opacity: 0 }, { queue: false });
				$(this).find(".handle_bg_small").animate({ opacity: 0 }, { queue: false });
				$(this).find(".content").animate({ opacity: 1 }, { queue: false });
				
			}
							   
		});
										
	});
	
});

