

	$.fn.DropDown = function(options) {
		var defaults = {
			rollover: false,
			bgcolor: '#000',
			rollovercolor: '#232323',
			fadeSpeed: 50,
			easing: 'swing'
		};
		
		var options = $.extend(defaults, options);
		
		return this.each(function() {
			$(this).find("ul li").each(function() {
				var li = $(this);
				var width = $(this).css('width');
				var height = $(this).css('height');
				var on = false;
				if ( $(this).find('ul').width() && $(this).find('ul').width() < $(this).outerWidth(true) ) { 
					$(this).find('ul').css('width',$(this).outerWidth(true)+'px'); 
				}
				li.bind('mouseenter',function() {
					if ( !on ) {
						li.find('ul').animate(
							{ width: ['toggle', options.easing], height: ['toggle', options.easing], opacity: 'toggle' }, // Animation Properties
							options.fadeSpeed, // Duration
							options.easing, // Easing
							function(){ on = true; }  // Callback
						);
						if ( options.rollover ) li.css('background',options.rollovercolor);
					}
				});
				li.bind('mouseleave',function() {
					if ( on ) {
						on = false;
						li.find('ul').hide(
							options.fadeSpeed, // Duration
							options.easing, // Easing
							function(){ }  // Callback
						);
						if ( options.rollover ) li.css('background',options.bgcolor);
					} else {
						on = false;
						setTimeout( function(){ 
							li.find('ul').hide(
								options.fadeSpeed, // Duration
								options.easing, // Easing
								function(){ }  // Callback
							);
							if ( options.rollover ) li.css('background',options.bgcolor); 
						}, 500 );
					}
				});
			});
		} );
	} ;

	$(function() {
		//$("#menu").DropDown({bgcolor:'none',rollovercolor:'#004689'}); 
		$("#menu > span").bind('click',function(){
			$("#menu > span").each( function() {
				$("#"+$(this).attr('submenu')+"_submenu").hide();
				if ( $(this).attr('oldindex') != '' ) $(this).css('z-index',$(this).attr('oldindex'));
				$(this).attr('oldindex','');
			});
			
			
			var submenu = $(this).attr('submenu');
			$("#"+submenu+"_submenu").show();
			$(this).attr('oldindex',$(this).css('z-index'));
			$(this).css('z-index','10');
		});
	} );
	
	
	
