(function($){
	var initLayout = function() {
		var hash = window.location.hash.replace('#', '');
		var currentTab = $('ul.tabby a')
							.bind('click', showTab)
							.filter('a[rel=' + hash + ']');

		showTab.apply(currentTab.get(0));
		$('a.imagefollow').trgallery({
			centered: true,
			hideSource: false
			});

		$('a.customGal').trgallery({

			opacity: 1,
			beforeZoomIn: function(boxID) {
				$('#' + boxID)
					.find('img')
					.css('opacity', 0)
					.animate(
						{'opacity':1},
						{ duration: 500, queue: false }
					);
			},
			beforeZoomOut: function(boxID) {
				$('#' + boxID)
					.find('img')
					.css('opacity', 1)
					.animate(
						{'opacity':0},
						{ duration: 500, queue: false }
					);
			}
		});
	};
	
	var showTab = function(e) {
		var tabIndex = $('ul.tabby a')
							.removeClass('active')
							.index(this);
		$(this)
			.addClass('active')
			.blur();
		$('div.zooimage').trgalleryClear();
		$('div.tab')
			.hide()
				.eq(tabIndex)
				.show();
	};
	
	EYE.register(initLayout, 'init');
})(jQuery)