$(document).ready(function() {
	
	$('.tabs a').click(function() {
		if ($('.tabs').hasClass('active')) {
			return false;
		}
		
		$('.tabs li.selected').removeClass('selected');
		$(this).parent().addClass('selected');
		var id = $(this).attr('href');
		
		$('.tabs').addClass('active');
		$('.tab-content div:visible').fadeOut('500');
		setTimeout(function() {
			$(id).fadeIn('500', function() {
				$('.tabs').removeClass('active');
			});
		}, 500);
		
		
		return false;
	});
	
	$('.tabs li:first-child a').trigger('click');

	//$('ul.buzzing li:first-child').addClass('current').show();
	
	//setTimeout('showBuzz()', 5000);
	
	$('#join-the-tree a').hover(function() {
		birds();
	});
	
	$('#birds').click(function() {
		birds();
	});
});

var birds = function() {
	
	var _birds = $('#birds');
	if (!_birds.hasClass('animating')) {
		_birds.addClass('animating');
		_birds.animate({top: parseInt(_birds.css('top')) - 8},100,'swing',function() {
			_birds.animate({top: parseInt(_birds.css('top')) + 8},100,'swing',function() {
				_birds.animate({top: parseInt(_birds.css('top')) - 8},100,'swing',function() {
					_birds.animate({top: parseInt(_birds.css('top')) + 8},100,'swing',function() {
						_birds.removeClass('animating');
					});
				});
			});
		});
	}
};

function showBuzz() {
	$('ul.buzzing .current').fadeOut('slow', function() {
		if($(this).is(':last-child')) {
			$(this).removeClass('current');
			$(this).parent().find('li:first-child').addClass('current');
		} else {
			$(this).removeClass('current').next().addClass('current');
		}
		$('ul.buzzing .current').fadeIn('slow')
	});
	setTimeout('showBuzz()', 5000);
}