//útiles de menú
$(document).ready(function () { 
	try { 
		$("#nav").superfish(); 
	} catch(ex) { }
});


//Slider de historia
function initHistoria() {
	var container = $('#wrapper-slider-crono');
	var container_width = container.width();
	var pages = $('#cronologia-lista-numeros a'); 
	var n_pages = pages.length;
	var current_page = -1;
	
	var page_width = 957;
	var crono_padding = 10;
	var crono_select_factor = 91;
	
	function setPage(page) {
		page = page*1;
		if (page<0 || page>n_pages-1 || current_page == page) return false;
		$('#crono-select').animate({'left': (crono_select_factor*page+crono_padding)+'px'}, 'fast');
		$('#slider-crono').animate({'left': (-1*page_width*page)+'px'}, 'fast');
		
		current_page = page;
	}
	
	$('#cronologia-lista-numeros li').hover(function() {
		$(this).addClass('crono-hover');
	}, function() {
		$(this).removeClass('crono-hover');
	}).click(function() {
        setPage(this.getAttribute('rel'));
		return false;
	});
	
	container.find('a.crono-prev').click(function() {
		if (current_page>0) setPage(current_page-1);
	});
	container.find('a.crono-next').click(function() {
		if (current_page<n_pages-1) setPage(current_page+1);
	});
	setPage(0);
}
