/*
#####################################################
# this file contains some current and old versions of scripts for expanding and 
# collapsing menus. They are used in, for example, the XML-driven project reports
#####################################################
*/

// these two are the old ones, which just set the display style of a specific element 
// to "none" or "", selecting it by ID

function _hideMenu(){
	if(showing != ""){
		Browser.StyleRef(showing).display="none"
	}
	showing = ""
}

function _showMenu(which){
	Browser.StyleRef(which).display=""
	showing = which
}


/*
#####################################################
# these functions do a similar job but instead of setting style directly for an element
# they assign the item with that ID to a class. This means that we can provide defaults
# for those styles like this:
#
#		.hideme
#		{
#			
#		}
#		.showme
#		{
#		
#		}
# and using those classes set the display of all the "hideme" items to "none" onLoad 
# (with the last function)
# Neither class has the display style set, but when the onload event fires, all those 
# in the "hideme" class become invisible. Subsequent changes are made my changing the 
# class back and forth
# The reason for all this is so that we can ensure that the menu displays in its entirety
# unless the user has javascript that is capable of showing the expanding menu properly
#####################################################
*/
		
var showing=""

function hideMenu(){
	if(showing != ""){
		Browser.ObjRef(showing).className="hideme"
	}
	showing = ""
}

function showMenu(which){
	Browser.ObjRef(which).className="showme"
	showing = which
}

function hideForJavascripters(){
	createClassNodeArr("div","showme")
	if(clssNodeArr.length>0){
		showing=clssNodeArr[0].id
	}
	document.styleSheets[0].rules[1].style.display="none"
}
		


//#####################################################
//other potentially useful stuff taken from the web follows:
//#####################################################

//parameters
//e = element
//style property value fw = FontWeight
function changeElementsStyleByClass(e,spv){
if(document.getElementsByTagName)//check for obj
   {
   var nodes = document.getElementsByTagName(e)
   var max = nodes.length
   for(var i = 0;i < max;i++)
      {
      var nodeObj = nodes.item(i);
      var attrMax = nodeObj.attributes.length
      for(var j = 0; j < attrMax; j++)
         {
          if(nodeObj.attributes.item(j).nodeName == 'class')
             {
             if(nodeObj.attributes.item(j).nodeValue == 'hideme')
             nodeObj.style.display = none;
             }
         }
      }
   }
}

//make an array of elements with a class
//global arr 
clssNodeArr = new Array();
// parameters
// e = element
// v = class value
function createClassNodeArr(e,v){
if(document.getElementsByTagName)//check for obj
   {
   var nodes = document.getElementsByTagName(e)
   var max = nodes.length
   for(var i = 0;i < max;i++)
      {
      var nodeObj = nodes.item(i);
      var attrMax = nodeObj.attributes.length
      for(var j = 0; j < attrMax; j++)
         {
          if(nodeObj.attributes.item(j).nodeName == 'class')
             {
             if(nodeObj.attributes.item(j).nodeValue == v)
              {
               clssNodeArr[clssNodeArr.length] = nodeObj
              }
             }
         }
      }
   }
}


//call the function on document load e.g. <body onload="createClassNodeArr('div','hideme')">

//change the style of all those elements with a class
function styleByClass(clr){
if(document.getElementsByTagName)//check for obj
   {
   var max = clssNodeArr.length
   for(var i = 0;i < max;i++)
      {
      var nodeObj = clssNodeArr[i];
      nodeObj.style.color = clr;
      }
   }
}

// From http://forums.devshed.com/archive/t-115036, and originally http://www.mozilla.org/docs/web-developer/css1technote/css1tojs.html#whycss1fromjs
/*
var agt=navigator.userAgent.toLowerCase();
if ( (parseInt(navigator.appVersion)==4) && 
(agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
&& (agt.indexOf('compatible') == -1) ) {
document.classes.hint.all.backgroundColor="yellow";
}
else if (agt.indexOf('gecko') != -1) { 
document.getElementById('tssxyz').sheet.insertRule('.hint { background-color: yellow }', document.getElementById('tssxyz').sheet.cssRules.length )
}
else if ( (parseInt(navigator.appVersion)>=4) && 
(agt.indexOf('msie') != -1) ) {
document.styleSheets["tssxyz"].addRule (".hint", "background-color:yellow");
}


*/