//javascript for showing divs on mouse overs
// Written by tim baillie for MS Engineering 29/09/03

document.WM = new Object();
document.WM.hirelist = new Object();
document.WM.hirelist.expandos = new Array();
document.WM.hirelist.heights = new Array();
document.WM.hirelist.names = new Array();

function WM_toggle(id) 
{
  //hide currently shown menu3
  WM_hideOthers(id);  

  if (document.all)
  {
    if(document.all[id].style.display == 'none')
    {
      document.all[id].style.display = '';
    } 
    else 
    {
      document.all[id].style.display = 'none';
    }
  } 
  else if (document.getElementById)
  {
    if(document.getElementById(id).style.display == 'none')
    {
      document.getElementById(id).style.display = 'block';
    } 
    else 
    {
      document.getElementById(id).style.display = 'none';
    }
  } 
  else if(document.layers) 
  {
      if(parseInt(id + 1))
      {
	  ditem = id + 1;
      } 
      else 
      {
	  ditem = document.WM.hirelist.names[id];
      }
      
      if(document.WM.hirelist.expandos[ditem].clip.bottom == 0) 
      {
	     document.WM.hirelist.expandos[ditem].clip.bottom = document.WM.hirelist.heights[ditem];
      } 
      else 
      {
	  document.WM.hirelist.expandos[ditem].clip.bottom = 0;
      }
      WM_align();
  }
}

//(TB) Show menu3 when tab is clicked
function WM_SHOW(id) 
{
  //hide currently shown menu3
  WM_hideOthers(id);  

  if (document.all)
  {
    if(document.all[id].style.display == 'none')
    {
      document.all[id].style.display = '';
    } 
  } 
  else if (document.getElementById)
  {
    if(document.getElementById(id).style.display == 'none')
    {
      document.getElementById(id).style.display = 'block';
    } 
  } 
  else if(document.layers) 
  {
      if(parseInt(id + 1))
      {
	  ditem = id + 1;
      } 
      else 
      {
	  ditem = document.WM.hirelist.names[id];
      }
      
      if(document.WM.hirelist.expandos[ditem].clip.bottom == 0) 
      {
	     document.WM.hirelist.expandos[ditem].clip.bottom = document.WM.hirelist.heights[ditem];
      } 
      WM_align();
  }
}

function WM_align() {
    var i,j,stupid_netscape_array_infinate_loop_error;
    stupid_netscape_array_infinate_loop_error = document.WM.hirelist.expandos.length;
    for(i=0; i<stupid_netscape_array_infinate_loop_error; i++) {
		j = i + 1;
		if(document.WM.hirelist.expandos[j]){
	    	if(document.layers) {
				document.WM.hirelist.expandos[j].top = document.WM.hirelist.expandos[i].top + document.WM.hirelist.expandos[i].clip.bottom;
	   		}
		}
    }
}

function WM_initialize_toolbar(){
    if(document.layers) {
		for(i=0; i<document.layers['container'].document.layers.length; i++){
	    	document.WM.hirelist.expandos[i] = document.layers['menu3'].document.layers[i];
	    	document.WM.hirelist.names[document.layers['menu3'].document.layers[i].name] = i;
	    	document.WM.hirelist.heights[i] = document.WM.hirelist.expandos[i].clip.bottom;
		}
		for (p=0;p<document.WM.hirelist.expandos.length;p=p+2){
	    	WM_toggle(p);
		}
		document.layers['container'].visibility = 'visible';
    } else if (document.all){
		for(i = 0; i < document.all('menu3').all.length; i++){
		    document.all('menu3').all[i].style.position = 'relative';
		    if(document.all('menu3').all[i].className == 'respond'){
			document.all('menu3').all[i].style.display = 'none';
		    }
		}
		document.all('menu3').style.visibility = 'visible';
    } else if (document.getElementsByTagName && document.getElementById){
		var contained = document.getElementById('menu3').getElementsByTagName('div');
		for(i = 0; i < contained.length; i++){
		    contained[i].style.position = 'relative';
		    if(contained[i].getAttribute('class') == 'respond'){
			contained[i].style.display = 'none';
		    }
		}
		document.getElementById('menu3').style.visibility = 'visible';
    }
}

function WM_hideOthers(id)
{
  if(document.layers) {
		// do nothing for netscape
    } else if (document.all){
		for(i = 0; i < document.all('menu3').all.length; i++){
		    // if the id is not equal to id
		    if ((document.all('menu3').all[i].id != id) && (document.all('menu3').all[i].className == 'respond'))
		    {
		      document.all('menu3').all[i].style.display = 'none';
		    }
		}
		document.all('menu3').style.visibility = 'visible';
    } else if (document.getElementsByTagName && document.getElementById){
		var contained = document.getElementById('menu3').getElementsByTagName('div');
		for(i = 0; i < contained.length; i++){
		    if((contained[i].getAttribute('id') != id) && (contained[i].getAttribute('class') == 'respond'))
		    {
			contained[i].style.display = 'none';
		    }
		}
		document.getElementById('menu3').style.visibility = 'visible';
    }
}
