Index: /extensions/rv_menutree/trunk/js/rvtree.js
===================================================================
--- /extensions/rv_menutree/trunk/js/rvtree.js	(revision 27410)
+++ /extensions/rv_menutree/trunk/js/rvtree.js	(revision 27411)
@@ -94,9 +94,6 @@
 			{
 				// This LI has UL's in it, so it's a +/- node
-				if ( !XElement.hasClass(item, RVTree.options.nodeOpenClass) )
-					XElement.addClass(item, RVTree.options.nodeClosedClass);
-
 				// If it's just text, make the text work as the link also
-				if (item.firstChild.nodeName=="#text")
+				if (item.firstChild.nodeType==3)
 				{
 					t = t+item.firstChild.nodeValue;
@@ -127,9 +124,6 @@
 			if (isRoot && RVTree.options.IEVersion && RVTree.options.IEVersion < 8)
 				item.style.marginLeft="-16px"; // thats IE6,IE7 ; IE8 seems more compliant
-			if (s)
-			{
-				s.appendChild(document.createTextNode(t));
-				item.insertBefore(s,item.firstChild);
-			}
+			s.appendChild(document.createTextNode(t));
+			item.insertBefore(s,item.firstChild);
 		}
 		ul.style.marginLeft = 0;
Index: /extensions/rv_menutree/trunk/js/rvtree.min.js
===================================================================
--- /extensions/rv_menutree/trunk/js/rvtree.min.js	(revision 27410)
+++ /extensions/rv_menutree/trunk/js/rvtree.min.js	(revision 27411)
@@ -1,5 +1,4 @@
-var XElement={hasClass:function(a,d){if(!a)return false;var f=a.className;return f.length>0&&(f==d||RegExp("(^|\\s)"+d+"(\\s|$)").test(f))},addClass:function(a,d){if(a){XElement.hasClass(a,d)||(a.className+=(a.className?" ":"")+d);return a}},toggleClasses:function(a,d,f){if(a){for(var b=a.className.split(/\s+/),g=-1,c=-1,e=0;e<b.length;e++){if(b[e]==d)g=e;if(b[e]==f)c=e}if(g>=0){b.splice(g,1);c>=g&&c--}else b.push(d);c>=0?b.splice(c,1):b.push(f);a.className=b.join(" ");return a}}},RVTree={options:{nodeClosedClass:"liClosed",
-nodeOpenClass:"liOpen",nodeBulletClass:"liBullet",nodeLinkClass:"bullet"},convertTree:function(a){if(document.createElement){if(window.attachEvent&&!window.opera)if(/MSIE ([0-9]{1,}[.0-9]{0,})/.exec(navigator.userAgent)!=null)RVTree.options.IEVersion=parseFloat(RegExp.$1);RVTree._processList(a,true)}},_processList:function(a,d){if(!(!a.childNodes||a.childNodes.length==0)){for(var f=0;f<a.childNodes.length;f++){var b=a.childNodes[f];if(b.nodeName=="LI"){for(var g=false,c=0;c<b.childNodes.length;c++){var e=
-b.childNodes[c];if(e.nodeName=="UL"){g=true;RVTree._processList(e,false)}}c=document.createElement("SPAN");e="\u00a0";c.className=RVTree.options.nodeLinkClass;if(g){XElement.hasClass(b,RVTree.options.nodeOpenClass)||XElement.addClass(b,RVTree.options.nodeClosedClass);if(b.firstChild.nodeName=="#text"){e+=b.firstChild.nodeValue;b.removeChild(b.firstChild)}c.onclick=function(){XElement.toggleClasses(this.parentNode,RVTree.options.nodeOpenClass,RVTree.options.nodeClosedClass);return false}}else if(XElement.hasClass(b,
-RVTree.options.nodeClosedClass))c.onclick=function(){var h=this.parentNode.getElementsByTagName("A");if(h.length)document.location=h[0].href};else XElement.addClass(b,RVTree.options.nodeBulletClass);b.style.listStyleType="none";if(d&&RVTree.options.IEVersion&&RVTree.options.IEVersion<8)b.style.marginLeft="-16px";if(c){c.appendChild(document.createTextNode(e));b.insertBefore(c,b.firstChild)}}}a.style.marginLeft=0;a.style.paddingLeft=d?0:"8px"}}};
-(function(){if(typeof _rvTreeAutoQueue!="undefined"&&_rvTreeAutoQueue.length)for(var a=0;a<_rvTreeAutoQueue.length;a++)RVTree.convertTree(_rvTreeAutoQueue[a]);_rvTreeAutoQueue={push:function(d){RVTree.convertTree(d)}}})();
+var XElement={hasClass:function(a,e){if(!a)return!1;var f=a.className;return 0<f.length&&(f==e||RegExp("(^|\\s)"+e+"(\\s|$)").test(f))},addClass:function(a,e){if(a)return XElement.hasClass(a,e)||(a.className+=(a.className?" ":"")+e),a},toggleClasses:function(a,e,f){if(a){for(var b=a.className.split(/\s+/),g=-1,c=-1,d=0;d<b.length;d++)b[d]==e&&(g=d),b[d]==f&&(c=d);0<=g?(b.splice(g,1),c>=g&&c--):b.push(e);0<=c?b.splice(c,1):b.push(f);a.className=b.join(" ");return a}}},RVTree={options:{nodeClosedClass:"liClosed",
+nodeOpenClass:"liOpen",nodeBulletClass:"liBullet",nodeLinkClass:"bullet"},convertTree:function(a){document.createElement&&(window.attachEvent&&!window.opera&&null!=/MSIE ([0-9]{1,}[.0-9]{0,})/.exec(navigator.userAgent)&&(RVTree.options.IEVersion=parseFloat(RegExp.$1)),RVTree._processList(a,!0))},_processList:function(a,e){if(a.childNodes&&0!=a.childNodes.length){for(var f=0;f<a.childNodes.length;f++){var b=a.childNodes[f];if("LI"==b.nodeName){for(var g=!1,c=0;c<b.childNodes.length;c++){var d=b.childNodes[c];
+"UL"==d.nodeName&&(g=!0,RVTree._processList(d,!1))}c=document.createElement("SPAN");d="\u00a0";c.className=RVTree.options.nodeLinkClass;g?(3==b.firstChild.nodeType&&(d+=b.firstChild.nodeValue,b.removeChild(b.firstChild)),c.onclick=function(){XElement.toggleClasses(this.parentNode,RVTree.options.nodeOpenClass,RVTree.options.nodeClosedClass);return!1}):XElement.hasClass(b,RVTree.options.nodeClosedClass)?c.onclick=function(){var a=this.parentNode.getElementsByTagName("A");a.length&&(document.location=
+a[0].href)}:XElement.addClass(b,RVTree.options.nodeBulletClass);b.style.listStyleType="none";e&&RVTree.options.IEVersion&&8>RVTree.options.IEVersion&&(b.style.marginLeft="-16px");c.appendChild(document.createTextNode(d));b.insertBefore(c,b.firstChild)}}a.style.marginLeft=0;a.style.paddingLeft=e?0:"8px"}}};(function(){if("undefined"!=typeof _rvTreeAutoQueue&&_rvTreeAutoQueue.length)for(var a=0;a<_rvTreeAutoQueue.length;a++)RVTree.convertTree(_rvTreeAutoQueue[a]);_rvTreeAutoQueue={push:function(a){RVTree.convertTree(a)}}})();
Index: /extensions/rv_menutree/trunk/main.inc.php
===================================================================
--- /extensions/rv_menutree/trunk/main.inc.php	(revision 27410)
+++ /extensions/rv_menutree/trunk/main.inc.php	(revision 27411)
@@ -47,9 +47,29 @@
 		global $template, $page;
 
+		$upper_ids = isset($page['category']['uppercats']) ? array_flip( explode(',', $page['category']['uppercats'])) : null;
+		$refLevel = 0;
+		foreach($block->data['MENU_CATEGORIES'] as &$cat)
+		{
+			$level = $cat['LEVEL'];
+			if ($level>$refLevel)
+				$pre = '<ul'.($refLevel==0?' class=rvTree id=theCategoryMenu':'').'>';
+			else
+				$pre = '</li>'.str_repeat('</ul></li>', $refLevel-$level);
+
+			$class= $cat['SELECTED'] ? 'selected ' : '';
+			if ($cat['count_categories'] > 0)
+				$class .= isset($upper_ids[$cat['id']]) ? 'liOpen':'liClosed';
+			if (!empty($class))
+				$class=' class="'.$class.'"';
+			$cat['PRE'] = $pre;
+			$cat['CLASS'] = $class;
+			$refLevel = $level;
+		}
+		unset($cat);
 		$rvmt_base_name  = basename(dirname(__FILE__));
 		$template->set_template_dir(PHPWG_ROOT_PATH.'plugins/'.$rvmt_base_name.'/template/');
 		$template->assign(array(
 			'RVMT_BASE_NAME' => $rvmt_base_name,
-			'RVMT_UPPER_IDS' => isset($page['category']['uppercats']) ? array_flip( explode(',', $page['category']['uppercats'])) : null,
+			'RVMT_POST' => str_repeat('</li></ul>', $refLevel),
 			)
 		);
Index: /extensions/rv_menutree/trunk/template/rv_menutree_categories.tpl
===================================================================
--- /extensions/rv_menutree/trunk/template/rv_menutree_categories.tpl	(revision 27410)
+++ /extensions/rv_menutree/trunk/template/rv_menutree_categories.tpl	(revision 27411)
@@ -4,25 +4,7 @@
 <dd>
 {strip}
-{assign var='ref_level' value=0}
 {foreach from=$block->data.MENU_CATEGORIES item=cat}
-	{if $cat.LEVEL > $ref_level}
-		<ul{if $ref_level == 0} class=rvTree id=theCategoryMenu{/if}>
-	{else}
-		</li>
-		{'</ul></li>'|@str_repeat:($ref_level-$cat.LEVEL)}
-	{/if}
-	{if $cat.SELECTED}
-		{assign var=liclass value='selected '}
-	{else}
-		{assign var=liclass value=''}
-	{/if}
-	{if $cat.count_categories > 0}
-		{if isset($RVMT_UPPER_IDS[$cat.id])}
-			{assign var=liclass value="`$liclass`liOpen"}
-		{else}
-			{assign var=liclass value="`$liclass`liClosed"}
-		{/if}
-	{/if}
-	<li{if !empty($liclass)} class="{$liclass}"{/if}> <a href="{$cat.URL}"{if $cat.IS_UPPERCAT} rel="up"{/if}>{$cat.NAME}</a>
+	{$cat.PRE}
+	<li{$cat.CLASS}> <a href="{$cat.URL}"{if $cat.IS_UPPERCAT} rel="up"{/if}>{$cat.NAME}</a>
 		{if $cat.count_images > 0}
 			<span{if $cat.nb_images <= 0} class=menuInfoCatByChild{/if} title="{$cat.TITLE}"> [{$cat.count_images}] </span>
@@ -31,7 +13,6 @@
 			<img title="{$cat.icon_ts.TITLE}" src="{$ROOT_URL}{$themeconf.icon_dir}/recent{if $cat.icon_ts.IS_CHILD_DATE}_by_child{/if}.png" alt="(!)">
 		{/if}
-	{assign var='ref_level' value=$cat.LEVEL}
 {/foreach}
-{'</li></ul>'|@str_repeat:$ref_level}
+{$RVMT_POST}
 {/strip}
 {combine_script id='rvmt' load='async' path="plugins/`$RVMT_BASE_NAME`/js/rvtree.min.js"}
