$(function()
{
	$.fn.dropMenu = function(options)
	{
		options = $.extend({
			type: 'menu'
		}, options || {});
		
		var clicked = 0;
		var menu = 0;
		var x = 0;
		if (options.type == 'actions') x = 30;
		
		//$(this).unbind('click');
		//$('body').unbind('click');
		
		$(this).click(function(event)
		{
			id_drop = 0; // обязательно сбрасываем
			
			if (current_drop)
			{
				$(current_drop).unbind('click');
				$(current_drop).hide();
			}
			
			if ($(this).attr('abbr')) id_drop = '#' + $(this).attr('abbr');			
			if (!id_drop) return;			
			current_drop = id_drop;
			clicked = 1;
			
			menu = $(id_drop)
			.css({
				left: event.pageX - x,
				top: event.pageY,
				display: 'none'
			})
			.html($(id_drop).html())
			.appendTo('body')
			.show();
		});
		
		$('body').click(function()
		{			
			clicked++;
			if (clicked > 2 && menu) menu.hide();
		});
	};
});

/*
$(function()
{
	$.fn.dropMenu = function(options)
	{
		options = $.extend({
		}, options || {});
		
		var id_tip;
		var clicked = 0;
		var menu = 0;
		
		$(this).unbind('click');
		$('body').unbind('click');
		
		$(this).click(function(event)
		{
			if ($(this).attr('abbr')) id_tip = '#' + $(this).attr('abbr');			
			if (!id_tip) return;
			clicked = 1;
			
			menu = $(id_tip)
			.css({
				left: event.pageX,
				top: event.pageY,
				display: 'none'
			})
			.html($(id_tip).html())
			.appendTo('body')
			.show();
		});
		
		$('body').click(function()
		{
			clicked++;
			if (clicked > 2 && menu) menu.hide();
		});
		*/
		/*
		
		$(this).mousemove(function(e)
		{
			if (!clicked) return false;
			
			var x = Math.round($(this).offset().left) + 2;
			var y = Math.round($(this).offset().top) + 2;
			var width = Math.round($(this).width()) - 4;
			var height = Math.round($(this).height()) - 4;
			
			$('#log').html("x1: " + e.pageX + ", y1: " + e.pageY + ", " + x + ", " + y + ", " + width + ", " + height);
			
			if (e.pageX <= x || e.pageX >= (x + width) || e.pageY <= y || e.pageY >= (y + height)) $(id_tip).fadeOut(100);
		});
		
		$(id_tip).mousemove(function(e)
		{
			if (!clicked) return false;
			
			$('#log').html("x2: " + e.pageX + ", y2: " + e.pageY + ", pos2: " + $(id_tip).offset().left);
		});
		*/
/*
	};
});
*/
