
var isExpanded   = false;

var imgOpened    = new Image(11,9);
imgOpened.src    = 'images/arrow_r.gif';
var imgClosed    = new Image(11,9);
imgClosed.src    = 'images/arrow_r.gif';

var imgOpenedSelected    = new Image(11,9);
imgOpenedSelected.src    = 'images/arrow_r_sel.gif';

var imgClosedSelected    = new Image(11,9);
imgClosedSelected.src    = 'images/arrow_r_sel.gif';

var SelectedLink='';
var SelectedChildLink='';
var SelectedChildLinkNo=0;

var ExpandedCatNo=0;


function reDo() {
  if (innerWidth != origWidth || innerHeight != origHeight)
    location.reload(true);
} // end of the 'reDo()' function


if (isNS4) {
  var origWidth  = innerWidth;
  var origHeight = innerHeight;
  onresize       = reDo;
}


function nsGetIndex(el) {
  var ind       = null;
  var theLayers = document.layers;
  var layersCnt = theLayers.length;
  for (var i = 0; i < layersCnt; i++) {
    if (theLayers[i].id == el) {
      ind = i;
      break;
    }
  }
  return ind;
} // end of the 'nsGetIndex()' function


function nsArrangeList() {
  if (firstInd != null) {
    var theLayers = document.layers;
    var layersCnt = theLayers.length;
    var nextY     = theLayers[firstInd].pageY + theLayers[firstInd].document.height;
    for (var i = firstInd + 1; i < layersCnt; i++) {
      if (theLayers[i].visibility != 'hide') {
        theLayers[i].pageY = nextY;
        nextY              += theLayers[i].document.height;
      }
    }
  }
} // end of the 'nsArrangeList()' function


function nsShowAll() {
  var theLayers = document.layers;
  var layersCnt = theLayers.length;
  for (i = firstInd; i < layersCnt; i++) {
    theLayers[i].visibility = 'show';
  }
} // end of the 'nsShowAll()' function


