
// the timeout for the menu
var timeout = 400;

var doneOnce = false;
var doneContentOnce = false;
var allFixed = false;

var minScreenWidth = 770;

var contentWidth = 100;
var screenWidth;
var mainAxis;
var mainJustify;
var mainWidth = 0;
var menuWidth = 0;

// not very clean but simple
// the function can be run in the HTML for faster display
// window.onload=initMenu;

// creat timeout variables for list item
// it's for avoid some warning with IE
for( var i = 0; i < 100; i++ )
{
    eval("var timeoutli" + i + " = false;");
}

// this function apply the CSS style and the event
function initMenu(justify, axisMain, axisSub)
{
		mainJustify = justify;
		mainAxis = axisMain;

		screenWidth = document.body.clientWidth - 12;
		if (browser.isNS) screenWidth -= 6;
		if (browser.isIE) screenWidth += 9;
		if (axisMain == "h") screenWidth += 3;

		if (screenWidth < minScreenWidth) screenWidth = minScreenWidth;

    // a test to avoid some browser like IE4, Opera 6, and IE Mac
    if ( browser.isDOM1
    && !( browser.isMac && browser.isIE )
    && !( browser.isOpera && browser.versionMajor < 7 )
    && !( browser.isIE && browser.versionMajor < 5 ) )
    {
        menu = document.getElementById('menuv');

        var lis = menu.getElementsByTagName('li'); // all the li
//var bevLeft = 0;
        var theWidth = 0;
        var subWidth = 0;
        var subHeight = 0;
        // i am searching for ul element in li element
        for ( var i=lis.length-1; ( i >= 0 && !doneOnce); i-- )
        {

            // is there a ul element ?
            ulis = lis.item(i).getElementsByTagName('ul');

						if (lis.item(i).childNodes[0].offsetWidth > lis.item(i).offsetWidth)
							    var theWidth = lis.item(i).childNodes[0].offsetWidth;
						else  var theWidth = lis.item(i).offsetWidth;


//lis.item(i).childNodes[0].style.left = bevLeft + "px";
//bevLeft += 128;
						menuWidth = theWidth;
							//alert(lis.item(i));
							//lis.item(i).style.width = lis.item(i).childNodes[0].offsetWidth + "px";
							//lis.item(i).childNodes[0].style.width = lis.item(i).offsetWidth + "px";
							//alert(lis.item(i).childNodes[0].offsetWidth + "px");

        		//alert(lis.item(i).offsetWidth);
//alert(lis.item(i).tagName + " = " + lis.item(i).offsetWidth + " ::: " + lis.item(i).childNodes[0].tagName + " = " + lis.item(i).childNodes[0].offsetWidth + " ::: " + theWidth);

						//alert(i + " : " + lis.item(i).offsetWidth);
						if (lis.item(i).parentNode.parentNode.tagName == "LI")
						{
							//alert("LI");
							subWidth += theWidth;
						}

						if (axisMain == "h")
						{
							if (lis.item(i).parentNode.parentNode.tagName == "DIV")
							{
								//alert("DIV");
								lastMain = i;
								if (!browser.isIE && (i + 1) < lis.length)
								{
									//alert(theWidth);
									//lis.item(i).style.width = theWidth + "px";
									mainWidth += lis.item(i).childNodes[0].offsetWidth;
									//alert(theWidth);
								}
								else mainWidth += theWidth;

								menu.style.width = mainWidth + "px";
								//lis.item(i).parentNode.parentNode.style.padding = "10px";
								//alert(mainWidth + "px");
							}
						}
						else
						{
							if (lis.item(i).parentNode.parentNode.tagName == "DIV")
							{
								menu.style.width = theWidth + "px";
								mainWidth = theWidth;
								//alert(mainWidth);

								//lis.item(i).childNodes[0].style.top = subHeight + "px";
								//subHeight += lis.item(i).childNodes[0].offsetHeight;
								//lis.item(i).offsetWidth;
								//alert(ulis.item(0).childNodes[1].childNodes[0].offsetWidth);
								//alert(lis.item(i).childNodes[0].style.padding);
							}
						}

            if ( ulis.length > 0 )
            {
            		ulis.item(0).style.top = (ulis.item(0).offsetTop + lis.item(0).offsetHeight - 0) + "px";

            	   //alert("UL");
            		if (axisMain == 'h' && !doneOnce)
            		{
            		   ulis.item(0).style.left = "0px"; //(ulis.item(0).offsetLeft - lis.item(0).offsetWidth) + "px";
            		   ulis.item(0).style.top  = lis.item(i).childNodes[0].offsetHeight + "px";
            		}
            		if (axisMain == 'v' && !doneOnce) ulis.item(0).style.top  = (ulis.item(0).offsetTop  - lis.item(0).offsetHeight) + "px";

            		//subWidth -= lis.item(i).offsetWidth;
            		if (axisSub == "h") ulis.item(0).style.width = subWidth + "px";
            		else ulis.item(0).style.width = theWidth;
            		subWidth = 0;

            		if (justify == "r" && axisMain == "h" && axisSub == "h")
            		{
            			if (ulis.item(0).offsetWidth > theWidth)
            			{
            				ulis.item(0).style.left = (0 - (ulis.item(0).offsetWidth - theWidth)) + "px";
            			}
            		}

                // improve IE key navigation
                if ( browser.isIE )
                {
                    addAnEvent(lis.item(i),'keyup',show);
                }
                // link events to list item
                addAnEvent(lis.item(i),'mouseover',show);
                addAnEvent(lis.item(i),'mouseout',timeoutHide);
                addAnEvent(lis.item(i),'blur',timeoutHide);
                addAnEvent(lis.item(i),'focus',show);

                // add an id to list item
                lis.item(i).setAttribute( 'id', "li"+i );
                //lis.item(i).getElementsByTagName('a')[0].className = 'menuIndicateur';
                hideUlUnderLi(lis.item(i));

								if (document.layers)
								{
									//alert("1"); UNKNOWN - OPERA???
									//ulis.item(0).top = lis.item(i).offsetTop;
								}
								else if (document.all)
								{
									//alert("2"); INTERNET EXPLORER
									//ulis.item(0).style.top = lis.item(i).offsetTop;

									if (axisMain == "v")
									{
										//theOffset = theWidth + menu.offsetLeft - 0;
										ulis.item(0).style.left = theWidth + "px";
										if (browser.isNS) ulis.item(0).style.top = lis.item(i).offsetTop + "px";
										if (axisSub == "h")
										{
											var thisLeft = 0;
											for (j = 0; j < ulis.item(0).childNodes.length; j++)
											{
												if (ulis.item(0).childNodes[j].tagName != undefined)
												{
													diff = ulis.item(0).childNodes[j].childNodes[0].offsetWidth - ulis.item(0).childNodes[j].offsetWidth;
													//lis.item(i).style.width = theWidth + "px";
													ulis.item(0).childNodes[j].style.left  = thisLeft + "px";
													thisLeft += diff;
													//alert(thisLeft);
												}
											}
										}
									}

								}
								else if (document.getElementById)
								{
									//MOZILLA
									//alert(menu.offsetLeft);
									//alert(lis.item(i).offsetWidth);
									if (axisMain == "v")
									{
										//theOffset = theWidth + menu.offsetLeft - 0;
										ulis.item(0).style.left = theWidth + "px";
										if (browser.isNS) ulis.item(0).style.top = lis.item(i).offsetTop + "px";
										if (axisSub == "h")
										{
											var thisLeft = 0;
											for (j = 0; j < ulis.item(0).childNodes.length; j++)
											{
												if (ulis.item(0).childNodes[j].tagName != undefined)
												{
													diff = ulis.item(0).childNodes[j].childNodes[0].offsetWidth - ulis.item(0).childNodes[j].offsetWidth;
													//lis.item(i).style.width = theWidth + "px";
													ulis.item(0).childNodes[j].style.left  = thisLeft + "px";
													thisLeft += diff;
													//alert(thisLeft);
												}
											}
										}
									}
									//alert(ulis.item(0).offsetTop + " : " + ulis.item(0).top);
								}

                //ulis.item(0).style.top = lis.item(i).offsetTop + "px";
                //alert(ulis.item(0).offsetTop + " : " + lis.item(i).offsetTop);
            }
        }

        if (axisMain == "h" && !doneOnce)
        {
					var thisLeft = 0;  var subLeft = 0; var subHeight = 0;
					for ( var i=0; i<lis.length; i++ )
					{
						if (lis.item(i).parentNode.parentNode.tagName == "LI")
						{
							if (!browser.isIE && axisSub == "h")
							{
								//alert(lis.item(i).offsetWidth + " : " + theWidth);
								diff = lis.item(i).childNodes[0].offsetWidth - lis.item(i).offsetWidth;
								//lis.item(i).style.width = theWidth + "px";
								lis.item(i).style.left  = subLeft + "px";
								subLeft += diff;
							}
						}

						if (lis.item(i).parentNode.parentNode.tagName == "DIV")
						{
							subLeft = 0;
							if (!browser.isIE)
							{
								diff = lis.item(i).childNodes[0].offsetWidth - lis.item(i).offsetWidth;
								if (diff == 0) diff = lis.item(i).childNodes[0].offsetWidth; // BEV - Firefox 1.5

								//lis.item(i).style.width = theWidth + "px";
								lis.item(i).style.left  = thisLeft + "px";
								thisLeft += diff;
							}
							if (axisMain == "v")
							{
							   lis.item(i).childNodes[0].style.top = subHeight + "px";
								subHeight += lis.item(i).childNodes[0].offsetHeight;
							}
						}
					}
				}

        if (axisMain == "v" && !doneOnce)
        {
            var subHeight = 0;
           for ( var i=0; i < lis.length; i++ )
           {
              if (lis.item(i).parentNode.parentNode.tagName == "DIV")
              {
                 lis.item(i).style.top = subHeight + "px";
                 subHeight += lis.item(i).childNodes[0].offsetHeight;
               }
            }
         }

        if (justify == "l")
        {
          menu.style.left = "0px";
        }

        if (justify == "c")
        {
        	var oldLeft = menu.offsetLeft;
        	//var newLeft =
        	menu.style.left = (menu.parentNode.offsetWidth - mainWidth)/2 + "px";
        	//alert(menu.offsetLeft);
        }

        if (justify == "r")
        {
        	var oldLeft = menu.offsetLeft;

        	menu.style.left = (menu.parentNode.offsetWidth - mainWidth) + "px";
         if (!doneOnce && !browser.isIE && axisMain == "h") menu.style.left = (menu.parentNode.offsetWidth - mainWidth - 13) + "px";

        	// i am searching for ul element in li element
        	for ( var i=0; (i<lis.length && !doneOnce); i++ )
        	{
            	// is there a ul element ?
            	ulis = lis.item(i).getElementsByTagName('ul');
            	if ( ulis.length > 0 )
            	{
            		if (axisMain == "v") ulis.item(0).style.left = (ulis.item(0).offsetLeft - theWidth - ulis.item(0).offsetWidth) + "px";

								if (document.layers)
								{
									//UNKNOWN - OPERA???
								}
								else if (document.all)
								{
									//INTERNET EXPLORER
								}
								else if (document.getElementById)
								{
									//MOZILLA
									if (axisMain == "v")
									{
										if (axisSub == "v")
										{
											var theDiff = (ulis.item(0).childNodes[1].childNodes[0].offsetWidth - ulis.item(0).offsetWidth);
											ulis.item(0).style.left = (ulis.item(0).offsetLeft - theDiff) + "px"; // - (oldLeft*2) - ulis.item(0).offsetWidth  : 2 * (padL + padR)
											//ulis.item(0).parentNode.parentNode.parentNode.style.padding = "10px";
											//alert(ulis.item(0).offsetLeft);
										}
										else
										{
											var thisLeft = 0;
											for (j = 0; j < ulis.item(0).childNodes.length; j++)
											{
												if (ulis.item(0).childNodes[j].tagName != undefined)
												{
													diff = ulis.item(0).childNodes[j].childNodes[0].offsetWidth - ulis.item(0).childNodes[j].offsetWidth;
													//lis.item(i).style.width = theWidth + "px";
													ulis.item(0).childNodes[j].style.left  = thisLeft + "px";
													thisLeft += diff;
													//alert(thisLeft);
												}
											}
										}
									}
								}
            	}
           }

           if (axisMain == "v") menu.style.left = "0px";
        }
    }
    doneOnce = true;
}

