jQuery.noConflict();
jQuery.fn.droppy = function() {
	this.each(function() {
	
		var root = this, zIndex = 1000;
		
		jQuery('ul', this).hide();

		function getSubnav(ele) {
			if (ele.nodeName.toLowerCase() == 'li') {
				var subnav = jQuery('> ul', ele);
				return subnav.length ? subnav[0] : null;
			} 
			else {
				return ele;
			}
		}

		function getActuator(ele) {
			if (ele.nodeName.toLowerCase() == 'ul') {
				return jQuery(ele).parents('li')[0];
			} 
			else {
				return ele;
			}
		}

		function hide() {
			var subnav = getSubnav(this);
			if (!subnav) return;
			
			jQuery.data(subnav, 'cancelHide', false);
			jQuery.data(subnav, 'cancelShow', true); 
			
			setTimeout(function() {
				if (!jQuery.data(subnav, 'cancelHide')) {
					jQuery(subnav).slideUp('fast');
					setTimeout(function() { jQuery.data(subnav, 'cancelShow', false); }, 250);
				}
			}, 100);	
		}

		function show() {
			var subnav = getSubnav(this);
			if (!subnav) return;
			
			jQuery.data(subnav, 'cancelHide', true);
			
			if (!jQuery.data(subnav, 'cancelShow')){
				jQuery(subnav).css({zIndex: zIndex++}).slideDown('fast');
			}
			
			if (this.nodeName.toLowerCase() == 'ul'){
				jQuery(getActuator(this)).addClass('hover');
			}
		}

		jQuery('ul, li', this).hover(show, hide);
		jQuery('li', this).hover(
			function() { jQuery(this).addClass('hover'); },
			function() { jQuery(this).removeClass('hover'); }
		);
	
	});
};