function initIt()
{
  if (!capable || !isServer)
    return;

  if (isDOM) {
    var tempColl    = document.getElementsByTagName('DIV');
    var tempCollCnt = tempColl.length;
    for (var i = 0; i < tempCollCnt; i++) {
      if (tempColl[i].id == expandedDb)
        tempColl[i].style.display = 'block';
      else if (tempColl[i].className == 'child')
        tempColl[i].style.display = 'none';
    }
  } // end of the DOM case
  else if (isIE4) {
    tempColl        = document.all.tags('DIV');
    var tempCollCnt = tempColl.length;
    for (var i = 0; i < tempCollCnt; i++) {
      if (tempColl(i).id == expandedDb)
        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  = document.layers;
    var layersCnt  = theLayers.length;
    for (var i = 0; i < layersCnt; i++) {
      if (theLayers[i].id == expandedDb)
        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
  // select first item
 // set_selected();
} // end of the 'initIt()' function



function unset_selection() {
  if (isDOM) {  // IE5 isDOM !
	// remove old parent selction
	if (SelectedLink) {
      	var selectedIm = document.getElementById(SelectedLink + 'Img');
      	if (selectedIm.src==imgOpenedSelected.src) {
			selectedIm.src=imgOpened.src;
		} else {
			selectedIm.src=imgClosed.src;
      	}
	}
      // remove old child selection
	if (SelectedChildLink) {
		var selectedChildIm = document.getElementById('imCh'+SelectedChildLinkNo);
		selectedChildIm.src = imgClosed.src;
      }
   } else if (isNS4) {
	// remove old main selection
	if (SelectedLink) {
      	var selectedIm = document.layers[SelectedLink + 'Parent'].document.images['imEx'];
      	if (selectedIm.src==imgOpenedSelected.src) {
			selectedIm.src=imgOpened.src;
		} else {
			selectedIm.src=imgClosed.src;
      	}
	}
      if (SelectedChildLink) {
	     	var selectedChildIm = document.layers[SelectedChildLink + 'Child'].document.images['imCh'+SelectedChildLinkNo];
     		selectedChildIm.src = imgClosed.src;
	}
  }
  
}



function set_selected_child(el,childno) {
  unset_selection();
  // new selection
  if (isDOM) {
  	var whichChildIm = document.getElementById('imCh'+childno);
  	whichChildIm.src = imgClosedSelected.src;
  } else if (isNS4) {
	var whichChildIm = document.layers[el + 'Child'].document.images['imCh'+childno];
      whichChildIm.src = imgClosedSelected.src;
  }
  SelectedLink='';
  SelectedChildLink=el;
  SelectedChildLinkNo=childno;
}


function set_selected(el) {
  unset_selection();

  if (isDOM) {  // IE5 isDOM !
   	var whichIm = document.getElementById(el + 'Img');
      whichIm.src            = imgClosedSelected.src;
   } else if (isNS4) {
  	var whichIm = document.layers[el + 'Parent'].document.images['imEx'];
     	whichIm.src            = imgClosedSelected.src;
  }
  SelectedLink=el;
}


function expandBase(el, unexpand, linked)
{
  if (!capable)
    return;
 
  if (ExpandedCatNo!=0 && ExpandedCatNo!=el) { 
	expandBase(ExpandedCatNo, true, false);
  }
  
  if (linked) {
  	unset_selection();
  }

  if (isDOM) {  // IE5 isDOM !
    var whichEl = document.getElementById(el + 'Child');
    var whichIm = document.getElementById(el + 'Img');
    if (whichEl.style.display == 'none' && whichIm) {
      whichEl.style.display  = 'block';
      if (linked || el==SelectedLink) {
	      whichIm.src = imgOpenedSelected.src;
      } else {
		whichIm.src = imgOpened.src;
	}
	ExpandedCatNo=el;
    } else { 
	if (unexpand) {
	      whichEl.style.display  = 'none';
		ExpandedCatNo=0;
      }
      if (linked || el==SelectedLink) {
	      whichIm.src = imgClosedSelected.src;
      } else {
		whichIm.src = imgClosed.src;
	}
    }

  } // end of the DOM case

  // reduced functionality for IE4
  else if (isIE4) {     
    var whichEl = document.all(el + 'Child');
    var whichIm = document.images.item(el + 'Img');
    if (whichEl.style.display == 'none') {
      whichEl.style.display  = 'block';
      whichIm.src            = imgOpened.src;
	ExpandedCatNo=el;
    } else { 
	if (unexpand) {
        whichEl.style.display  = 'none';
	  ExpandedCatNo=0;
	}
      whichIm.src            = imgClosed.src;
    }
  } // end of the IE4 case

  else if (isNS4) {
    var whichEl = document.layers[el + 'Child'];
    var whichIm = document.layers[el + 'Parent'].document.images['imEx'];
    if (whichEl.visibility == 'hide') {
      if (linked || el==SelectedLink) {
	      whichIm.src = imgOpenedSelected.src;
      } else {
		whichIm.src = imgOpened.src;
	}
      whichEl.visibility  = 'show';
	ExpandedCatNo=el;
     } else { 
	if (unexpand) {
		whichEl.visibility  = 'hide';
		ExpandedCatNo=0;
	}
      if (linked || el==SelectedLink) {
	      whichIm.src            = imgClosedSelected.src;
      } else {
		whichIm.src            = imgClosed.src;
	}
    }
    nsArrangeList();
  } // end of the NS4 case

  // store new selection
  if (linked) {
	SelectedLink=el;
  }
} // end of the 'expandBase()' function



/**
 * Add styles for positioned layers
 */
//fontTag = 'font-family: arial, verdana, helvetica, geneva, sans-serif; font-size: 12px; color: #FFFFFF; text-decoration:none;';
//fontTagHover = 'font-family: arial, verdana, helvetica, geneva, sans-serif; font-size: 12px; color: #FF0000; text-decoration:none;';
//fontTagCurrent = 'font-family: arial, verdana, helvetica, geneva, sans-serif; font-size: 12px; color: #00ff00; text-decoration:none;';
if (capable) {
  with (document) {
    // Brian Birtles : This is not the ideal method of doing this
    // but under the 7th June '00 Mozilla build (and many before
    // it) Mozilla did not treat text between <style> tags as
    // style information unless it was written with the one call
    // to write().
    if (isDOM || isIE4) {
      var lstyle = '<style type="text\/css">'
                 + '<!--'
                 + 'div {color: #666666;}'
               //  + '.heada {' + fontTagHover + '}'
               //  + '.heada_cnt {' + fontTagHover + '}'
                 + '.parent {' + fontTag + ' display: block}'
                 + '.child {' + fontTag + 'display: none;}'
                 + '.item, .tblItem {'+ fontTag +'}'
		     	 + '.item:hover,  .tblItem:hover  {' + fontTagHover + '}'
                 + '.item:active, .tblItem:active {' + fontTagCurrent + '}'
                 + '\/\/-->'
                 + '<\/style>';
      write(lstyle);
    }
    else {
      var lstyle = '<style type="text\/css">'
                 + '<!--'
                 + 'div {color: #666666;}'
               //  + '.heada {' + fontTagCurrent + '}'
               //  + '.heada_cnt {' + fontTagCurrent + '}'
                 + '.parent {' + fontTag + ' position: absolute; visibility: hidden}'
                 + '.child {' + fontTag + ' position: absolute; visibility: hidden}'
                 + '.item, .tblItem {'+ fontTag +'}'
		     	 + '.item:hover,  .tblItem:hover  {' + fontTagHover + '}'
                 + '.item:active, .tblItem:active {' + fontTagCurrent + '}'
                 + '\/\/-->'
                 + '<\/style>';
      write(lstyle);
    }
  }
} else { //if not capable
  with (document) {

      var lstyle = '<style type="text\/css">'
                 + '<!--'
                 + 'div {color: #666666;}'
               //  + '.heada {' + fontTagCurrent + '}'
               //  + '.heada_cnt {' + fontTagCurrent + '}'
                 + '.parent {' + fontTag + ' visibility: inherit}'
                 + '.child {' + fontTag + ' visibility: inherit}'
                 + '.item, .tblItem {'+ fontTag +'}'
		     	 + '.item:hover,  .tblItem:hover  {' + fontTagHover + '}'
                 + '.item:active, .tblItem:active {' + fontTagCurrent + '}'
                 + '\/\/-->'
                 + '<\/style>';
      write(lstyle);
/*
    writeln('<style type="text\/css">');
    writeln('<!--');
    writeln('div {color: #FFFFFF; }');
    writeln('.heada {font-family: ' + fontFamily + '; font-size: 12px}');
    writeln('.heada_cnt {font-family: ' + fontFamily + '; font-size: 12px}');
    writeln('.parent {font-family: ' + fontFamily + '; color: #FFFFFF; text-decoration: none}');
    writeln('.child {' + fontTag + '}');
    writeln('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333300; text-decoration: none}');
    writeln('.tblItem:hover {color: #333300; text-decoration: underline}');
    writeln('\/\/-->');
    writeln('<\/style>');
*/
  }
} // end of adding styles


onload = initIt;