//hack
$(function(){
    $('.button').removeAttr("disabled"); 
});

(function($){
	$.fn.ajaxButton = function(options) {
		var defaults = {
			spinner : '/css/img/spinner.gif',
			message : 'Loading',
			type : 'show',
			element : 'button'
		};
		var options = $.extend(defaults, options);
        
        return this.each(function() {
			if(options.element == 'button')
			{
			    if(options.type == 'show')
    			{
    			    $(this).attr("disabled", true); 
             		$(this).addClass('loading');
             		$(this).val(options.message + '...');
    			}   
    			else if(options.type == 'hide')
    			{
    			    $(this).removeAttr("disabled");
    			    $(this).removeClass('loading');
    			    $(this).val(options.message);
    			}
			}
			else if(options.element == 'textbox')
			{
			    if(options.type == 'show')
			        $(this).addClass('loading');
			    else if(options.type == 'hide')
			        $(this).removeClass('loading');
			}
			else if(options.element == 'link')
			{
			    if(options.type == 'show')
			        $(this).addClass('loading-bar');
			    else if(options.type == 'hide')
			        $(this).removeClass('loading-bar');
			}
			else if(options.element == 'search_timeline')
			{
				if(options.type == 'show')
			        $(this).addClass('loading');
			    else if(options.type == 'hide')
			    {
					$(this).removeClass('loading');
					($(this).find('.left')).removeClass('loading');
				}    
					
			}
			
			   
		});
	};	
})(jQuery);

