$(document).ready(function() {
	
	$("#timeline a").attr("id",function() { return 'link'+this.hash.substr(2); } );	
	$("#timeline a#link2008").addClass("selected");
	window.actItem = '2008';
	//$("#tooltip").hide();
	
	$("#timeline a").each( function() {
		$(this).append("<span>&nbsp;</span>");
		var t = $(this).text();
		var y = $(this).attr("id");
		y = y.substring(4);
		$(this).parent().append("<p class=\"tooltip\" id=\"ttip"+y+"\">"+t+"</p>");
		var l = $(this).css("left");
		l = l.substring(0,l.length-2)-0;
		$("#ttip"+y).css("left",l+7);	
		if (y!=window.actItem) $("#ttip"+y).hide();
									
	});
	
	$("#timeline a").click( function() { 
		$("#y"+window.actItem).addClass("hidden");
		$("#link"+window.actItem).removeClass("selected");
		window.actItem = this.id.substring(4);
		$("#y"+window.actItem).removeClass("hidden");
		$("#link"+window.actItem).addClass("selected");
		return false;
	} );
	
	$("#timeline a").hover(function(){
		window.hovered = true;
		clearTimeout(window.hoverTimer);
		var a = window.actItem;
		$("#link"+a).removeClass("selected"); 
		$("#ttip"+a).hide();
		var y = $(this).attr("id");
		y = y.substring(4);
		$("#ttip"+y).show();
		if ($(this).attr("id")!="link"+window.actItem) { 
		//			
		}
	},function(){
		window.hovered = false;
		if ($(this).attr("id")!="link"+window.actItem) {
			var y = $(this).attr("id");
			y = y.substring(4);
  			$("#ttip"+y).hide();
			clearTimeout(window.hoverTimer);
			window.hoverTimer = setTimeout(function() {
				if (window.hovered===false&&window.fadeTriggered!=true) {
					var a = window.actItem;
					$("#link"+a).addClass("selected");
					$("#ttip"+a).fadeIn("slow");
				}
			},1000);									   							   
		} else {
			var a = window.actItem;
			$("#link"+a).addClass("selected");
		}
	});
	
	
	//$('#timeline a').mouseover(function() { alert(this.id); } );	
						   
						   
});