(function($){
  
  // contact form trigger
  $('.contact-form-trigger').click(function() {
    $('.contact-form-wrapper').animate({
      height: 'toggle'
    });
  });
  
  var app = {};
  
  app.show_overlay = function() {
    // show the overlay
    $('.overlay').fadeTo(300, 0.8);
    //$('.overlay').css('opacity', 0.8);
  }
  
  app.hide_overlay = function() {
    // hide the overlay
    $('.overlay').fadeOut(300);
    //$('.overlay').css('opacity', 0.8);
  }
  
  app.overlay = $('.overlay');
  
  // attach click event to the overlay
  $('.overlay').click(function() {
    // hide overlay
    app.hide_overlay();
    // hide the newsletter form
    $('.newsletter').fadeOut(300);
  });
  
  // newsletter trigger
  $('.newsletter_trigger').click(function(e) {
    // prevent default event
    e.preventDefault();
    // show the overlay
    app.show_overlay();
    // show the newsletter form
    $('#newsletter-form')[0].reset();
    $('#newsletter-form').show();
    $('input', '#newsletter-form').removeClass("highlight");    
    $('.user-message p', '.newsletter').html();
    $('.user-message', '.newsletter').hide();
    $('.newsletter').fadeIn(300);
    //$('.newsletter').css('z-index', 100);
  });
  
  // newsletter close
  $('.newsletter_close').click(function(e) {
    // hide overlay
    app.hide_overlay();
    // hide the newsletter form
    $('.newsletter').fadeOut(300);
  });
  
  // waypoint for the links to micro sites
  $('.about').waypoint({
    offset: 150
  });
  $('.about').waypoint(function(e, direction) {
    if (direction === 'down') {
      // show the fixed menu
      $('.fixed_menu').fadeIn(300);
    } else {
      // hide the fixed menu
      $('.fixed_menu').fadeOut(100);
    }
  });
  
  // lightbox if any
  if ($('.gallery_box a').length > 0) {
    $('.gallery_box a').lightBox();    
  }
  
  
})(jQuery);

