/*functions to hide and display submenus 
this script expects the submenus to have the ids given in
the array subarray. They are called by calling displaysub() with the
id as argument*/

var subarray=new Array("sub1", "sub2", "sub3", "sub4");
var displayed=new Array();

for (var counter=0; counter<subarray.length; counter++)
   {displayed[subarray[counter]]=0;}

function hidesub(subname)
{
  try{
	var newsub=document.getElementById(subname);
	newsub.style.visibility="hidden";
	displayed[subname]=0;
     } catch(e) {}
}

function hideallsubs()
{
  for (var i=0; i<subarray.length; i++)
      {hidesub(subarray[i]);}
  document.onclick=null;
}


function displaysub(subname)
{
  try{
	  if (displayed[subname]==1){hidesub(subname); return}
	  hideallsubs();
	  var newsub=document.getElementById(subname);
	  newsub.style.visibility="visible";
	  displayed[subname]=1;
  } catch(e) {}
}
