(function($) {
	$.fn.shake = function(intShakes, intDistance, intDuration, color, colorOld) {
		this.each(function() {
			var self = this;
			$(this).css({'position':'relative'});
			if(color && colorOld) {
				$(this).css({'border-color': color});
				
				$(this).oneTime(intShakes * 250, function() {
					$(self).css({'border-color': colorOld});
				});
			}
			for (var x=1; x<=intShakes; x++) {
				$(this).animate({left:(intDistance*-1)}, (((intDuration/intShakes)/4)))
					.animate({left:intDistance}, ((intDuration/intShakes)/2))
					.animate({left:0}, (((intDuration/intShakes)/4)));
			}
		});
		return this;
	};
	
})(jQuery);