/* $Id$ */


// These scripts were originally found on cooltype.com.
// Modified 01/01/1999 by Tobias Ratschiller for linuxapps.com

// Modified 7th June 2000 by Brian Birtles for Mozilla 5.0
// compatibility for phpMyAdmin

// Rewritten and put in a libray 2nd May 2001 by Loïc Chapeaux

// Test passed with:
// - Mozilla 0.8.1-0.9.6 for Windows (js enabled & disabled)
// - IE5, 5.01, 5.5, 6.0 for Windows
// - Netscape 4.75 for Windows

// Test failed (crappy DOM implementations) with:
// - Opera 5.02 for windows: 'getElementsByTagName' is unsupported
// - Opera 5.10 to 5.12 for windows, Opera 5+ for Linux: 'style.display' can't
//   be changed
// - Konqueror 2+: 'style.display' can't be changed


/**
 * Collapses/expands a menu when the user require this to be done
 *
 * @param  string  the name of the database to act on
 * @param  boolean whether to expand or to collapse the database content
 *
 * @access  public
 */
function expandBase(el, unexpand, texte)
{
  if (!capable)
  {
    return;
  }

  if (!unexpand)
 	unexpandAll ();

//  if (texte) alert (texte);
//  if (!unexpand) alert (el + " " + unexpand);

  if (isDOM) 
   {
    var whichEl = document.getElementById('Child' + el);
  	if (unexpand) 
	      whichEl.style.display  = 'none';
	else
	      whichEl.style.display  = 'block';
  } // end of the DOM case
  else if (isIE4) {
    var whichEl = document.all('Child' + el);
    if (whichEl.style.display == 'none' || whichEl.style.display == '') {
      whichEl.style.display  = 'block';
    }
    else if (unexpand) {
      whichEl.style.display  = 'none';
    }
  } // end of the IE4 case
  else if (isNS4) {
    var whichEl = document.layers['Child' + el];
    if (whichEl.visibility == 'hide') {
      whichEl.visibility  = 'show';
    }
    else if (unexpand) {
      whichEl.visibility  = 'hide';
      //whichIm.src         = imgClosed.src;
    }
    nsArrangeList();
  } // end of the NS4 case
} // end of the 'expandBase()' function

function unexpandAll ()
{
    var tempColl = document.getElementsByTagName('DIV');
    var tempCollCnt = tempColl.length;
    for (var i = 0; i < tempCollCnt; i++) {
	 if (tempColl[i].className == 'child')
        	tempColl[i].style.display = 'none';
	}
}

document.onclick = unexpandAll;