function initContent()
{
   theHead   = document.getElementById('header');     //Creates a pointer to header div.
   thePage   = document.getElementById('page');       //Creates a pointer to page div.
   theCont   = document.getElementById('contentcap'); //Creates a pointer to contentcap div.
   theMenuBG = document.getElementById('menubg');     //Creates a pointer to menubg div.
   theFoot   = document.getElementById('footer');     //Creates a pointer to footer div.

   //if the first level of the menu is vertical the menubg needs some tweaking
   if (mainAxis == "v")
   {
      if (browser.isIE)
      {
         //If using IE the menubg div must be the same height as the contentcap div
         theMenuBG.style.height = (theCont.parentNode.offsetHeight - theHead.offsetHeight) + "px";
      }
      else
      {
         //If using FF the menubg div needs a little tweaking depending on whether the contentcap is fixed width or not.
         if (theCont.offsetWidth == 647) //Fixed Width = 647 = 775 - 128
         {
            //theMenuBG.style.height = (theCont.offsetHeight - 1) + "px";
            theMenuBG.style.height = (theCont.parentNode.offsetHeight - theHead.offsetHeight) + "px";
         }
         else
         {
            //theMenuBG.style.height = (theCont.offsetHeight + 3 - 0) + "px";
            theMenuBG.style.height = (theCont.parentNode.offsetHeight - theHead.offsetHeight) + "px";
         }
      }

      //if the first level of the menu is right justified, the menubg div needs positioning to the right.
      if (mainJustify == "r")
      {
         theMenuBG.style.left = (thePage.offsetLeft + theCont.offsetWidth - 0) + "px";
         //alert(thePage.offsetWidth);
         //if (browser.isIE) theMenuBG.style.left = (screenWidth + 3 - theMenuBG.offsetWidth) + "px";
         //else theMenuBG.style.left = (screenWidth - 1 - theMenuBG.offsetWidth) + "px";
      }
      else theMenuBG.style.left = thePage.offsetLeft + "px";
   }

   doneContentOnce = true;
/*
	//alert(document.body.clientWidth);
	if (screenWidth < minScreenWidth) screenWidth = minScreenWidth;

	menu  = document.getElementById('menuv');
	thebg = document.getElementById('menubg');
	thecontent = document.getElementById('contentcap');
	theheader = document.getElementById('header');
	thefooter = document.getElementById('Footer');

	if (!menu && !theheader)
	{
		thecontent.style.top = (thecontent.offsetTop - 200) + "px";
		return;
	}
	if (!menu)
	{
		thecontent.style.top = (thecontent.offsetTop - 100) + "px";
		return;
	}

	thebg.style.top = (theheader.offsetTop + theheader.offsetHeight - 5) + "px";

   var divStuff = thecontent.getElementsByTagName('div');
   var theNewWidth  = 0;
   var theNewHeight = 0;

   for (var k = 0; k < divStuff.length; k++)
   {
      if (divStuff.item(k).id == "")
      {
         //alert(k + " : " + divStuff.item(k).id + " : height = " + divStuff.item(k).offsetHeight + " : width = " + divStuff.item(k).offsetWidth);
         if (k != 1) theNewWidth += divStuff.item(k).offsetWidth;
         if (divStuff.item(k).offsetHeight > theNewHeight) theNewHeight = divStuff.item(k).offsetHeight;
      }
   }

   //alert(theNewHeight + " : " + theNewWidth);

   thecontent.style.height = theNewHeight + "px";
   thecontent.style.width  = theNewWidth  + "px";

	if (mainAxis == "v" && mainJustify == "l")
	{
		//thebg.style.height = "100%";
		//menubg.style.height = Screen.availHeight + "px";
		thebg.style.top        = theheader.offsetHeight + "px";
		thebg.style.left       = theheader.offsetLeft + "px";
		thebg.style.width      = (menu.offsetLeft + menuWidth - 0) + "px";
		//alert(thecontent.offsetHeight);
		//thebg.style.background = document.bgColor;

		thecontent.style.top   = thebg.offsetTop + "px";
		thecontent.style.left  = (thebg.offsetLeft + thebg.offsetWidth - 0) + "px";
		thecontent.style.width = (screenWidth - thebg.offsetWidth + 12) + "px";
		if (browser.isIE) thecontent.style.width = (screenWidth - thebg.offsetWidth + 3) + "px";
		//alert("asd" + thebg.offsetLeft);

		if (browser.isIE) testHeight = document.documentElement.clientHeight;
		else testHeight = window.innerHeight;

		thebg.style.height = thecontent.offsetHeight + "px";

		if ((thecontent.offsetTop + thecontent.offsetHeight) > testHeight)
		{
//			thebg.style.height = thecontent.offsetHeight + "px";
//			thebg.style.height = "200px";
         if (doneContentOnce) thecontent.style.width = (screenWidth - thebg.offsetWidth + 12) + "px";
         else thecontent.style.width = (screenWidth - thebg.offsetWidth - 1) + "px";
		   if (browser.isIE) thecontent.style.width = (screenWidth - thebg.offsetWidth + 3) + "px";
		}
		else
		{
//			//thebg.style.height = "100%";
//			//if (browser.isIE) thebg.style.height = document.documentElement.clientHeight + "px";
//			//thebg.style.height = thebg.offsetHeight - thebg.offsetTop + "px";
//
//			thebg.style.height = "200px";
		}

	}
	else if (mainAxis == "v" && mainJustify == "r")
	{
		var widthTweak = 8; //for all browsers

		var leftTweak  = 9; //for firefox
		if (browser.isNS) leftTweak -= 4; //for netscape
		if (browser.isIE) leftTweak -= 4; //for internet explorer

      thebg.style.top   = theheader.offsetHeight + "px";
		thebg.style.left  = (menu.offsetLeft - leftTweak) + "px";
		menu.style.left   = "0px";
		thebg.style.width = (menu.offsetLeft + menuWidth + widthTweak - 0) + "px";

		//thebg.style.width      = (menu.offsetLeft + menuWidth - 0) + "px";
		//thebg.style.height     = thecontent.offsetHeight + "px";

		thecontent.style.top   = thebg.offsetTop + "px";
		thecontent.style.left  = "0px";
		thecontent.style.width = (screenWidth - thebg.offsetWidth - 3) + "px";
		//alert("asd" + thebg.offsetLeft);

		if (browser.isIE) testHeight = document.documentElement.clientHeight;
		else testHeight = window.innerHeight;

		thebg.style.height = thecontent.offsetHeight + "px";

		if ((thecontent.offsetTop + thecontent.offsetHeight) > testHeight)
		{
			//thebg.style.height = thecontent.offsetHeight + "px";

			if (doneContentOnce)
			{
			   thecontent.style.width = (screenWidth - thebg.offsetWidth + 12) + "px";
			   if (!browser.isIE) thebg.style.left = (thebg.offsetLeft + 13) + "px";
			}
         else
         {
            thecontent.style.width = (screenWidth - thebg.offsetWidth - 1) + "px";
         }
		   if (browser.isIE)
		   {
		      thecontent.style.width = (screenWidth - thebg.offsetWidth + 3) + "px";
		   }

			//alert("true");
		}
		else
		{
		   //alert("false");
		   if (!browser.isIE) thebg.style.left = (thebg.offsetLeft + 13) + "px";

		   thecontent.style.width = (screenWidth - thebg.offsetWidth + 12) + "px";
		   if (browser.isIE) thecontent.style.width = (screenWidth - thebg.offsetWidth + 3) + "px";

			//alert(thebg.style.left);
			//thebg.style.width = "130px";
			//if (!browser.isIE)thebg.style.left = (thebg.offsetLeft + 13 - 0) + "px";
			//thebg.style.height = "100%";
			//if (browser.isIE) thebg.style.height = document.documentElement.clientHeight + "px";
			//thebg.style.height = thebg.offsetHeight - thebg.offsetTop + "px";
		}
		//if ((menubg.offsetLeft + menubg.offsetWidth - 0) < minScreenWidth) menubg.style.left = minScreenWidth - menubg.offsetWidth + "px";
	}
	else if (mainAxis == "h")
	{
		thecontent.style.top    = (thebg.offsetTop  + thebg.offsetHeight - 0) + "px";
		fullWidth = 98.9;  //Highest width that doesn't cause horiz scroll on firefox.
		newWidth  = fullWidth * (contentWidth/100);
		thecontent.style.width  = "100%"; //newWidth + "%";
		thecontent.style.left   = (fullWidth - newWidth)/2 + "%";

		thecontent.style.height = theNewHeight + "px";
      //thecontent.style.width  = theNewWidth  + "px";

      //if (browser.isIE) thecontent.style.width  = theNewWidth  + "px";
      if (!doneContentOnce && theNewWidth <= 771) allFixed = true;
      if (allFixed)
      {
         thecontent.style.width  = "772px";
      }
	}

//	if (browser.isIE && !doneContentOnce)
//	{
//		tmpChr = thecontent.childNodes[0].childNodes[0].style.width.indexOf("%");
//		tmpVal = thecontent.childNodes[0].childNodes[0].style.width.substr(0,tmpChr);
//		thecontent.childNodes[0].childNodes[0].style.width = (tmpVal - 1) + "%";
//	}

   //thefooter.style.top = (thefooter.offsetTop + thefooter.offsetHeight - 0) + "px";

	doneContentOnce = true;

//   //alert(thecontent.offsetHeight);
//   //thecontent.style.height = "1000px";
//   var divStuff = thecontent.getElementsByTagName('div');
//   var theNewWidth  = 0;
//   var theNewHeight = 0;
//
//   for (var k = 0; k < divStuff.length; k++)
//   {
//      if (divStuff.item(k).id == "")
//      {
//         //alert(k + " : " + divStuff.item(k).id + " : height = " + divStuff.item(k).offsetHeight + " : width = " + divStuff.item(k).offsetWidth);
//         if (k != 1) theNewWidth += divStuff.item(k).offsetWidth;
//         if (divStuff.item(k).offsetHeight > theNewHeight) theNewHeight = divStuff.item(k).offsetHeight;
//      }
//   }
//
//   //alert(theNewHeight + " : " + theNewWidth);
//
//   thecontent.style.height = theNewHeight + "px";
//   thecontent.style.width  = theNewWidth  + "px";

   //var templateDiv = thecontent.getElementById('menubg');

   //alert(document.offsetHeight);
*/
}

