	// (Parts of this script is generated in .xslt file)

	//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    //  GLOBAL VARIABLES
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     
    // Static
    //=-=-=-=-=-=-=-=-=-=-=-=-=-
    var _firstCell = 0;    
    var _visible = false;
    var _doPostBack = false;
		
	var _action = "";
    
    //Indication of wich cell is currently marked as active
    var _activeCell = 0;
    
    //	CONFIGURATION    
    //=-=-=-=-=-=-=-=-=-=-=-=-=-
    var _menuClosedPos = -21;//Xposition where the menu is "parked"
    var _menuOpenedPos = 0; //Xposition where the menu is opened
    var _menuOpenDelay = 250; //Time before menu enters screen
    var _menuOpenSpeed = 7; //How fast the menu enters
    var _menuCloseDelay = 750; //Time before menu is closed
    var _menuCloseSpeed = 10; //How fast the menu leaves screen    
    
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    //  PRELOAD IMAGES
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    //Static data
    //=-=-=-=-=-=-=-=-=-=-=-=-=-    
    var _edges     = CreateImageArray(8); 
    var _bkg         = CreateImageArray(2);    
    
     //background
    _bkg[0].src     = "/static/jo/cs/menu/off_bkg.gif";
    _bkg[1].src     = "/static/jo/cs/menu/on_bkg.gif";
    
    //edges
    _edges[0].src   = "/static/jo/cs/menu/off_right.gif";
    _edges[1].src   = "/static/jo/cs/menu/on_right.gif";
    _edges[2].src   = "/static/jo/cs/menu/off_left.gif";
    _edges[3].src   = "/static/jo/cs/menu/on_left.gif";
    _edges[4].src   = "/static/jo/cs/menu/off_inner_right.gif";
    _edges[5].src   = "/static/jo/cs/menu/on_inner_right.gif";
    _edges[6].src   = "/static/jo/cs/menu/off_inner_left.gif";
    _edges[7].src   = "/static/jo/cs/menu/on_inner_left.gif";    
        
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // CORE  FUNCTIONS
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    //Swaps an image in document.
    function Swap(name, image) {
      document.images[name].src = image.src;
    } 
    
    //Swaps a background image
    function SetBackground(name, active) {
      if(active == 'on')
        document.getElementById(name).className = "on";        
      
      if(active == 'off')
        document.getElementById(name).className = "off";
    }    
    
    //Resets a cell to inactive state.
    function DeactivateCell(position) {    
      //Reset background      
      SetBackground("c"+position, 'off');
      
      //Swap edges
      if(position == _firstCell) {
        Swap("e"+position, _edges[0]);
        Swap("e"+(position+1),_edges[6]);
      } 
      else if(position == _lastCell) {
        Swap("e"+position, _edges[4]);        
        Swap("e"+(position+1), _edges[2]);
      }
      else {
        Swap("e"+position, _edges[4]);
        Swap("e"+(position+1), _edges[6]);      
      }    
    }
    
    //Activates a "cell".
    function ActivateCell(position) {
      //Reset old cell
      DeactivateCell(_activeCell);
      
       //Update currently active cell
      _activeCell = position;
      
      //Activate background
      SetBackground("c"+position, 'on');
      
      //Swap edges
      if(position == _firstCell) {
        Swap("e"+position, _edges[1]);
        Swap("e"+(position+1),_edges[7]);
      } 
      else if(position == _lastCell) {
        Swap("e"+position, _edges[5]);        
        Swap("e"+(position+1), _edges[3]);
      }
      else {
        Swap("e"+position, _edges[5]);
        Swap("e"+(position+1), _edges[7]);
      }
    }
    
    //Creates an image array
    function CreateImageArray(size) {   	
	  if(size == 0) return;
	  	   
   	  var newArray = new Array(size);
   	  
   	  for(i=0; i<size; i++) 
   	    newArray[i] = new Image();
   	    
   	  return newArray;  	   	
   	}
   	
   	//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    //  "ACTIONS"
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    //Hover button actions
    function DoHover(destination, position){
      Swap("i" + destination, _buttons[position]);
    }    
    
    //Performed when a menuitem is clicked
    function DoClick(position, script) {    
		//Clicks are disabled during animations
		if(_action == "") {
		    //Activate new
			ActivateCell(position);
			
			var scriptIdentifier = "javascript:";
			var pos = script.indexOf(scriptIdentifier);
			
			if(pos == -1) {
				//Normal link
				parent.frames["contentFrame"].location.href = script;
			}
			else {
				//Javascript, remove scriptIdentifier and execute code	
				eval(script.substring(pos+scriptIdentifier.length));
			}
		}
    }      

	//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
	//	SHOW MENU
	//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    //Initiates menu show sequence.
    function InitiateShow() {
		if(_action != "show") {		
			var oldAction = _action;
			_action = "show";
		
			if(oldAction == "hide")
				Show();
			else
				setTimeout("Show()", _menuOpenDelay);
		}
    }
    
    //Animates the menu entering screen
    function Show() {
		if(_action == "show") {		
		  if(parseInt(document.getElementById("menu").style.top) < _menuOpenedPos) {
			document.getElementById("menu").style.top = ((parseInt(document.getElementById("menu").style.top)) + 1) +  "px";   
			setTimeout("Show()", _menuOpenSpeed);
		  }
		  else { 
			  _visible = true;
			  OnOpened();
		  }
		}
    } 
    
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    //	HIDE MENU
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    //Initiates menu hide sequence.
    function InitiateHide() {
		if(_action != "hide") {
			var oldAction = _action;
			_action = "hide";
			
			if(oldAction == "show")
				Hide();
			else
				setTimeout("Hide()", _menuCloseDelay);
		}
    }
    
    //Animates the menu leaving screen
    function Hide() {
		if(_action == "hide")
		{
		   if(parseInt(document.getElementById("menu").style.top) > _menuClosedPos) {
			document.getElementById("menu").style.top = ((parseInt(document.getElementById("menu").style.top)) - 1) +  "px";   
			setTimeout("Hide()", _menuCloseSpeed);
		  }
		  else { 
			  _visible = false;
			  OnClosed();
		  }
		}
    }
    
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    //	EVENTS
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    //"Event" Menu has been closed.
    function OnClosed() {
		_action = "";
		//Should we load another menu??
		if(_doPostBack == true) {		
			document.location.href = _pageName + "?identifier=" + _menuIdentifier;
		}    
    }
    
    //"Event" Menu has been opened.
    function OnOpened() {		
		_action = "";
    }
    
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // CALL THESE FUNCTIONS TO CONTROL MENU
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    //Opens a menu with the specified identifier
    function Open(identifier) {    
		if(identifier == _menuIdentifier && _doPostBack != true) {
			_doPostBack = false;
			if(_initiallySelected != -1 && _visible == false && _activeCell == 0) //2005-04-27 added _activeCell == 0... activate cell only if menu is initialized...
				ActivateCell(_initiallySelected);
			InitiateShow();
		}
		else {						
			_doPostBack = true;
			_menuIdentifier = identifier;
			InitiateHide();
		}
    }
    
    //Closes/Hides any visible menu
    function Close() {
		_doPostBack = false;
		InitiateHide();
    }
    
     //Initializes the menu, should be called by page load.
    function Init() {
		//Any menu to show?
        if(_menuIdentifier != "") {			 
			if(_initiallySelected != -1)
				ActivateCell(_initiallySelected);
			InitiateShow();
	    }
    } 
    
    //Gets the identifier for the navigation item currently active.
    function Active() {
		if(_identifiers)
			return _identifiers[_activeCell];
		return "";
    } 
      