/*======================================================================
	BUTTONIZE
	--------------------------------------------------------------------
	Purpose: Converts anchors and inputs into graphically-styled CSS
			 buttons via progressive enhancement. Allows for variable 
			 width/height, rounded corners, drop-shadows, and full-alpha 
			 transparency.
	--------------------------------------------------------------------	
	Authors: Ben Crouse & Jon Aldinger, WebLinc LLC
	Date:    June 2009
	Version: 1.0
	
	Credit:  The fundamentals of this technique were created by David Hellsing:
		     http://monc.se/kitchen/59/scalable-css-buttons-using-png-and-background-colors
----------------------------------------------------------------------*/
(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() { $this.trigger('click'); return false; })
					.insertBefore(this);
				
				$.each(['class', 'value', 'id'], function() { $this.removeAttr(this); });
				$this.addClass(settings.replacedClass);
			}
			
			($button || $this).html('<i/><span>' + text + '<i/><span/></span>');
		});
	};
})(jQuery);