$(document).ready(function(){

	//Grab the original BG color of the link
	var originalBG = $(".animate").css("background-color");
	//The color you want to fade too
	var fadeColor = "#e5e5e5"; 

    $("#timelines td").hover(
      function () {
		$(this).animate({ backgroundColor: "offwhite" }, 100);
		$(this).addClass("activeTR");

		if ($(this).find("h5 a").attr("href").search("world-regions") != -1) {
			$(this).find("h5 a").append(" <span class=\"viewMap\">(view&nbsp;map)</span>");
		}
      }, 
      function () {
		$(this).animate({ backgroundColor: "gray" }, 100);
		$(this).removeClass("activeTR");
		$(".viewMap").remove();
      }
    );
	
	$(".timebar"+timePeriodCurrent).addClass("activeTime");
	$(".timeList"+timePeriodCurrent).addClass("activeTime");
	$(".timemap"+timePeriodCurrent).addClass("activeTime");
	$(".regionGroup"+timePeriodCurrent).addClass("activeRegion");
	
	
	$(".regionList li").hover(
		function() {
			if ($(this).hasClass("activeRegion")) { } else {
				$(this).addClass("hoverRegion");
				var theClass = this.className.replace(/regionGroup/gi,'');
				theClass = theClass.replace(" hoverRegion","");
				theClass = theClass.replace("first ","");
				theClass = theClass.replace("last ","");
				$(".timebar" + theClass).addClass("hoverTime");
			}
		}, function() {
			$(this).removeClass("hoverRegion");
				var theClass = this.className.replace(/regionGroup/gi,'');
				theClass = theClass.replace(" hoverRegion","");
				theClass = theClass.replace("first ","");
				theClass = theClass.replace("last ","");
				$(".timebar" + theClass).removeClass("hoverTime");
		}
	);
	
	$(".regionList li").click(function(){
		var newURL = $(this).attr("rel");
		if (newURL != "" && newURL != null) {
			window.location = newURL;
		}
	})

	$(".maplist li").hover(
		function() {
			if ($(this).hasClass("activeTime")) { } else {
				$(this).addClass("hoverRegion");
				var theClass = this.className.replace(/timemap/gi,'');
				theClass = theClass.replace(" hoverRegion","");
				theClass = theClass.replace("first ","");
				theClass = theClass.replace("last ","");
				$(".timebar" + theClass).addClass("hoverTime");
			}
		}, function() {
			$(this).removeClass("hoverRegion");
				var theClass = this.className.replace(/timemap/gi,'');
				theClass = theClass.replace(" hoverRegion","");
				theClass = theClass.replace("first ","");
				theClass = theClass.replace("last ","");
				$(".timebar" + theClass).removeClass("hoverTime");
		}
	);
	$(".boxList li").hover(
		function() {
			if ($(this).hasClass("activeTime")) { } else {
				$(this).addClass("hoverTime");
				var theClass = this.className.replace(/timebar/gi,'');
				theClass = theClass.replace(" hoverTime","");
				theClass = theClass.replace("first ","");
				theClass = theClass.replace("last ","");
				theClass = theClass.replace(" Item","");
				$(".regionGroup" + theClass).addClass("hoverRegion");
				$(".timemap" + theClass).addClass("hoverRegion");
			}
		}, function() {
			$(this).removeClass("hoverTime");
				var theClass = this.className.replace(/timebar/gi,'');
				theClass = theClass.replace(" hoverTime","");
				theClass = theClass.replace("first ","");
				theClass = theClass.replace("last ","");
				theClass = theClass.replace(" Item","");
				$(".regionGroup" + theClass).removeClass("hoverRegion");
				$(".timemap" + theClass).removeClass("hoverRegion");
		}
	);
	





})
