$(window).load(function () {
  /* Media tabs */
  var tabContainers = $('#tabs > div.tab');
  tabContainers.hide().filter(':first').show();
  $('#tabs #media-options a').click(function () {
    tabContainers.fadeOut();
    tabContainers.filter(this.hash).fadeIn();
    $('#tabs #media-options a').removeClass('selected');
    $(this).addClass('selected');
    return false;
  }).filter(':first').click();
  
  /* Gallery thumbnails fade */
  $('a[rel*=lightbox]').colorbox({scrolling: false, opacity: 0.7, transition:"fade"});
  var activeOpacity = 1.0, inactiveOpacity = 0.5, fadeTime = 500, thumbs = "ul.gallery li"; 
  $(thumbs).fadeTo(1, inactiveOpacity);
  $(thumbs).hover(
    function() { 
      $(this).stop(true, true).fadeTo(fadeTime, activeOpacity); 
    }, 
    function(){ 
      $(this).stop(true, true).fadeTo(fadeTime, inactiveOpacity); 
    }
  );
  
  /* JS for submit */
  $('a.btn').click(function(e) { 
    e.preventDefault();
    $(this).parents('form').submit(); 
  });
  
  /* SMooth scroll */
  $('a.top').click(function(e) {
    e.preventDefault();
    $('html, body').animate({scrollTop: $("#index").offset().top}, 500); return false; 
  });
  
  /* Contact form validation */
  $("#contact-form").validate();

});

