//setup the menus
//Event.observe(window, 'load', loadMenus, false);
function loadMenus()
{
  arrMenus = $$('div.menu_item_sub');
  for(i = 0; i < arrMenus.length; i++) 
    {
      Effect.SlideUp(arrMenus[i].id, {duration: .2  } );
    }
}
            
//the last menu item we moved around (currently open)
var menu_open;
//lock the effects whilst in progress
var locked = false;
            
//roll down the appropriate menu
function rollDown( numb )
{
  //debug - remove me
  //$('debug').update( 'numb='+numb+'|menu_open='+menu_open+'|locked='+locked);
                
  //not locked and not moving the same menu as already open
  if( !locked && (menu_open != numb ) )
    {
      //do we have a menu open we need to shut?
      if( menu_open )
	{
	  //change the text class (color)
	  $('menu_item_text_'+menu_open).className = 'menu_item_text';
	  //shut the menu
	  Effect.SlideUp('menu_item_sub_'+menu_open, {duration: .3  } );    
	  //is there a shadow bar than needs showing?
	  var shadow_numb = menu_open + 1;
	  if( $('menu_item_split_'+shadow_numb) )
	    {
	      $('menu_item_split_'+shadow_numb).className = 'menu_item_split';
	    }
	}
                    
      //
      //commence opening the menus
      //
      //change the text class (color)
      $('menu_item_text_'+numb).className = 'menu_item_text_active';
      //slide down menu, lock the effects before starting, and uplock after
      Effect.SlideDown('menu_item_sub_'+numb, {duration: .3, beforeStart: function(){ locked = true; }, afterFinish: function(){ locked = false; } } );    
      //is there a shadow bar we need to hide?
      var shadow_numb = numb + 1;
      if( $('menu_item_split_'+shadow_numb) )
	{
	  $('menu_item_split_'+shadow_numb).className = 'menu_item_split_no_background';
	}
                    
      //set the menu_open
      menu_open = numb;
    }
}
            
function activateSubMenu( elem )
{
  //get any currently active links and switch them off 
  arrLinks = $$('a.menu_item_sub_link_active');
  for(i = 0; i < arrLinks.length; i++) 
    {
      arrLinks[i].className = 'menu_item_sub_link';
    }
  //highlight the current link
  elem.className = 'menu_item_sub_link_active';
                
  //              //update content with AJAX from here.
  //                var url = 'http://url.to.content/content.html'; 
  //                new Ajax.Request(url, {
  //                                      method: 'get',
  //                                      onSuccess: function(request) {
  //                                        $('content_div_id').update( request.responseText );
  //                                      }
  //                                    });

}
  
