$().ready(function(){
  //hide the first menu item always for courses
  var course_home = $("div#side-menu a[href='/index.php']");
  $(course_home).next().remove(); // get rid of the break after it first
  $(course_home).remove(); // then remove it itself
  //if it's a strong tag for the first menu item
  /*
  var program_introduction = $("strong[title='Program Introduction'],strong[title='Introduction de programme']");
  $(program_introduction).hide(); 
  $(program_introduction).next().hide();
  $(program_introduction).prev().hide();
  $(program_introduction).prev().prev().hide();
  $(program_introduction).prev().prev().prev().hide();
   $(program_introduction).prev().prev().prev().prev().hide();
  //if it's an anchor tag, it's a little more complicated:
  program_introduction = $("a[title='Program Introduction'],a[1 title='Introduction de programme']");
  if($(program_introduction).parent() != null) {
  if($(program_introduction).parent().get(0) != null) {
  if($(program_introduction).parent().get(0).tagName == 'STRONG') {
    program_introduction = $(program_introduction).parent();
  }
  }
  }
  $(program_introduction).hide(); 
  $(program_introduction).next().hide();
  $(program_introduction).prev().hide();
  $(program_introduction).prev().prev().hide();
  $(program_introduction).prev().prev().prev().hide();
  */
  //set up the sections in a test or survey
  var sections = $("div.row:contains('*SECTION*')");
  var sectionCount = $(sections).length;

  var numbers = $(".row > h3");
  var sectionNumbers = new Array();
  $(sections).each(function () {
      
      var number = $(this).children("h3");
      var restart = number.text();

      restart = parseInt(restart.substring(0, restart.length - 1));
      sectionNumbers.push(restart);

      var sectionLabel = $(this).text();
      
      sectionLabel = sectionLabel.split("*SECTION*")[1];
      $(this).text(sectionLabel);
      $(this).wrap("<h4 style='border: #555555 solid 1px'></h4>");
      
  });
  
  $(numbers).each(function () {
      if(sectionCount > 0) {
        var currentNumber = $(this).text();
        currentNumber = parseInt(currentNumber.substring(0, currentNumber.length - 1));
        var finalNumber = currentNumber;
        for (var i = 0 ; i < sectionNumbers.length ; i++) {
          if(currentNumber > sectionNumbers[i]) {
            finalNumber -= 1;
          }
        }
        $(this).text(finalNumber + ")");
      }
  });
});
