$(function(){


//GLOBAL
//------------------------------------------------------
	
	//Tab box
	$('.tab-box .tab-content').hide();
	$('.tab-box .tab-content:first').show();
	$('.tab-box .tabs ul li:first').addClass('active');
	
	$('.tab-box .tabs ul li a').click(function(){
		$('.tab-box .tabs ul li').removeClass('active');
		$(this).parent().addClass('active');
		
		var currentTab = $(this).attr('href');
		$('.tab-box .tab-content').hide();
		$(currentTab).show();
		return false;
	});
	
	

//HOME
//------------------------------------------------------
	
	//Home news slider
	$('.news-slider').cycle({
		fx:		'scrollHorz',
		timeout: 0,
		speed:	 500,
		prev:	'.news-item-prev',
		next:	'.news-item-next',
		onPrevNextEvent: function(isNext, zeroBasedSlideIndex, slideElement){
			if (zeroBasedSlideIndex == 0){ $('.news-item-prev').hide(); }
			else { $('.news-item-prev').show(); }
			
			if (zeroBasedSlideIndex == 2){ $('.news-item-next').hide(); }
			else { $('.news-item-next').show(); }
		}
	});

	$('#news-more-btn').click(function(){
		$(this).attr('href', $('.news-item:visible').attr('rel'));
		return;
	});
	
	
	
//ABOUT
//------------------------------------------------------	
	
	//About team member rotator
	$('.team-rotator').cycle({
		fx:		'fade',
		timeout: 3000,
		speed:	 500
	});
	
	
//TEAM
//------------------------------------------------------	
	
	//Team member thumb rotator
	$('.member-photo').cycle({                            
		fx:		 'fade',
		timeout: 1100,
		delay:	 -1100,
		speed:	 700,
		sync:    1
	}).cycle("pause").hover(function() {
		$(this).cycle('resume');
	}, function(){
		$(this).cycle('pause');
	});
	


	//Team detail speech bubble
	$('.team-member-picture .plus').hover(function(){
		$('.team-member-picture figcaption').show();
	}, function(){
		$('.team-member-picture figcaption').hide();	
	});
	
	
	//Team thumb scroller
	if ($('#team-scroller').length !== 0) {
		$('#team-scroller').rowscroller({
			navUp:				'#scroller-up',
			navDown:			'#scroller-down'
		});
	}
		

//CLIENTS
//------------------------------------------------------

	//Client thumb scroller
	if ($('#client-scroller').length !== 0) {
		$('#client-scroller').rowscroller({
			navUp:				'#scroller-up',
			navDown:			'#scroller-down',
			visibleRows:		4
		});
	}


//NEWS BLOG
//------------------------------------------------------	
	
	//Sidebar toggles
	$('ul.toggle .parent > a').click(function(e){
		$(this).parent().toggleClass('expanded');
		$(this).next('ul').slideToggle();
		e.preventDefault();
	});

	
});
