/*!
 * stampfx.js
 * Stamp effects plugin for Workhouse Advertising website.
 */

(function($) {
	var defaults = {
		effect: 'fade',
		options: { mode: 'hide' },
		speed: 'normal',
		fadeSpeed: 'normal',
		fadeDelay: 0
	};

	$.fn.stampfx = function(options, idOverrides) {
		return $(this).each(function() {
			var clicked = false;
			var settings = $.extend(true, {}, defaults, options, idOverrides[$(this).attr('id')]);
			return $(this).click(function(evt) {
				if (!clicked && (clicked = true)) {
					var callback = function() {
						$stamp.fadeIn(settings.fadeSpeed, function() {
							$(this).css({ filter: '' });
							clicked = false;
						});
					};
					var $stamp = $(this).effect(settings.effect, settings.options, settings.speed, function() {
						if (settings.fadeDelay > 0) {
							setTimeout(callback, settings.fadeDelay);
						} else {
							callback();
						}
					});
				}
				return this;
			});
		});
	};
})(jQuery);

