/***************************************************************
* - File: $Id: multi_menu.js
*
*
* **************************************************************
*
*  Copyright notice
*
**  (c) 2008 Stefan Fritsche 
*  All rights reserved
*
* **************************************************************
*
*  This source file is subject to InfoPortal CMS license
*  that is bundled with this package in the files LICENSE_EN.TXT or     
*  LICENSE_DE.TXT.
*
*  If you need more Information about this license or if
*  you did not receive a copy about it, please go to 
*     http://www.ip-cms.com
*  or send a note to license@ip-cms.com so we can mail you a 
*  copy immediately.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
 * handler: Event Handler, der aufgerufen wird, sobald ein Eintrag im
 * Menü angeklickt wird. 
 */
function handler(e) {
 		    var ev = e || window.event;
  			var target = ev.srcElement || ev.target; 
  
            // Liste der DIV's auslesen
            var list = document.getElementsByTagName("div");

            // Alle Menüs lesen, und danach die Handler setzen
            for(var i = 0; i < list.length; ++i) {
                var node = list[i];
                    if(node.id == "menu") {
                        var childs = node.getElementsByTagName("li");
                        for(var j = 0; j < childs.length; ++j) {
                            childs[j].className = "hide";    
                        }
                    }
            }
  
  			if (target != this) return;
  			if(target.className == "tweak")
   				target.className = "hide";
  			else
   				target.className = "tweak";
}

// Liste der DIV's auslesen
var list = document.getElementsByTagName("div");

// Alle Menüs lesen, und danach die Handler setzen
for(var i = 0; i < list.length; ++i) {
	var node = list[i];
	// Multi Menü gefunden?
	if(node.id == "menu") {
		// Alle List Items suchen
		var childs = node.getElementsByTagName("li");
		for(var j = 0; j < childs.length; ++j) {
			if (childs[j].className == "") {
				childs[j].className = "hide";	
				childs[j].onclick = handler;   
			}
		}
	}
}
 		
// Selektierte Einträge aufklappen!
for(var i = 0; i < list.length; ++i) {
	var node = list[i];
	// Multi Menü gefunden?
	if(node.id == "menu") {
		var childs = node.getElementsByTagName("li");
   		for(var j = 0; j < childs.length; ++j) {
   			// letzter selektierter Eintrag?
   			if (childs[j].className == "tweak_me") {
   				node = childs[j];
   				// Alle Elternknoten aufklappen
   				while (node && node.tagName != "div") {
   					node.className = "tweak";
   					node = node.parentNode;
   				}
   			} else { childs[j].className = "hide"; }
   		}
  	}
}




