jQuery.fn.textdropdown = function() {
	/*
	This is a modified version of the jQuery plugin from 
	http://anotherdan.com/57/simple-facebook-like-textbox-dropdown-jquery-plugin
	"with" basically sets the default object to be appended in front of every method call
	$(this) is the object that calls this function as a method
	*/
	var buttonSize = 'small';
	if (arguments.length == 1) {
		buttonSize = arguments[0];
	}
	
  with ($(this)) {
    with (next('ul:first')) {
      find('li').click(function() {
        $(this).parent().prev('.textdropdown-outer').find('input:first').attr('value', $(this).html());
        $(this).parent().hide();
      });
      hide();
    } 

    keypress(function() { 
      $(this).parent().next('ul:first').hide();
    });

    change(function() { 
      $(this).parent().next('ul:first').hide();
    });
		
		if (buttonSize == 'small') {
		  var buttonSrc = '/webcode/javascript/textdropdown.jquery.myversion/dropdown-arrow.gif';
			var buttonWidth = 10;
		} else {
		  var buttonSrc = '/webcode/javascript/textdropdown.jquery.myversion/dropdown-arrow-large.png';			
			var buttonWidth = 13;
		} //endif

    var w = width() + 1;
    wrap('<div class="textdropdown-outer" style="width: ' + w + 'px; height: ' + (height() + 5) + 'px;"></div>');
    parent().append('<img src="'+buttonSrc+'" class="textdropdown-btn" alt="" />');				
    var btn = parent().find('.textdropdown-btn');		
//    width(width() - btn.width() - 5);  //Safari isn't getting button width (btn.width()) for some reason, so hard code this
    width(width() - buttonWidth - 5);  //DEBUG
    css("border", "0");

    btn.click(function() {
      var p = parent();
      with (p.next('ul:first')) {
        css('position', 'absolute');
        css('width',    p.width());
        css('left',     p.position().left);
        css('top',      p.position().top + p.height() + 1);
        toggle();
      }
    });
  }
}
