
var slide_id = 0;
var speed = 'normal';

function slide(clicked)
{
	if (slide_id != clicked)
	{
		if (clicked == $('#home-ref .list li').size()) slide_id = 0;
		else slide_id = clicked;
		
		clearTimeout(slide_show);
		
		$('#home-ref .detail .img').fadeOut(speed, function() {
			$('#home-ref .list li.active').removeClass('active');
			$('#home-ref .detail .img').html(refs[slide_id]['img']);
			$('#home-ref .detail .title').html(refs[slide_id]['name']);
			$('#home-ref .detail .link a').attr('href', refs[slide_id]['link']);
			$('#home-ref .detail .status span').html(refs[slide_id]['title']);
			$('#home-ref .list li:nth(' + slide_id + ')').addClass('active');
			$(this).fadeIn(2000, function(){
				slide_show = setTimeout("slideShow()", 5000);
			});
		});	
	}
}

function slideShow()
{
	slide(slide_id + 1);
}

var slide_show = setTimeout("slideShow()", 5000);

$(document).ready(function(){
   	var tabContainers = $('.tab-fragment');    
    var tabStatus = 0;
   	
    $('.tab-list a').click(function () {
    	var e = this;
		if (tabStatus == 0)
		{
			tabStatus = 1;
	        tabContainers.filter(':not(:hidden)').hide('slide', {direction: 'left'}, function(){
	        	tabContainers.filter(e.hash).show('slide', {direction: 'right'});
	        	tabStatus = 0;
	        });
	        //tabContainers.filter(this.hash).show('slide', {direction: 'right'});
	        $('.tab-list > li').removeClass('active');
	        $(this).parent().addClass('active');  
		}      
        return false;
    });
	
    $('#home-ref .list a').each(function(index) {
		$(this).click(function(){
			slide(index);
			return false;
		});		
	});
	
	adjustHeights();
	
});
