Inserting a custom menu group into a drupal suckerfish menu

We have a huge anchored document with and equally huge TOC. There’s also a traditional drupal menu on that page.
My goal was to get the inline menu into the drupal menu.

Div swapping didn’t work ie: div1.innerHTML = div2.innerHTML. The menu showed up but the open / close functionality was lost.

So moving the node was the key.


		$(document).ready(function() {
			document.getElementById('dhtml_menu-254').parentNode.className='first dhtml-menu collapsed start-collapsed';
			insertAfter(document.getElementById('toc'),document.getElementById('dhtml_menu-252'));
			node2delete=document.getElementById("dhtml_menu-269").parentNode;
			node2delete.parentNode.removeChild(node2delete);
		});

		//create function, it expects 2 values.
		function insertAfter(newElement,targetElement) {
			//target is what you want it to go after. Look for this elements parent.
			var parent = targetElement.parentNode;
			//if the parents lastchild is the targetElement...
			if(parent.lastchild == targetElement) {
				//add the newElement after the target element.
				parent.appendChild(newElement);
			} else {
				// else the target has siblings, insert the new element between the target and it's next sibling.
				parent.insertBefore(newElement, targetElement.nextSibling);
			}
		}