jQuery.fn.selectEm = function() {
	jQuery(this).each(function(i,dom){
		var pos = null;
		var orig = null;
		var fake = null;
		var options = null;
		
		orig = jQuery(dom);
		fake = jQuery('<div class="select fake"><div class="selected"></div><div class="expander">&nbsp;</div><div class="options"></div></div>');
		pos = jQuery(dom).offset();
		orig.hide().after(fake);
		jQuery('option', orig).each(function(i,option){
			jQuery('.options', fake).append('<div class="option" id="' + jQuery(option).val() + '">' + jQuery(option).html() + '</div>');
		});
		
		jQuery('.selected', fake).html(jQuery('option:selected', orig).text());
		fake.click(function(){ showOptions(fake, orig, pos); });
	});
	
	
	
	
	
	
	
	function showOptions(fake, org, pos) {
		jQuery('.options', fake)
			.css({
				top: pos.top + 30,
				left: pos.left,
				maxHeight: 200
			}).slideDown(200, function(){
				fake.unbind('click', showOptions);
				jQuery('.option', fake).bind('click', function(){ selectOption(this, org, fake); });
				jQuery('body').bind('click', function(){ hideOptions(fake, org, pos); });
			});
	}
	
	function hideOptions(fake, org, pos) {
		jQuery('.options', fake).slideUp(200);
		jQuery('body').unbind('click');
		jQuery('.options', fake).unbind('click');
		fake.bind('click', function() { showOptions(fake, org, pos); });
	}
	
	function selectOption(clicked, org, fake) {
		
		var id = jQuery(clicked).attr('id');
		var old_selected = jQuery('option:selected', org).get(0);
		old_selected.selected = false;
		jQuery('option', org).each(function(){
			if (jQuery(this).val() == id) {
				this.selected = true;
				jQuery('.selected', fake).html(jQuery(this).html());
				return false;
			}
		});
	}
	
};

