var mouse_currently_over = '';

$(document).ready(function() {

	$(".navigation li").click(
		function() {

			if ($(this).attr("class").indexOf("subnav-li-")==-1) { // if not a subnav li
			
				mouse_currently_over = $(this).attr("id");

				doNavigation(mouse_currently_over);

			}
			
		}
	);	
	
	$(".navigation li").hover(
		function() {

			if ($(this).attr("class").indexOf("subnav-li-")==-1) { // if not a subnav li
			
				mouse_currently_over = $(this).attr("id");

				setTimeout("doNavigation('"+mouse_currently_over+"')", 600);

			}
			
		},
		function() {
			mouse_currently_over = '';
		}
	);

	
});

function doNavigation(toShow) {

	if (mouse_currently_over==toShow) {

		$("[id^='div-subnavigation-']").each(function() {
			var this_id = $(this).attr("id");
			this_id = this_id.replace("div-subnavigation-", "");
			var to_show_id = toShow.replace("nav-li-", "");
			if (this_id!=to_show_id) {
				$(this).slideUp(200);
			}
			
		});
			
		var this_id = toShow;
		this_id = this_id.replace("nav-li-", "");
		$("#div-subnavigation-"+this_id).slideDown(200);

	}
	
}
