(function(jQuery) {
jQuery.fn.lava = function() {

	return this.each(function() {

		var $back= jQuery('<table  class="slider"><tr><td width=100% class="leftslider">&nbsp;</td><td width=50px class="rightslider">&nbsp;</td></tr></table>').appendTo(this);
		var $li = jQuery('.menuitem', this);
		var $selected = jQuery($li[0]);
		var ce = jQuery($selected)[0];

		// ******************** mouseover  *********************************
		$li.mouseover(function() {
			move(this);
		});

		// ******************** mouseout  *********************************
		jQuery(this).mouseout( function() {

		});

		// ******************** click  *********************************
		$li.click(function(e) {
		});

		$back.css({ left: 0, top: 0, width: 0, height: 0 });


		// ******************** move  *********************************
		function move(el) {
		    $back.css("display","block");
			if (!el) el = ce;
			// .backLava element border check and animation fix
			var bx=0, by=0;
			if (!jQuery.browser.msie) {
				bx = ($back.outerWidth() - $back.innerWidth())/2;
				by = ($back.outerHeight() - $back.innerHeight())/2;
			}
			$back.stop()
			.animate({
				left: el.offsetLeft-bx,
				top: el.offsetTop-by,
				width: el.offsetWidth,
				height: 38
			}, 300, 'swing');
		};
	});
};
})(jQuery);
