(function ($) {

  $(document).ready(function() {
    
    if ($("body.default").length > 0) {
      
      
      // get the first category (i.e. "/about/blahblah/" -> 'about')
      var headers = ["about", "abc", "contact", "film-and-photos", "for-teachers", "get-involved", "sponsors"]

      var toplevel = window.location.pathname.substring(1).split("/")[0];
      if ($.inArray(toplevel, headers) == -1) toplevel = headers[0]; 
      
      var header = $("<div id='header-image'><img src='/images/headers/" + toplevel + ".jpg' /></div>");
      
      $("body.default #content>h1").after(header);
      
      var tips = [
      "<p>YOH fest gives our students the oppurtunity to explore sensitive themes, you have to love it.... education and performance.</p><h4>Sascha Bragaglia</h4>  <p>Dance Teacher  <br />Hedland SHS</p> ",
      "<p>Our students dont get to see many live shows, there was silence in the crowd as they watched the other schools perform in awe!</p><h4>Sascha Bragaglia</h4> <p>Dance Teacher <br />Hedland SHS</p> ",
      "<p>The first year we joined we had 5 students, last year 30,  this year over 60 students are involved, YOH fest gets bigger and better ever year!</p><h4>Sascha Bragaglia</h4><p>Dance Teacher <br />Hedland SHS</p> "]

      var tip = tips[Math.floor(Math.random() * tips.length)];
      
      $("body.default #tips").append(tip);
    }
  
    var search = $("li.search input");
    
    function setSearch() {
      search.val("Search");
    }
    
    function clearSearch() {
      search.val("");
    }
    
    setSearch();
    
    search.focus(clearSearch).blur(setSearch);

   
    // Disable menu links for toplevel links with no child links (i.e. clicking on the link doesnt do anything)
    $("#menu>ul>li").each(function () {
      if ($(this).find("ul").length > 0) {
        $(this).children("a").click(function(e) {
          e.preventDefault();
        })
      }
    });
    
    if ($.fn.lightBox) {
      var lightBoxOpts = {
        imageLoading:			'/jquery-lightbox/images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
  			imageBtnPrev:			'/jquery-lightbox/images/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
  			imageBtnNext:			'/jquery-lightbox/images/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
  			imageBtnClose:		'/jquery-lightbox/images/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
  			imageBlank:				'/jquery-lightbox/images/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
      };
      
      $("#image-gallery a").lightBox(lightBoxOpts)
    }
  
  });
  
})(jQuery);


