/**
 * @author Frantic Oy
 */
function sideNaviMulti() {
	
	var	classes = {}
	classes.hl = 'navi_static_pointer'; // highlight class
	classes.top = 'navi_3rd_lvl';
	classes.sub = 'navi_4th_lvl';
	classes.topItem = 'navi_3rd_lvl_item';
	classes.subItem = 'navi_4th_lvl_item';

		// var regAurl = /\/A\d{6,10}/;
	     //var aurl = location.href.match(regAurl);
	     var aurl=location.pathname;
    
        // HR-urls fix
         if (aurl == null) {
            var aurl = $("#origurl").val();
         }

//Hide all sublevels
		 $('.'+classes.sub).hide();

//look though all links in 3rd_level
		 $('li.'+classes.topItem).each(
		 	function()
			{
				
		 /*if found,
		 add higlight class, show any sublevels,replace link with text => linkToText()*/;
		 
				if ($(this).find('a:first').attr('href')==aurl) {
					$(this).addClass(classes.hl).find('ul').show();
					linkToText($(this).find('a:first').get(0));
					return
				/*if match was found, that's it. stop */
				}
			}
		 );
				 
/*look through sublevels if nothing was found on the top level		 	*/
		 $('li.'+classes.subItem).each(
		 	function()
			{
				
		 /*if found,
		 add higlight class, show any sublevels,replace link with text => linkToText()*/;
		 		if ($(this).find('a:first').attr('href')==aurl) {
					$(this).addClass(classes.hl).parent().show();
					linkToText($(this).find('a:first').get(0));
					return
				//if match was found, that's it. stop 
				}
			}
		 );
				
}

function linkToText(linkObj) {
	//remove the anchor object but preserve the text it contains
	var parentElem = linkObj.parentNode;
	var text = linkObj.innerHTML;

	parentElem.removeChild(linkObj);
	newText = document.createTextNode(text);
	newText.nodeValue = newText.nodeValue.replace(' &amp; ',' & ');
	newText.nodeValue = newText.nodeValue.replace(' &#38; ', ' & ');
	parentElem.insertBefore(newText,parentElem.firstChild);
	
}
//run the script
	sideNaviMulti();

