(function($) {
$.fn.lavaLamp = function(o) {
    o = $.extend({ 'startItem': 0, fx: "linear", speed: 500, click: function(){} }, o || {});

    return this.each(function() {
        var me = $(this), noop = function(){},
            $back = $('<li class="back"><div class="left"></div></li>').appendTo(me),
            $li = $("li", this), 
            $curr,$shown;
       
        if (o.startItem>=0)
        {
			$("#aeo").text("CT");
			$($li[o.startItem]).addClass("current")[0];
			$curr = $("li.current", this);
        }
        else
			$curr = $("#aeo");

        $li.not(".back").hover(function() {
			set_shown($(this));
        }, noop);

        $(this).hover(noop, function() {
			set_shown($curr);
        });

        $li.click(function(e) {
			set_shown($(this));
            return o.click.apply(this, [e, this]);
        });

		$shown=null;
        set_shown($curr);

        function set_shown($el) {
			if ($el==$shown)
				return;
			
			var $ashown=$shown;
			$shown=$el;
			
			if ($ashown==null) {
				if ($el==null)
					return;
				
				if ($el.attr('id')=="aeo") {
					$el.css({"width":"96px"});
					$el.text("CÁLCULAR TALLA");
					$(".ll_extopt").addClass("selected");
					$back.css({"opacity":0.01});
				}
				else {
					$back.css({"opacity":1.0});
					$back.css({ "left": $el[0].offsetLeft+"px", "width": $el[0].offsetWidth+"px" });
				}
				return;
			}
			
			if ($ashown.attr('id')=="aeo") {
				$ashown.stop().animate({
					width: "16px"
				}, {queue:false, duration:400} );
				$ashown.text("CT");
				$(".ll_extopt").removeClass("selected");
			}
			else {
				if ($el.attr('id')=="aeo")
				{
					$back.stop().fadeTo("fast",0.01);
					$back.css({ "left": $ashown[0].offsetLeft+"px", "width": $ashown[0].offsetWidth+"px" });
				}
			}
			
			if ($el.attr('id')=="aeo") {
				$el.stop().animate({
				width: "96px",
				}, {queue:false, duration:400} );
				$el.text("CÁLCULAR TALLA");
				$(".ll_extopt").addClass("selected");
			}
			else {
				$back.stop().fadeTo("fast",1.0);
				$back.each(function() {
					$.dequeue(this, "fx"); }
				).animate({
					width: $el[0].offsetWidth,
					left: $el[0].offsetLeft
				}, o.speed, o.fx);
			}
		}

		$("#aeo").mouseover(function(){
			set_shown($(this));
		});

		$("#aeo").mouseout(function(){
			set_shown($curr);
		});
    });
};
})(jQuery)

