var value;

jQuery.fn.textdropdown = function() {
 
	with ($(this)) {
	with (next('#get_list')) {
		find('li').click(function() {
			if($(this).hasClass("disabled")) return false;
			$("#text_id_input").val($(this).attr("id"));
			value = $(this).attr("id");			
			updateStockImageList();
			$(this).parent().prev('.textdropdown-outer').find('#text_search').attr('value', $(this).children('em:first').html());
			$(this).parent().hide();
		});
		hide();
	}

    keypress(function() { 
		$(this).parent().next('#get_list').hide();
    });
	var wrapper = $("#arrow_div");
    change(function() { 
		$(this).parent().next('#get_list').hide();
    });

    wrap('<div class="textdropdown-outer" ></div>');
    var btn = parent().prepend('<div id="arrow_div" class="textdropdown-btn">&nbsp;</div>').find('.textdropdown-btn');
    width(width() - btn.width() - 5);
    css("border", "0");

    btn.click(function() {
      var p = parent();
      with (p.next('#get_list')) {
        css('position', 'absolute');
        css('width',    p.width());
        css('left',     p.position().left);
        css('top',      p.position().top + p.height() + 1);
        toggle();
      }
    });
  }
}
