function initialiseMenuActions() {
  $('#menu ul').hide();
  //$('#menu ul:first').show();    //this line can optionally be uncommented to show the first available submenu on load
  thumbImageHidden = "images/arrow2.jpg";    //path to the thumb image when submenu is HIDDEN
  thumbImageShown = "images/arrow2r.jpg";    //path to the thumb image when submenu is SHOWN
  hideSpeed=1000;   //duration of the HIDE effect for submenus in miliseconds
  showSpeed=500;   //duration of the SHOW effect for submenus in miliseconds
  $('#menu li a.hov').hover(
    function() {
      $(this).blur();
      var testElement = $(this).next();
      var arrow = $(this).find('img');
      if((testElement.is('ul')) && (!testElement.is(':visible'))) {
        var arrow2 = $('#menu ul:visible');
        arrow2 = arrow2.prev();
        arrow2 = arrow2.find('img');       
        $('#menu ul:visible').hide(hideSpeed);
        testElement.show(showSpeed);       
        arrow.attr("src",thumbImageShown);
        arrow2.attr("src",thumbImageHidden);
        return false;
        }
      } 
    );
  $('#menu li a').click(
    function() {
      $(this).blur();
      var testElement = $(this).next();
      var arrow = $(this).find('img');
      if((testElement.is('ul')) && (!testElement.is(':visible'))) {
        var arrow2 = $('#menu ul:visible');
        arrow2 = arrow2.prev();
        arrow2 = arrow2.find('img');       
        $('#menu ul:visible').hide(hideSpeed);
        testElement.show(showSpeed);       
        arrow.attr("src",thumbImageShown);
        arrow2.attr("src",thumbImageHidden);
        return false;
        } 
      else if((testElement.is('ul')) && (testElement.is(':visible'))) {
        testElement.hide(hideSpeed);        
        arrow.attr("src",thumbImageHidden);       
        return false;
        }
      } 
    );
  }
$(document).ready(function() {initialiseMenuActions();});
