var current_tab = '#tab1';

$(document).ready(function() {
	// Tabs functionality
	$('div.tab:gt(0)').hide();
	$('#tabs.tabset li a').click(function(event) {
		event.preventDefault();
		var tab = $(this).attr('href');
		var old = current_tab;
		$(old).fadeOut(10, function() {
			$(tab).fadeIn(10);
			current_tab = tab;
		});
		$(this).parent('li').siblings('li').children('a').removeClass('active');
		$(this).addClass('active');
	});
	
	// Category accordion
	$('ul.categories-list li ul').hide();
	
	$('ul.categories-list li a.toggler').mouseover(function(event) {
		var hot	= this;
		
		$(hot).parent('li').siblings('li').children('ul').slideUp(30, function() {
			$(hot).siblings('ul').slideDown(30);
		});
	});
	
	// .boxScroll scrolling behavior
	$('.boxScroll .leftFloatDiv').each(function() {
		var newHeight = 0;
		var minHeight = 200;
		$(this).children('h2, ul').each(function() {
			newHeight += $(this).outerHeight(true);
			})
		$(this).height((newHeight > minHeight) ? newHeight : minHeight );
		})
		.scrollable({
			items: 'ul',
			size: 4,
			nextPage: '.scroll-right',
			prevPage: '.scroll-left',
			onBeforeSeek: function(i) {
				if (i % 4 != 0) { return false; }
				},
			alert: false
		})
		.find('.scrollLeft, .scrollRight')
			.click(function() {return false;});
});