﻿var __images = new Array();var __curr = 0;var __newItems = new Array();var __currNewsItem = 0;
function __showNext(){$(__images[__curr]).fadeOut("slow");__curr++;if (__curr >= __images.length){__curr = 0;}$(__images[__curr]).fadeIn("slow");setTimeout("__showNext()", 5000);}function __showNextNews(){$(__newItems[__currNewsItem]).fadeOut("slow");__currNewsItem++;if (__currNewsItem >= __newItems.length){__currNewsItem = 0;}$(__newItems[__currNewsItem]).fadeIn("slow");setTimeout("__showNextNews()", 8000);}
$(document).ready(
	function()
	{
		// Home Page Image Rotation Setup
		$("div#body div#images img").each(function(){__images.push($(this));});
		$("div#body div#images img:first").css("display", "block");
		if (__images.length > 1){setTimeout("__showNext()", 5000);}

		// Navigation Highlighting
		$("#nav a").each(function(){var location = window.location.href;location = location.substring(location.lastIndexOf('/'));if ($(this).attr('href') == location){$(this).addClass("selected");}else{$(this).removeClass("selected");}});
		
		// Searchbar Functionality
		$("#searchterms").keyup(function(event){if (event.keyCode == 13){window.location.href = "/search/?q=" + $("#searchterms").attr("value");}}).focus(function(){$(this).attr("value", "");});
		$("#go-search").click(function(){window.location.href = "/search/?q=" + $("#searchterms").attr("value");});
		
		// News Ticker Functionality
		$("div.headline:first").css("display", "block");
		var __headlineHeight = 0;
		$("div.headline").each(function(){if ($(this).height() > __headlineHeight){__headlineHeight = $(this).height();}__newItems.push($(this));});
		__headlineHeight += 150;
		$("#headlines").height(__headlineHeight);
		if (__newItems.length > 1){setTimeout("__showNextNews()", 8000);}
		
	}
);