/*
Credits: 	Inspiration/Code borrowed from Dave Lindquist (http://www.gazingus.org)
		Menu hide functionality was aided by some code I found on http://www.jessett.com/
		Based on the work of sam AT hampton-smith.com

*/


var currentMenu = 0;
var mytimer = 0;

function startTime() {
	mytimer = window.setTimeout(closeMenu, 500);
}

function closeMenu() {
    if (mytimer) {
		clearInterval(mytimer);
		mytimer = null;
		timerOn = false;
    }
	if(currentMenu) {
		currentMenu.css('visibility', 'hidden');
	}
}

function openMenu() {
	var sub = $(this).find('.sub');
	closeMenu();
	if(sub.length>0) {
		currentMenu = $(sub[0]);
		currentMenu.css('visibility', 'visible');
	}
}

$(document).ready(
	function() {
		var li = $('#topMenu > li');
		li.mouseenter( openMenu );
		li.mouseleave( startTime );

		$('#sitemap').click(
			function() {
				$('#showMap').slideToggle('slow');
				return false;
			}
		);
	}
)

