/* $Id: left.js,v 1.3 2001/11/30 00:28:45 loic1 Exp $ */

// 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

// Modified June 2002 by Jürgen Modre


// 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


var isExpanded   = false;



var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'

                  && typeof(document.createElement) != 'undefined')

               ? 1 : 0;

var isIE4      = (typeof(document.all) != 'undefined'

                  && parseInt(navigator.appVersion) >= 4

                  && typeof(window.opera) == 'undefined')

               ? 1 : 0;

var isNS4      = (typeof(document.layers) != 'undefined')

               ? 1 : 0;

var capable    = (isDOM || isIE4 || isNS4)

               ? 1 : 0;

// Uggly fix for Konqueror 2.2 that is half DOM compliant

if (capable && typeof(navigator.userAgent) != 'undefined') {

    var browserName = ' ' + navigator.userAgent.toLowerCase();

    if (browserName.indexOf('konqueror') > 0) {

        capable = 0;

    }

}



/**
 * Collapses all at startup
 *
 * @access  public
 */
function initIt(nav_document)
{
  if (!capable)
    return;

  if (isDOM) {
    var tempColl    = nav_document.getElementsByTagName('DIV');
    var tempCollCnt = tempColl.length;
    for (var i = 0; i < tempCollCnt; i++) {
      if (tempColl[i].id == expandedItems)
//alert("block");

        tempColl[i].style.display = 'block';
      else if (tempColl[i].className == 'child')
//alert("none");

        tempColl[i].style.display = 'none';
    }
  } // end of the DOM case
  else if (isIE4) {
    tempColl        = nav_document.all.tags('DIV');
    var tempCollCnt = tempColl.length;
    for (var i = 0; i < tempCollCnt; i++) {
      if (tempColl(i).id == expandedItems)
        tempColl(i).style.display = 'block';
      else if (tempColl(i).className == 'child')
        tempColl(i).style.display = 'none';
    }
  } // end of the IE4 case
  else if (isNS4) {
    var theLayers  = nav_document.layers;
    var layersCnt  = theLayers.length;
    for (var i = 0; i < layersCnt; i++) {
      if (theLayers[i].id == expandedItems)
        theLayers[i].visibility   = 'show';
      else if (theLayers[i].id.indexOf('Child') != -1)
        theLayers[i].visibility   = 'hide';
      else
        theLayers[i].visibility   = 'show';
    }
    nsArrangeList();
  } // end of the NS4 case
} // end of the 'initIt()' function


/**
 * Collapses/expands a item when the user require this to be done
 *
 * @param  el string = the  name of the div element to expand
 * @param  unexpand =  boolean whether to expand or to collapse the item content
 * @param  onlyThisItemOpened = boolean whether to only expand

 *                     this item or also leave the others opened
 *
 * @access  public
 */
function expandItem(nav_document, el, unexpand, onlyThisItemOpened)
{
  if (!capable)
    return;



  if (onlyThisItemOpened) {

    // close all DIV elements

    expandedItems = el + 'Child';

	initIt(nav_document);

  } else {

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

	}
} // end of the 'expandBase()' function