/* 
 * Button which can be enabled and disabled,
 * has a function attached which only worked when enabled
 */
(function($)
{
	$.fn.Button = function(fn)
	{
		return this.each(function()
		{
			if(!$(this).is('input') || !$(this).is('a')) { return false; }

			this.fn = fn;
			this.disabled = false;
		    var scope = this;

			this.click(function(){
				if(!scope.disabled && typeof scope.fn == 'function') { scope.fn(); }
				return false;
			});

			this.hover(function(){ if(!scope.disabled) { scope.addClass('hover'); } }, function() { scope.removeClass('hover'); });
			this.mousedown(function(){ scope.addClass('active'); });
			this.mouseup(function(){ scope.removeClass('active'); });

		});
	};

	$.fn.Disable = function()
	{
		return this.each(function()
		{
			this.disabled = true;
			$(this).addClass('disabled');
		});
	};

	$.fn.Enable = function()
	{
		return this.each(function()
		{
			this.disabled = false;
			$(this).removeClass('disabled');
		});
	};

})(jQuery);

