(function($) {
	$.fn.buttonize = function(options) {
		var settings = $.extend({ replacedClass: 'button-replaced' }, options);

		return this.each(function() {
			var $this = $(this),
				text = $this.text() || $this.val(),
				$button = null;

			if($this.is('input')) {
				$button = $('<a href="#"></a>').addClass(this.className)
											   .attr('id', this.id)
											   .click(function(e) {
												   e.preventDefault();
												   $this.get(0).click();
											   })
											   .insertBefore(this);

				$.each(['class', 'value', 'id'], function() { $this.removeAttr(this); });
				$this.addClass(settings.replacedClass);
			}

			($button || $this).html('<i/><span>' + text + '<i/><span/></span>');
		});
	};
})(jQuery);

