// JavaScript Document
var clearQueue = true;
var gotoEnd= false;



				
				

jQuery(function() {
				$("div.year:not(.always-active) .tl-box").fadeTo('fast', 0.7);
				$(document).everyTime(1500, function() {
 						 $('#year2010 .tl-box').animate({ borderTopColor: "#ffdd00", borderRightColor: "#ffdd00", borderBottomColor: "#ffdd00", borderLeftColor: "#ffdd00" }, 1000);
						 $(document).everyTime(1010, function() { 
						 
						 $('#year2010').addClass("active-trail");              
						 $('#year2010 .tl-box').removeAttr("style");
						 $('#year2010 .tl-box').removeAttr("style");
						 


							

						 
						  }, 1);

				}, 1);
				
				
				
				 hover_bind ();
			$(".tl-header a.previous-slide").click(function() {
					
				

				
				 slide("down");
				
				 get_index = $('.tl-header a').index(this);
				 get_index_next = get_index - 1;
				 
				 active_year_id = $(".slide:eq("+get_index_next+") .year:last").attr('id');
				 $("#"+active_year_id).addClass("active-trail");
				 	$("div.active-trail .tl-box").fadeTo('fast', 1, function() {
      					// Animation complete.
   				 });
				 $("#timeline-content ."+active_year_id).addClass("active-copy");	
				 
				 fade(".tl-header a.previous-slide:eq("+get_index+")", ".tl-header a.previous-slide:eq("+get_index_next+")");
				 fade(".tl-footer a.next-slide:eq("+get_index+")", ".tl-footer a.next-slide:eq("+get_index_next+")");
				
  				 hover_bind ();				
			});
				
			$(".tl-footer a.next-slide").click(function() {
					
				  
				  
				   slide("up");
				  
				  
				  get_index = $('.tl-footer a').index(this);
				  get_index_next = get_index + 1;
				  
				  active_year_id = $(".slide:eq("+get_index_next+") .year:eq(0)").attr('id');
				  $("#"+active_year_id).addClass("active-trail");
				  	$("div.active-trail .tl-box").fadeTo('fast', 1, function() {
      					// Animation complete.
   				 });
				  $("#timeline-content ."+active_year_id).addClass("active-copy");
				  
				  fade(".tl-footer a.next-slide:eq("+get_index+")", ".tl-footer a.next-slide:eq("+get_index_next+")");
				  fade(".tl-header a.previous-slide:eq("+get_index+")", ".tl-header a.previous-slide:eq("+get_index_next+")");
				  hover_bind ();
				 	
  									
			});
			
			$(".slide .year .tl-box").click(function() {
				
				
				$("div.year").removeClass("active-trail");
				

				active_year = $(this).parents( "div.year" );
				active_year_id = active_year.attr('id');	
			
				
				
				active_year.addClass("active-trail");
				$("div.active-trail .tl-box").fadeTo('fast', 1, function() {
      					// Animation complete.
   				 });
				$("div.year:not(.active-trail)  .tl-box").fadeTo('fast', 0.7, function() {
      					// Animation complete.
   				 });

				
				$("#timeline-content .tl-copy").removeClass('active-copy');
				$("#timeline-content ."+active_year_id).addClass("active-copy");
				
				hover_bind ();
				
			});
			
		
			

	});

var hoverFunc = function() {
						
						$(this).children(".tl-box").stop(clearQueue , gotoEnd);
						$(this).children(".tl-box").fadeTo('normal', 1, function() {
						
							// Animation complete.
					 });
				};
				
				var unhoverFunc = function(){
					$(this).children(".tl-box").stop(clearQueue , gotoEnd);
					$(this).children(".tl-box").fadeTo('normal', 0.7, function() {
							// Animation complete.
					 });
	  
				};
				
function hover_bind () {
		
				
				
		
				$("div.year").unbind('mouseenter', hoverFunc);
				
				$("div.slide:not(.t1-slide) div.year:not(.active-trail)").bind('mouseenter', hoverFunc);
				
				$("div.year").unbind('mouseleave', unhoverFunc);
				
				$("div.slide:not(.t1-slide) div.year:not(.active-trail)").bind('mouseleave', unhoverFunc);	
	}
		
	
	function slide($direction) {
		$	('#year2010 .tl-box').removeAttr("style");
			$("div.year").removeClass("active-trail");
			$("#timeline-content .tl-copy").removeClass('active-copy'); 
			
			if($direction == "up") {
				
					move = '-=531';
					
			} else {
				
					move = '+=531';
		    }
		
					
		    $('.slide').animate({
						  
					top: move

			}, 1000, function() {
				   
				   // Animation complete.
			
			});		
  									
	}
	
	function fade($out, $in) {
			$($out).fadeOut("fast", function() {
				
				$($in).fadeIn("fast");

			});		
  									
	}
	
	
