$(document).ready(function(){
	
		// Replace HRs with Divs in IE
		// This is necessary becasue IE doesn't let you style the HR element, and we use it extensively on the site.
	  if (jQuery.browser.msie) {
			$("hr").each(function() {
				var hrClass = $(this).attr("class")
				$(this).wrap("<div class='hr " + hrClass +"'></div>");
			});
		}
		
		//Innerfade effect for the footer facts
		$('.facts').innerfade({
			animationtype: 'fade',
			speed: 750,
			timeout: 7000,
			type: 'random',
			containerheight: '40px'
		}); 
		
		// Add utility first/last/alt classes to LIs.
		$("ul li:first-child").addClass("first");
		$("ul li:last-child").addClass("last");
		$("ul li:nth-child(even), table tr:nth-child(even)").addClass("alt");
		
		//Input focus and blur
		$("input[type='text'], textarea").focus(function(){
			$(this).addClass("focus")
		});
		$("input[type='text'], textarea").blur(function(){
			$(this).removeClass("focus");
		});
		
		$("div.home-overview div.section:last-child").css( { "paddingRight" : "0" } );
		
		// displays a random header background image
		var arrHeaderBGImg = Array("sub.jpg", "sub2.jpg", "sub3.jpg", "sub4.jpg", "sub5.jpg");
		var intRandomIndex = Math.floor(Math.random() * arrHeaderBGImg.length);
		$("div.sub-header").css( { "backgroundImage" : "url(images/struct/" + arrHeaderBGImg[intRandomIndex] + ")" } );
		
		// Add the "on" class to the first (default) link.
		$("#tabs li:first-child a").addClass("on");
		
		// Issue & Policy: pulls content through an AJAX server request
		$("#tabs li a").click(
			function(event)
			{
				// Prevent jump links from "jumping" to the top of the page.
				event.preventDefault();
				
				// Remove the "on" class from any link that has it.
				$("a.on").removeClass("on");
				// Add the "on" class to the selected link.
				$(this).addClass("on");
				
				// Grab the value from the selected link's HREF attribute (without the #).
				var strIssue = $(this).attr("href").substr(1);
				
				// 1. Clear the content area.
				// 2. Populate the content area with an animated graphic of a loading bar.
				// 3. Pull the content dynamically based on the value in the query string.
				$("#issues-content").empty().append("<div id=\"LoadingBar\"></div>").load("issue_policy_content.aspx?issue=" + strIssue);
			}
		);
		
		// Energy Update: pulls content through an AJAX server request
		$("#EnergyUpdateTabs li a").click(
			function(event)
			{
				// Prevent jump links from "jumping" to the top of the page.
				event.preventDefault();
				
				// Remove the "on" class from any link that has it.
				$("a.on").removeClass("on");
				// Add the "on" class to the selected link.
				$(this).addClass("on");
				
				// Grab the value from the selected link's HREF attribute (without the #).
				var strYear = $(this).attr("href").substr(1);
				
				// 1. Clear the content area.
				// 2. Populate the content area with an animated graphic of a loading bar.
				// 3. Pull the content dynamically based on the value in the query string.
				$("#EnergyUpdateList").empty().append("<div id=\"LoadingBar\"></div>").load("archived_updates_content.aspx?year=" + strYear);
			}
		);
});