/*
GroupPhone
02-04-2010
-----------------
BrandTech
Jasper Haggenburg
-----------------
Phone - Button
*/
(function($)
{
	
	$.fn.button = function(action1, action2, hover) {
		/* private variables */
		var self 				= this;
		
		/* public variables */
		this.$container	= $(this);
		this.state 			= 'disabled';
		this.action			= 1;
		
    /* public methods */
		this.initialize = function() {
			this.enable();	
			
			self.$container.unbind('click').click(function() {
				if(self.state == 'enabled') {
					if(self.action == 1) {
						if($.isFunction(action1)){ action1(); };	
						if($.isFunction(action2)){ self.action = 2 };
					} else {
						if($.isFunction(action2)){ action2(); };	
						if($.isFunction(action2)){ self.action = 1 };
					}
				}
			}).disableTextSelect();
			
			if(hover) {
				this.$container.hover(function(){self.enable()}, function(){self.disable()});
				this.disable();
			}
			
			return this;
		};
		
		this.enable = function() {
			if(!$.browser.msie) this.$container.stop().animate({'opacity':1}, 200);
			this.$container.addClass('enabled').css('cursor','pointer');
			this.state = 'enabled';
			return this;
		};
			
		this.disable = function() {
			if(!$.browser.msie) this.$container.stop().animate({'opacity':0.6}, 200);
			this.$container.removeClass('enabled').css('cursor','default');
			this.state = 'disabled';
			return this;
		};

		return this.initialize();		
	};

})(jQuery);
