/**
 * Spinner jQuery Plug-in by Alexis MINEAUD
 * email : alexis.mineaud@gmail.com
 */
 
;(function($) {

	$.fn.extend({
		spin: function(settings) {
			settings = $.extend({
				text: "",
				img: "/base/ress/icons/spinners/std_spinner.gif",
				className: "spin",
				delay: 150
			}, settings);
		
			var img = '<img src="'+ settings.img +'" />';
			var text = (settings.text == '' ? '' : '<div class="text">'+ settings.text +'</div>');
			
			return $(this).hide(0).show(150).html('<div class="'+ settings.text +'">'+ img + text +'</div>').show(settings.delay);
		},
		
		stopSpin: function(settings) {
			settings = $.extend({
				delay: 150
			}, settings);
			
			return $(this).hide(settings.delay).html('');
		},
		
		spinBefore: function(settings) {
			settings = $.extend({
				delay: 150
			}, settings);
				
			id = 'spin_' + ($(this).attr('id'));
			var html = '<div id="' + id + '"></div>';
			
			$(this).before(html);
			return $('div#'+id).spin(settings);
		},
		
		spinAfter: function(settings) {
			settings = $.extend({
				delay: 150
			}, settings);
				
			id = 'spin_' + ($(this).attr('id'));
			var html = '<div id="' + id + '"></div>';
			
			$(this).after(html);
			return $('div#'+id).spin(settings);
		}
	});
	
})(jQuery);