jQuery.fn.forma_vipad=function()
{
	var list=$(this).find(".vipad_list");
	var input=$(this).find(".vipad_input");
	
	$(list).find(".vipad_row").hover(
		function()
		{
			if (!$(this).is(".vipad_selected"))
			{
				$(this).addClass("vipad_row_over");
			}
		},
		function()
		{
			$(this).removeClass("vipad_row_over");
		}
	);
	
	$(input).keypress(function (event)
	{
		if (event.which==13)
		{
			$(input).val($(list).find(".vipad_selected").text());
			if ($(list).is(":visible"))
			{
				$(list).fadeOut(200);
				return false;
			}
			else
			{
				return true;	
			}
		}
	});
	
	$(input).keyup(function(event)
	{
		if (event.which==40)
		{
			vipad_selected=$(list).find(".vipad_selected").nextAll(":visible").eq(0);
			if ($(vipad_selected).length==0)
			{
				vipad_selected=$(list).find(".vipad_row:visible").eq(0);
			}
			$(list).find(".vipad_selected").removeClass("vipad_selected");
			$(vipad_selected).addClass("vipad_selected");
			$(input).val($(vipad_selected).text());
		}
		else if (event.which==38)
		{
			vipad_selected=$(list).find(".vipad_selected").prevAll(":visible").eq(0);
			if ($(vipad_selected).length==0)
			{
				vipad_selected=$(list).find(".vipad_row:visible").eq($(list).find(".vipad_row:visible").length-1);
			}
			$(list).find(".vipad_selected").removeClass("vipad_selected");
			$(vipad_selected).addClass("vipad_selected");
			$(input).val($(vipad_selected).text());
		}
		else
		{
			var reg=new RegExp($(input).val(), "i");
			$(list).find(".vipad_row").each(function(i, row)
			{
				var row_text=$(row).text();
				if (reg.test(row_text))
				{
					$(row).slideDown(70);
				}
				else
				{
					$(row).slideUp(70);
				}
			});
		}
	});
	
	$(input).focus(function()
	{
		$(list).removeClass("hid").show();
	});
	
	$(input).keyup(function(event)
	{
		if ((event.which==40)||(event.which==38))
		{
			$(list).removeClass("hid").show();
		}
	});
	
	$(input).click(function()
	{
		$(list).removeClass("hid").show();
	});
	
	$(input).blur(function()
	{
		$(list).fadeOut(200);
	});
	
	$(list).find(".vipad_row").each(function(i, row)
	{
		$(row).click(function()
		{
			$(input).focus().val($(row).text());
			$(list).find(".vipad_row").removeClass("vipad_selected");
			$(this).addClass("vipad_selected");
		});
	});
	
	
	return this;
};
