// JavaScript functions using jQuery to animate the main menu
// written 2009.03.16 by Dan Klassen
// Copyright 2009, Church of the Saviour
//
$(document).ready(function() {
					  
// Pre-load Images from CSS (requires preload-images.js plugin)
	$.preloadCssImages({statusTextEl: '#textStatus', statusBarEl: '#status'});
	
// Show or Hide Submenus
	$("#mainmenu > li > ul").hide(); // hide second level main meny links on document ready.
	$("#subnav ul li:has(.current)").addClass("current"); // Show 'active' menu items in subnav

// Main Menu slide effects

	$("#mainmenu > li").click(
		function () { 
			$(this).children("ul").show("slow") ; // fade in the submenu
			$(this).parent().children(".clicked").children("ul").hide("slow"); // fade out previously opened submenu
			$(this).parent().children(".clicked").removeClass("clicked"); // removed clicked class from opened menu
			$(this).addClass("clicked"); // change menuitem class to 'clicked' 
		} 
	);
	$("#mainmenu").hover(
		function () { },// on hover in, do nothing
		function () { 
			$("#mainmenu > li > ul").hide("normal"); // fade out all drop-downs
			$("#mainmenu > li").removeClass("clicked"); // clear clicked class from any drop-downs
		} 
	);
	
// Homepage Image Cycler
	$("#featureimage").cycle({
		timeout:       8000,  // milliseconds between slide transitions (0 to disable auto advance) 
		speed:         1000,  // speed of the transition (any valid fx speed value) 
		pause:         1     // true to enable pause on hover 						
	});
	
});
