
var to;
var $shutDown = null;
(function($) {

	$.fn.dynamItDrop = function() {

		return this.each(function() {

			$(this).children('li').children('ul').addClass('opened');

			$(this).children('li').children('a').click(function() {

				clearTimeout(to);
				$('ul.opened').hide().siblings('a').removeClass('over');


				$shutDown = $(this).siblings('ul').show();
				if($shutDown.length) {
					$(this).addClass('over');
					coverUp();
					return false;
				}

			}).mouseout(function() {
				$shutDown = $(this).siblings('ul');
				to = setTimeout(function() {
					closeme($shutDown);
				}, 2000);
			});

			$('ul.opened').mouseover(function() {
				clearTimeout(to);
			}).mouseout(function() {
				$shutDown = $(this);
				to = setTimeout(function() {
					closeme($shutDown);
				}, 2000);
			});

		});

	};

})(jQuery);

function coverUp() {
	$("#dynamItCoverAll").width("100%").height("100%");
	$("#dynamItCoverAll").fadeIn('slow');
}

function closeme(o) {
	o.hide();
	o.siblings('a').removeClass('over');

	// modified
	$("#dynamItCoverAll").fadeOut('slow');
}


$(document).ready( function() {

	$("#dynamItCoverAll").click(function() {
		closeme($shutDown);
	});

});
