(function($) {
	$.fn.lavaLamp = function(options) {
		var opts = $.extend({}, {
			fx: "linear",
			speed: 500,
			click: function() {}
		}, options);
		
		return this.each(function(i, e) {
			var $this = $(this),
				$blob = $('<li class="blob"><span></span></li>').appendTo($this),
				$li = $("li:not(.blob, .hosting)", this),
				current = $("li.on", this)[0];
			
			var setBlob = function(ele) {
				$blob.css({
					'left': ele.offsetLeft,
					'width': ele.offsetWidth
				});
				current = ele;
			};
			
			$li.hover(function() {
				move(this.offsetWidth, this.offsetLeft);
			}, function() {
				!current ? move(50, $('.hosting')[0].offsetLeft) : move(current.offsetWidth, current.offsetLeft);
			});
			$li.click(function(e) {
				setBlob(this);
				return opts.click.call($('a', this)[0]);
			});
			!current ? $blob.css({ 'left': 824 }) : setBlob(current);
			
			var move = function(eWidth, eLeft) {
				$blob.each(function() {
					$.dequeue(this, "fx");
				}).animate({
					width: eWidth,
					left: eLeft
				}, opts.speed, opts.fx);
			};
		});
	};
})(jQuery);
