$(document).ready(function() {

	// For each link containing -off, set up a -on hover
	$("img[src*='-off']").each(function() {
	
		// Preload on state
		var img = new Image();
		img.src = $(this).attr("src").replace(/-off/,"-on");
		
		// Set up the hover switcher
		$(this).hover(function() {
			$(this).attr("src",$(this).attr("src").replace(/-off/,"-on"));
		}, function() {
			$(this).attr("src",$(this).attr("src").replace(/-on/,"-off"));
		});
	
	});
	
	
	$("#nav li ul").each(function() {
		$(this).css("display","block");
		$(this).css({ 
			"left" : $(this).parent().position().left + $(this).parent().width() / 2,
			"margin-left" : $(this).width() / 2 * -1
		});
		//if (!$(this).parent().hasClass("active"))
			$(this).css("display","none");
	});
	
	$("#nav li").hover(function() {
		$(this).find("ul").show();
	}, function() {
		$(this).find("ul").hide();
	});
	
	if ($(".match-heights").length)
		$(".match-heights div[id!='']").equalizeCols();
		
	$(".tooltip").tooltip({ 
		track: true, 
		delay: 0, 
		showURL: false, 
		showBody: " - ", 
		fade: 250 
	});
	
	// Homepage functionality
	if ($("#home").length)
	{
		$("#accordion1").hrzAccordion({
			eventTrigger: "mouseover",
			openOnLoad: 1,
			fixedWidth: 605,
			handlePosition: "left"
		});
		
		$("#slider").cycle({
			next: '#next',
			prev: '#prev',
			timeout: 9999
		});
	}
	
});