$(function() {
	// Root Nav active links
  $("#root-nav a").each(function(){
    if (jQuery.url.segment(0) && jQuery.url.segment(0).toLowerCase() == $(this).text().toLowerCase()) {
      $(this).addClass("active");
    }
	});
	// Active links
  $(".sub-nav a").each(function(){
		var query = (jQuery.url.attr("query") == null) ? "" : "?"+jQuery.url.attr("query");
    if ((jQuery.url.attr("path")+query).toLowerCase() == $(this).attr("href").toLowerCase()) {
      $(this).addClass("active").parents(".drop-down").find(".arrow").addClass("active");
    }

    if (jQuery.url.segment(1).toLowerCase() == $(this).text().toLowerCase()) {
      $(this).addClass("active");
    }
		// Database results
    if (jQuery.url.segment(1).toLowerCase() == "results" && $(this).text().toLowerCase() == "databases") {
			$(this).addClass("active");
    }
		// Previews
    if (jQuery.url.segment(1).toLowerCase() == "previews" && $(this).text().toLowerCase() == "previews") {
			$(this).parents(".drop-down").find(".arrow").addClass("active");
    }
		// Recaps
    if (jQuery.url.segment(1).toLowerCase() == "recaps" && $(this).text().toLowerCase() == "recaps") {
			$(this).parents(".drop-down").find(".arrow").addClass("active");
    }
		// Team Reports
    if (jQuery.url.segment(1).toLowerCase() == "team.aspx" && $(this).text().toLowerCase() == "team reports") {
			$(this).addClass("active").parents(".drop-down").find(".arrow").addClass("active");
    }
		// Game Logs
    if (jQuery.url.segment(1).toLowerCase() == "gamelogs" && $(this).text().toLowerCase() == "game logs") {
			$(this).addClass("active").parents(".drop-down").find(".arrow").addClass("active");
    }
		if (jQuery.url.segment(2) != null) {
			// Injuries
			if (jQuery.url.segment(2).toLowerCase() == "injury.aspx" && $(this).text().toLowerCase() == "injuries") {
				$(this).addClass("active");
			}
			// Game Logs
			if (jQuery.url.segment(2).toLowerCase() == "transaction.aspx" && $(this).text().toLowerCase() == "transactions") {
				$(this).addClass("active").parents(".drop-down").find(".arrow").addClass("active");
			}
			// Hot & Not Last 10
			if (jQuery.url.segment(2).toLowerCase() == "hotandnot10.aspx" && $(this).text().toLowerCase() == "hot & not") {
				$(this).addClass("active").parents(".drop-down").find(".arrow").addClass("active");
			}
		}
  });
	
	// Drop Downs - IE6 hover and z-index fix.
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		$(".drop-down").hover(
			function() {
				$(this).addClass("hover");
				var ul = $(this).find("ul");
				var iframe = $('<iframe id="block-frame">')
					.height(ul.height())
					.width(ul.width());
				iframe.prependTo($(this));
			},
			function() {
				$(this).removeClass("hover");
				$("#block-frame").remove();
			}
		);
	}
	
	// Teamlist table spacing.
	$("#body_teamlist_body .Sport_data table").attr("cellspacing", "0");
});