// Expanding Menu Toolbar DHTML Lifted from WebMonkey 
//	http://hotwired.lycos.com/webmonkey/01/12/index1a.html?tw=authoring

   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();
   
   var image_closed = 'http://www.hreporters.com/Icons/nav_plus.gif';
   var image_open = 'http://www.hreporters.com/Icons/nav_minus.gif';

   function WM_toggle(id) {
     var image_src;
     if (document.all){
       if(document.all[id].style.display == 'none'){
         document.all[id].style.display = '';
	 image_src=image_open;
       } else {
         document.all[id].style.display = 'none';
	 image_src=image_closed;
       }
     } else if (document.getElementById){
       if(document.getElementById(id).style.display == 'none'){
         document.getElementById(id).style.display = 'block';
	 image_src=image_open;
       } else {
         document.getElementById(id).style.display = 'none';
	 image_src=image_closed;
       }
     } 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];
	     image_src=image_open;
         } else {
   	     document.WM.hirelist.expandos[ditem].clip.bottom = 0;
	     image_src=image_closed;
         }
         WM_align();
     }

     //RRB - toggle the associated image
     var image = id.replace(/block/,'image');
     var image_container = id.replace(/block/,'header');
     WM_imageAssign(image, image_src, image_container);
//     WM_imageToggle(image, 
//		'http://www.ece.duke.edu/Icons/nav_plus.gif',
//		'http://www.ece.duke.edu/Icons/nav_minus.gif',
//		image_container);
   }

   

   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(){
       // RRB preload the nav images
       // if (document.images) {
       //     preload_open = newImage(image_open);
       //     preload_closed = newImage(image_closed);
       // }

       if(document.layers) {
   		for(i=0; i<document.layers['wm_container'].document.layers.length; i++){
   	    	document.WM.hirelist.expandos[i] = document.layers['wm_container'].document.layers[i];
   	    	document.WM.hirelist.names[document.layers['wm_container'].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['wm_container'].visibility = 'visible';
       } else if (document.all){
   		for(i = 0; i < document.all('wm_container').all.length; i++){
   		    document.all('wm_container').all[i].style.position = 'relative';
   		    if(document.all('wm_container').all[i].className == 'xmenu_closed'){
   			document.all('wm_container').all[i].style.display = 'none';
   		    }
   		}
   		document.all('wm_container').style.visibility = 'visible';	
       } else if (document.getElementsByTagName && document.getElementById){
   		var contained = document.getElementById('wm_container').getElementsByTagName('div');
   		for(i = 0; i < contained.length; i++){
   		    contained[i].style.position = 'relative';
   		    if(contained[i].getAttribute('class') == 'xmenu_closed'){
   			contained[i].style.display = 'none';
   		    }
   		}
   		document.getElementById('wm_container').style.visibility = 'visible';
       }
   }


function WM_imageToggle(daImage, src1, src2, netscape_container){
      var objStr,obj;
//      var src1="http://www.ece.duke.edu/Icons/nav_plus.gif";
//      var src2="http://www.ece.duke.edu/Icons/nav_minus.gif";

      // Check to make sure that images are supported in the DOM.
  	  myImage = document.images[daImage];

      if(document.layers){
          myImage = document.layers['container'].document.layers[netscape_container].document.images[daImage];
      }

      if(document.images){
        // Check to see whether you are using a name, number, or object
          if(myImage.src == src1){
   	  	myImage.src = src2;
          } else {
    	  	myImage.src = src1;
          }
      }
    }

function WM_imageAssign(daImage, src, netscape_container){
      var objStr,obj;

      // Check to make sure that images are supported in the DOM.
  	  myImage = document.images[daImage];

      if(document.layers){
          myImage = document.layers['container'].document.layers[netscape_container].document.images[daImage];
      }

      if(document.images){
    	  myImage.src = src;
      }
    }

