$(document).ready(function(){

  // clear floats on block element
  $('.clearfix').append('<div class="clearall"><!-- clear floats --></div>')

  // add first and last classes to all lists, table rows, table heads and table cells in the DOM
  $('ul li:first-child,table tr:first-child,tr td:first-child, tr th:first-child').addClass('first');
  $('ul li:last-child,table tr:last-child,tr td:last-child, tr th:last-child').addClass('last');

  // start the drop down menu plugin 'superfish'
  $("ul.sf-menu").superfish({
      delay:  500,
      animation: {opacity:'show',height:'show'},
      speed: 'fast',
      autoArrows:  false
  });
  
  // centre 'superfish' menus under the top level navigation items
  $("ul.sf-menu li ul").each(function(){         // this function centres the drop-down menus under each of their top level nav bar items
      var pwidth = $(this).parent().width();          // get width of LI parent
      var cwidth = $(this).width();                   // get width of drop-down menu UL
      var marginleft = ((cwidth - pwidth) / 2);       // this is the value that the item needs to be negatively set on left margin
      $(this).css("margin-left",(0 - marginleft));    // set the new margin-left value directly onto the selector
  });

 
  // add 'hover' class for when user moves mouse over navigation items - mainly for IE6/7
  $("#nav li a").hover(
    function() {
      $(this).addClass('hot');
    },
    function() {
      $(this).removeClass('hot');
    }
  );
  
  // validation of form submissions
  // $('.validate-form').validate();
   
  $(".gallery-item a").equalHeights();

  $("a[rel^='prettyPhoto']").prettyPhoto({
      animationSpeed: 'normal', /* fast/slow/normal */
      padding: 40, /* padding for each side of the picture */
      opacity: 0.35, /* Value betwee 0 and 1 */
      showTitle: true, /* true/false */
      allowresize: true, /* true/false */
      counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
      theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
      callback: function(){}
  });
  
});
