/////////////////////////////////////////////////////////////////////////////////
// copyright 2003 by Peter Dematté                                             //
// MenuTree 1.0 (2003) 'menuExt.js' for ie4+, (N6), N7, Moz, Opera 7           //
// For some reason N6 doesen't shrink table after collapsing the tree          //
// Opera5 and 6 don't responde at all on .style.display = "none"               //
//                                                                             //
// This MenuTree is ment for right or left aligned Menu + Images (+/-)         //
//                                                                             //
// Id of TriggerRow, TriggerImage and affected Row must be "div";              //
// Name of TriggerImage must be "div" if used with DOM;                        //
// Trigger = changeNext(this) -> onClick or ondblClick;                        //
// openCloseAll(1) opens the Tree, openCloseAll(0) closes it;                  //
// TriggerRow and affected Row can be of any kind (<DIV>, <SPAN>, <A>, <TR>..) //
/////////////////////////////////////////////////////////////////////////////////
// <table>                                                                     //
//   <tr id="div" ondblClick="changeNext(this);">                              //
//     <td><a href="#">Some Link</a></td>                                      //
//     <td width="10">                                                         //
//       <img id="div" name="div" onClick="changeNext(this)" src="x.gif">      //
//     </td>                                                                   //
//   </tr>                                                                     //
//   <tr id="div"><td><table> .......... </table></td></tr>                    //
// </table>                                                                    //
/////////////////////////////////////////////////////////////////////////////////

// Preloading Images
img1=new Image();
img1.src="images/menu/plus_small.gif";
img2=new Image();
img2.src="images/menu/minus_small.gif";

// Redefine 'div' for DOM
function reDefineObjectsDOM() {
	countDiv = 0;
	countPix = 0;
	countSpl = 2; // 2nd div = img; every 3rd again;
	div = new Array;
	// menuAll = document.getElementsByName ('menu');
	pixAll = document.getElementsByName ('div');
	divAll = document.getElementsByTagName ('tr'); // use any other than 'tr' if so
	for (n = 0, size = divAll.length; n < size; n++) {
		if (divAll[n].id == 'div') {
			if (countSpl == 3) {
				div[countDiv++] = pixAll[countPix++];
				// menu[countDiv-1] = pixAll[countPix-1]; // ???
				countSpl = 1;
			}
			div[countDiv++] = divAll[n];
			countSpl++;
		}
	}
}

// change (menu.)backgroundColor; if m is set, theObject will be overwritten by menu[m]
var oldObj = 0;
// var menu = new Array();
function changeColor (theObject,m) {
	// if (m != null) theObject = menu[m];
	// theObject.style.backgroundColor='#CCCCBB';
	// if (theObject != menu[oldObj]) menu[oldObj].style.backgroundColor='';
	// for (n = 0, size = menu.length; n <= size; n++) if (menu[n] == theObject) oldObj = n;
}

// Finds the triggerObject(obj) and returns the index of it
function findObjectIndex(obj) {
	for (n = 0, size = div.length; n <= size; n++) if (div[n] == obj) return n;
}

// Changes the displayState and the Picture (depending on m)
function changeElements(m, n) {
	if (m == 1 || m == "none") {
		div[n+2].style.display = "";
		div[n+1].src = "images/menu/minus_small.gif";
	}
	else {
		div[n+2].style.display = "none";
		div[n+1].src = "images/menu/plus_small.gif";
	}
}

// Calls findObjectIndex(obj) and hands the right Index to changeElements(m, n)
function changeNext(obj) {
	n = findObjectIndex(obj);
	if (obj.name == 'div') n--; 
	changeElements (div[n+2].style.display, n);
}

// Finds all Nodes and hands the right Index to changeElements(m, n)
function openCloseAll(m) {
	if (isDOM || isOpr) reDefineObjectsDOM();
	for (n = 0, size = div.length - 3; n <= size; n += 3) {
		if (!breadCrump[div[n].name]) {
			if (breadCrump[div[n].title] != 1) changeElements (m, n);
		}	else {
			if (breadCrump[div[n].name] != 1) changeElements (m, n);
		}
		// alert(div[n].name);
	}
}

function reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);

function checkBrowsers() {}
	var isDOM = document.getElementById ? true:false;
	var isNN4 = document.layers ? true:false;
	var isIE4 = document.all ? true:false;
	var isOpr = false;
	var isMac = false;
	if (isDOM && isIE4) {var isIE5up = true; isIE4 = false; isDOM = false;} else {var isIE5up = false;}
	if (navigator.userAgent.indexOf('Opera') != "-1") {isOpr = true; isDOM = false; isNN4 = false; isIE4 = false; isIE5up = false;}
	if (navigator.userAgent.indexOf('Mac') != "-1") {isMac = true;}
// if (isDOM && !isIE4) reDefineObjectsDOM();
checkBrowsers();