	(function($){
    $.bump = function(el, options){
    	
    	// Some object and DOM instansiation to make traversing the DOM less expensive
        var base = this;
        base.$el = $(el);
        base.el = el;
        base.$el.data("bump", base);
        
        base.init = function(){
            base.options = $.extend({},$.bump.defaultOptions, options);
            base.bumping = false;
            if(base.options.autostart)
            	base.startbump(); // Autostart the bump if we need to
        };
        
        // Start the bump and set the timers and handles
        base.startbump = function(event){    
        	if(base.bumping)
        		return true; 
        	base.$el.bind(base.options.bind,base.stopbump);
        	base.options.beforeAnim();
        	base.bumping = true;
        	// Set our bounce effect and duration as well as the time between bumps
        	base.timeval = setInterval(function(){base.$el.effect("bounce",{},base.options.duration);},base.options.gap);
        };
         
        // Stop the bump and remove handles
        base.stopbump = function(event){
        	if(!base.bumping)
        		return false;
         	base.options.beforeStop();
         	base.$el.unbind(base.options.bind,base.stopbump);
         	clearInterval(base.timeval); // Clear and stop the timer
         	base.bumping = false;
         	base.options.afterStop();
        };
        
        // Run initializer
        base.init();
    };
    
    $.bump.defaultOptions = {
        duration: 250,					// How many miliseconds the bounce should last
        gap: 2000,						// How many miliseconds between bounces
        autostart: true,				// Whether we start straight away or wait
        beforeAnim: function(){},		// Runs before the bumping starts
        beforeStop: function(){},		// Runs just before the bumping is stopped
        afterStop: function(){},		// Runs after the bumping has finished
        bind: "mouseenter"				// The handle we want the bumping to stop on, "click etc"
    };
    
    $.fn.bump = function(options){
        return this.each(function(){
            (new $.bump(this, options));
        });
    };
    
})(jQuery);

