(function($){
	var initLayout = function() {
		var hash = window.location.hash.replace('#', '');
		var currentTab = $('ul.navigationTabs a')
							.bind('click', showTab)
							.filter('a[rel=' + hash + ']');
		if (currentTab.size() == 0) {
			currentTab = $('ul.navigationTabs a:first');
		}
		showTab.apply(currentTab.get(0));
		$('#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();
		
		// Buscamos el nombre del archivo y el div para cargar las nuevas imagenes con ajax
		archivo = $(".active").attr("title");
		nombre_div = $(".active").attr("rel");
		
		// Cargamos las nuevas imagenes con ajax
		$.post( archivo, function(data){
			$('#' + nombre_div).html(data);
		});
		

	};
	
	EYE.register(initLayout, 'init');
})(jQuery)