$(document).ready(function(){
  // Function to append an arrow to top-level menu items that have children.  
  $("ul#top_main_menu_menu li ul").children().each(function() {
    if ($("ul#top_main_menu_menu li ul").children(".level2")) {
      var targetItem = $(this).parent().parent();
      if (targetItem.hasClass("selected")) {
        targetItem.addClass("subpages-select");
      } else {
        targetItem.addClass("subpages");
      }
    }
  });
  
  // FAQ question hiding. (hide all answers by default at page load.
  $("#main-body-copy div.answer").hide();
  
  $("#main-body-copy p.question").click(function() {
    var questionNumber = $(this).attr("id");
    var answerVisibility = $("#main-body-copy div." + questionNumber).css("display");


    // alert("The clicked ID was " + questionNumber + ". & visibility = " + answerVisibility);
    if (answerVisibility == "block") {
      $("#main-body-copy div."+questionNumber).fadeOut("fast");
    } else {
      $("#main-body-copy div."+questionNumber).fadeIn("fast");
    }
  });
  
  // SEO Extra Content Hiding. (hide all extra content by default at page load).
  $("#main-body-copy div.indepth").hide();
  
  $("#main-body-copy a.indepth").click(function() {
    var inDepthNumber = $(this).attr("id");
    var inDepthVisibility = $("#main-body-copy div." + inDepthNumber).css("display");

    if (inDepthVisibility == "block") {
      $("#main-body-copy div."+inDepthNumber).fadeOut("fast");
      $("#main-body-copy a.indepth").css({ "background-image" : "url(/images/footer-bullet.gif)",
                                                "background-position" : "no-repeat 2px 5px"
                                            });
    } else {
      $("#main-body-copy div."+inDepthNumber).fadeIn("fast");
      $("#main-body-copy a.indepth").css({ "background-image" : "url(/images/menu-arrow-down.gif)",
                                                "background-position" : "no-repeat left 5px"
                                            });
    }
  });

  $(document).ready(function(){
  // Check whether 'Specify' field contains anything upon submission.
  /*
  var isEmpty = $('#phone').attr("value");
  if (isEmpty == "") {
    $("input#callback").attr("disabled", "disabled");
  }

  $("input#phone").blur(function() {
    var isEmpty = $('#phone').attr("value");
    if (isEmpty == "") {
      $("input#callback").attr("disabled", "disabled");
    } else {
      $("input#callback").removeAttr("disabled");
    }
  });

  $("form").submit(function() {
      if ($("input#phone").val() == "" && $("input#email").val() == "") {
        alert("Please enter your E-mail address or Telephone number or both so we can confirm your booking.");
        return false;
      }
  });
  */
});
});