$(function(){
  // Overtake share links and open them in a popup window
  $('a.share').click(function(e){
    e.preventDefault();
    window.open($(this).attr('href'));
  });
  
  // Setup all generic carousels
  App.AllCarousels = [];
  $.each($('.carousel'), function(index, item) {
    App.AllCarousels.push(new App.GenericCarousel($(item)));
  });
  
  // Make boxes wrapped with a link fade their background
  $('a.fade').hover(function(e) {
    $('div.boxed', $(this)).css('background-color', '#222');
  }, function(e) {
    $('div.boxed', $(this)).css('background-color', '#000');
  });
  
  // Roll over image swap for carousel navigations, and share buttons
  $('.hover-btn').hover(function(e) {
    this.src = this.src.replace('-out', '-over');
  }, function(e) {
    this.src = this.src.replace('-over', '-out');
  });
  
  // Home
  App.bodyClass('main-index', function() {
    App.HomePageHero = new App.HomePageCarousel($('.hero-carousel'), $('.hero-indicators div'));
  });	
  
  // About
  App.bodyClass('about-index', function() {
    App.AboutGallery 	   = new App.AboutPageCarousel($('.about-gallery'));
    App.AboutModal1Gallery = new App.AboutPageCarousel($('#modals-1-gallery'));
    App.AboutModal2Gallery = new App.AboutPageCarousel($('#modals-2-gallery'));
    App.AboutModal3Gallery = new App.AboutPageCarousel($('#modals-3-gallery'));
    App.AboutModal4Gallery = new App.AboutPageCarousel($('#modals-4-gallery'));
    App.AboutModals  	   = new App.AboutPageModals($('.culture'));	  
  });
  
  // Work Index
  App.bodyClass('work-index', function()
  {
    $('select.filter').dropkick(
      { 
	theme: 'syrup',
	change: function(value, label)
	{
	  $('.filter-form').submit();
	} 
      });
    
    $('select.project').dropkick(
    { 
      theme: 'syrup',
      change: function(value, label)
      {
	window.location = value;
      } 
    });
    
  $('html').click(function(e)
  {
    $.each( $('select'), function(index, value)
    {
      $(value).dropkick('close');
    });
  });
  
});
  
  // Contact
  App.bodyClass('contact-index', function() {
    App.Jobs = new App.JobFlipper($('.jobs'));
  });
});
