$(document).ready(function(){
	jQuery.fn.extend({
		TopMenu : function(options){
			var This = $(this);
			var div = This.next('div');
			var exT = options.extraTop || 0;
			var exL = options.extraLeft || 0;
			var speed = options.speed || 0;
			var STimer;
			var Timer;
			var ThisW = This.outerWidth();
			var ThisH = This.outerHeight();
			var DivW = $(div).outerWidth();
			var DivH = $(div).outerHeight();
			var ThisOff = This.offset();
			var ThisL = ThisOff.left + exL;
			var ThisT = ThisOff.top;
			var ThisB = (ThisT + ThisH) + exT;
			div.css({'position': 'absolute', 'left': ThisL+'px', 'top': ThisB+'px', 'z-index': 5000, 'overflow': 'hidden', 'display': 'none'});
			This.hover(function(){
				clearTimeout(Timer);
				STimer = setTimeout(function(){
					div.slideDown(speed);
				}, 200);
			}, function(){
				clearTimeout(STimer);
				Timer = setTimeout(function(){
					div.slideUp(speed);
				}, 300);
			});
			div.hover(function(){
				clearTimeout(Timer);
				div.slideDown(speed);
			}, function(){
				Timer = setTimeout(function(){
					div.slideUp(speed);
				}, 200);
			});
			
		}
	});
	$('.MainMenu').find('a').each(function(){
		var Tlink = $(this);
		if (Tlink.next('div').length > 0){
			Tlink.TopMenu({extraTop:0, extraLeft: 0, speed: 'fast'});
		}
	});
});