/*
	if (browser.isIE)
	{
		for (i = 0; i < 3; i++)
		{
			var theLength = thecontent.childNodes[0].childNodes[i].childNodes.length;
			for (j = 0; j < theLength; j++)
			{
				oldWidth = thecontent.childNodes[0].childNodes[i].childNodes[j].childNodes[0].offsetWidth;
				thecontent.childNodes[0].childNodes[i].childNodes[j].childNodes[0].style.width = "100%";
				newWidth = thecontent.childNodes[0].childNodes[i].childNodes[j].childNodes[0].offsetWidth;

				if (oldWidth <= newWidth)
				{
					thecontent.childNodes[0].childNodes[i].childNodes[j].childNodes[0].style.width = oldWidth + "px";
				}
			}
		}
	}
*/

function addAnEvent( target, eventName, functionName )
{
    // apply the method to IE
    if ( browser.isIE )
    {
        //attachEvent dont work properly with this
        eval('target.on'+eventName+'=functionName');
    }
    // apply the method to DOM compliant browsers
    else
    {
        target.addEventListener( eventName , functionName , true ); // true is important for Opera7
    }
}

// hide the first ul element of the current element
function timeoutHide()
{
    // start the timeout
    eval( "timeout" + this.id + " = window.setTimeout('hideUlUnder( \"" + this.id + "\" )', " + timeout + " );");
}

