jQuery(document).ready(function($) {
	var config = {    
		sensitivity: 3,  
		interval: 100,
		over: showMenu,
		timeout: 500,
		out: hideMenu
	};
	var right = 1;

	$('#top-navigation ul.horizontal > li').hoverIntent(config);
	
	// callback for hoverintent
	function showMenu() {
		if ($(this).children('ul').size()) {
			if ($(this).children('ul').is(':visible')) {
				return;
			}
		
			$('#top-navigation ul ul').fadeOut('fast');
			$(this).children('ul').fadeIn('fast');
		}
	}
	
	// callback for hoverintent
	function hideMenu() {
		return;
	}
	
	// show submenu on current page
	$('#top-navigation ul.horizontal li.current_page_item ul').show();
	$('#top-navigation ul.horizontal li.current_page_ancestor ul').show();
	
	// if there are events to scroll, set them up
	if ($('#events').children().size() > 1) {
		$('#events').cycle({
			next: '#more-less',
			prev: '#more-less',
			speed: 500,
			timeout: 0
		});
		
		$('#more-less').click(function() {
			if (right) {
				$(this).html('&lsaquo;');
				right = 0;
			}
			else {
				$(this).html('&rsaquo;');
				right = 1;
			}
			
			return false;
		});
	} else {
		$('#more-less').css('display', 'none');
	}
	
	$('.cycle-me').cycle({
		pause: 1,
		speed: 500,
		timeout: 4000
	});
});

$(document).bind("ready", function() {
	$('.map').slideUp();
	$('button').click(function(){
		$('.map').toggle("slow");
	});
});
