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

    return this.each(function() {
        var me = $(this), noop = function(){},
			$li = $(">li", this), 
			curr = $("li.current", this)[0] || $($li[0]).addClass("current")[0];
			$back = $('<li class="back"><div class="left"></div></li>').appendTo(me);
			$back.css({ "left": curr.offsetLeft+"px", "width": curr.offsetWidth+"px" });
			$("#menuTop").mouseover(function(){
				//$('#tooltype').slideUp(50);
				$('#tooltype').remove();
				move(curr,function(){});
			});
			
			$li.hover(function(){
				$(this).addClass("hover");
				//$('#tooltype').slideUp(50);
				$('#tooltype').remove();
				mess=$(this).find("ul").html();
				clickElementx=$(this)[0].offsetLeft-1;
				clickElementy=$(this)[0].offsetTop+30;
				//if ( $('#tooltype').length ){
				//	$('#tooltype').html("<ul>"+mess+"</ul>");
				//} else {
					$(this).parent().append("<div id='tooltype' style=''><ul>"+mess+"</ul></div>");
				//}
				$('#tooltype').css({left: clickElementx+"px", top: clickElementy+"px"});//,height:0
					

				
				move($(this)[0],function(){
					//$.log($($lastLi).find("ul").height());
					$('#tooltype').slideDown(100);
					$("#tooltype").hover(function(){},function(){
						$('#tooltype').remove();
						//$('#tooltype').slideUp(50);
						move(curr);
					});

				});
			},function(){
				$(this).removeClass("hover");
				
				
			});
		
        function move(el,cb) {
			
			//alert(el.offsetLeft);
			$(".subnav").hide();
            $back.each(function() {
                $(this).dequeue(); }
            ).animate({
                width: el.offsetWidth,
                left: el.offsetLeft
            }, o.speed, o.fx,cb);
        };

    });
};
})(jQuery);