$(document).ready(function(){ 
  
  //Superfish Menu
  $("ul.sf-menu").supersubs({ 
    minWidth:    12,   // minimum width of sub-menus in em units 
    maxWidth:    27,   // maximum width of sub-menus in em units 
    extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                       // due to slight rounding differences and font-family 
                       // call supersubs first, then superfish, so that subs are 
                       // not display:none when measuring. Call before initialising 
                       // containing tabs for same reason.
  });
  
  $("ul.sf-menu").superfish({
    autoArrows:    false
  });
  
  //Colorbox for Content Images
  $("a[rel='colorbox']").colorbox({
    current: "{current}/{total}"
  });
  
  //Validate
  $("#commentForm").validate({
    //don't show the error message
    errorPlacement: function(error,element) {
                       return true;
                    }
  });
  
  //Datepick
  $(".datepick").datepick();
  
  //Galleriffic
    // We only want these styles applied when javascript is enabled
    $('div.navigation').css({'width' : '240px', 'float' : 'left'});
    $('div.content').css('display', 'block');
    
    // Initially set opacity on thumbs and add
    // additional styling for hover effect on thumbs
    var onMouseOutOpacity = 0.67;
    $('#thumbs ul.thumbs li').opacityrollover({
      mouseOutOpacity:   onMouseOutOpacity,
      mouseOverOpacity:  1.0,
      fadeSpeed:         'fast',
      exemptionSelector: '.selected'
    });
    
    // Initialize Advanced Galleriffic Gallery
    var gallery = $('#thumbs').galleriffic({
      delay:                     2500,
      numThumbs:                 20,
      preloadAhead:              40,
      enableTopPager:            false,
      enableBottomPager:         false,
      maxPagesToShow:            7,
      imageContainerSel:         '#slideshow',
      controlsContainerSel:      '#controls',
      captionContainerSel:       '#caption',
      loadingContainerSel:       '#loading',
      renderSSControls:          false,
      renderNavControls:         false,
      playLinkText:              '',
      pauseLinkText:             '',
      prevLinkText:              '',
      nextLinkText:              '',
      nextPageLinkText:          '',
      prevPageLinkText:          '',
      enableHistory:             false,
      autoStart:                 false,
      syncTransitions:           true,
      defaultTransitionDuration: 900,
      onSlideChange:             function(prevIndex, nextIndex) {
        // 'this' refers to the gallery, which is an extension of $('#thumbs')
        this.find('ul.thumbs').children()
          .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
          .eq(nextIndex).fadeTo('fast', 1.0);
      },
      onPageTransitionOut:       function(callback) {
        this.fadeTo('fast', 0.0, callback);
      },
      onPageTransitionIn:        function() {
        this.fadeTo('fast', 1.0);
      }
    });
    
  
}); 
