// Requires the jQuery library in common_js/jquery.js

var current_submenu = false;

jQuery(function() {
	// Wait until images load
	window.onload = function() {
		setTimeout(function() {
			var content_height = $('#main-area').height();
			var leftnav_height = $('#left-navigation').height();

			if (content_height > leftnav_height) {
				var padding_size = (content_height - leftnav_height) + (document.all ? 20 : 0);
				$('#left-navigation-spacer').height(padding_size);
			}

			$('#background-hider').width($('#footer').width() + 8);
		}, 5);
	}

	setTimeout(function() {
		$('.navigation-menu > li').mouseover(function(evt) {
			if (current_submenu) {
				current_submenu.stop().hide();
			}

			var instance = this;

			var pos = $(instance).position();
			var height = $(instance).height();

			var item = $(instance).find('.sub-navigation-menu');
			if (item) {
				item.css('top', pos.top + height - 5);
				item.css('left', pos.left);
				//item.css('display', 'block');
				item.stop().show();

				if (document.all) {
					item.css('left', pos.left - 50);
				}

			}

			current_submenu = $(item);

			return true;
		});

	    $('.navigation-menu > li').mouseout(function(evt) {
		$(this).find('.sub-navigation-menu').stop().hide();
	    });

	}, 5);
});
