(function($){

	$.fn.jThrobby = function(options) {
		this.minAlpha = options.minAlpha ? options.minAlpha : 0.10;
		this.maxAlpha = options.maxAlpha ? options.maxAlpha : 0.90;
		this.targetAlpha = options.targetAlpha ? options.targetAlpha : 1.00;
		this.throb = options.throb ? options.throb : false;
		this.speed = options.speed ? options.speed : 500;
		this.easingIn = options.easingIn ? options.easingIn : "sineEaseInOut";
		this.easingOut = options.easingOut ? options.easingOut : "sineEaseInOut";
		this.now = options.now ? options.now : false;
		this.data('jThrob', this);
	
		this.vanish = function() {
			var jthrob = $(this).data('jThrob');
			if(jthrob.throb) {
				jthrob.animate(
					{opacity : jthrob.minAlpha}, 
					{ "duration" : jthrob.speed, 
					  "easing" : jthrob.easingIn, 
					  "complete" : jthrob.appear });
			}
			else {
				jthrob.animate(
					{opacity : jthrob.minAlpha}, 
					{ "duration" : jthrob.speed, 
					"easing" : jthrob.easingIn });	
			}
		}
	
		this.appear = function() {
			var jthrob = $(this).data('jThrob');
			if(jthrob.throb == true) {
				jthrob.animate({opacity : jthrob.maxAlpha}, { "duration" : jthrob.speed, "easing" : jthrob.easingOut, "complete" : jthrob.vanish });
			}
			else {
				jthrob.animate({opacity : jthrob.maxAlpha}, { "duration" : jthrob.speed, "easing" : jthrob.easingOut });	
			}
		}
	
		this.reveal = function() {
			var jthrob = $(this).data('jThrob');
			jthrob.stop();
			jthrob.animate({opacity : jthrob.targetAlpha}, { "duration" : jthrob.speed / 2, "easing" : jthrob.easingOut });
		}
	
	    if(!this.now) {
    		this.mouseover(this.vanish);
    		this.mouseout(this.reveal);   
	    }
	    else {
	        this.vanish();
	    }
	}
	
})(jQuery);