// hide the ul elements under the element identified by id
function hideUlUnder( id )
{
    document.getElementById(id).getElementsByTagName('ul')[0].style['visibility'] = 'hidden';
}

// show the first ul element found under this element
function show()
{
	//alert(this.style.width);
    // show the sub menu
    this.getElementsByTagName('ul')[0].style['visibility'] = 'visible';
    // clear the timeout
    eval ( "clearTimeout( timeout"+ this.id +");" );
    hideAllOthersUls( this );
}

// hide all ul on the same level of  this list item
function hideAllOthersUls( currentLi )
{
    var ul = currentLi.parentNode.parentNode;
    //alert(ul.childNodes[3].childNodes[1].id);
    //alert(ul.childNodes.length);
    //alert(ul.childNodes.length);
    for ( var i=0; i<ul.childNodes.length; i++ )
    {
    		//alert(i + " : " + ul.childNodes[i].childNodes[0].id);
    		//alert(ul.childNodes[i].childNodes[1].id + " : " + currentLi.id);

    		if ( browser.isIE )
    		{
    			if ( ul.childNodes[i] && ul.childNodes[i].childNodes[0] && ul.childNodes[i].childNodes[0].id && ul.childNodes[i].childNodes[0].id != currentLi.id )
        	{
        		//IEXPLORER
            hideUlUnderLi( ul.childNodes[i].childNodes[0] );
        	}
        }
      	else
      	{
        	if ( ul.childNodes[i] && ul.childNodes[i].childNodes[1] && ul.childNodes[i].childNodes[1].id && ul.childNodes[i].childNodes[1].id != currentLi.id )
        	{
        		//MOZILLA
            hideUlUnderLi( ul.childNodes[i].childNodes[1] );
        	}
        }
    }
}

// hide all the ul which are in the li element
function hideUlUnderLi( li )
{
    var uls = li.getElementsByTagName('ul');
    for ( var i=0; i<uls.length; i++ )
    {
        uls.item(i).style['visibility'] = 'hidden';
    }
}


function getAbsX(elt)
{
	return parseInt(elt.x) ? elt.x : getAbsPos(elt,"Left");
};

function getAbsY(elt)
{
	return parseInt(elt.y) ? elt.y : getAbsPos(elt,"Top");
};

function getAbsPos(elt,which)
{
	iPos = 0;
	while (elt != null)
	{
		//alert("!!! " + elt["offset" + which]);
		iPos += elt["offset" + which];
		elt = elt.offsetParent;
	}
	return iPos;
};
