$(document).ready(function() {  
	// DROP DOWN NAVIGATION
	// Cache nav  
	var nav = $("#topNav");  
	// Add indicators and hovers to submenu parents  
	nav.find("li").each(function() {  
		if ($(this).find("ul").length > 0) {  
			//show subnav on hover  
			$(this).mouseenter(function() {  
				$(this).find("ul").stop(true, true).slideDown();  
			});  
			//hide submenus on exit  
			$(this).mouseleave(function() {  
				$(this).find("ul").stop(true, true).slideUp();  
			});  
		}  
	});  

	// SLIDESHOW
	$("#slideshow").css("overflow", "hidden");
	// Cycle slideshow images
	$("ul#slides").cycle({
		fx: 'fade',
		pause: 1
	});

	// SIDE ACCORDION NAVIGATION
	initMenus();
});

// Copyright 2008 by Marco van Hylckama Vlieg
function initMenus() {
	$('ul.menu ul').hide();
	$.each($('ul.menu'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});
	$('ul.menu li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}
