/*global EYE, jQuery, $, $$ */
(function($) {
	var initLayout = function() {
		var hash = window.location.hash.replace('#', '');
		var currentTab = $('ul.navigationTabs a')
							.bind('click')
							.filter('a[rel=' + hash + ']');
		if (currentTab.size() === 0) {
			currentTab = $('ul.navigationTabs a:first');
		}
		showTab.apply(currentTab.get());
		$('#myGallery').spacegallery({loadingClass: 'loading'});
	};
	
	var showTab = function(e) {
		var tabIndex = $('ul.navigationTabs a')
							.removeClass('active')
							.index(this);
		$(this)
			.addClass('active')
			.blur();
		$('div.tab')
			.hide()
				.eq(tabIndex)
				.show();
	};
	
	EYE.register(initLayout, 'init');
})(jQuery);