$(document).ready(function()
{
  starting = false;
  loadingStart();

  function loadingStart()
  {
    if(starting)
    {
      $('div#loading').fadeIn(2500);
    }
    starting = true;
    loadingStep1();
  }

  function loadingStep1()
  {
    $('div#loading').fadeIn(2500, function() {
      loadingStep2();
    });
  }

  function loadingStep2()
  {
    $('div#loading').fadeOut(4500, function() {
      loadingStart();
    });
  }

  var delayValue = 10000;
  $('nav#menu-supersized').hover(
    function ()
    {
      $('span#toogle').text('<');
      $(this).stop().animate({'left':'0px'},150);
    },
    function ()
    {
      $('span#toogle').text('>');
      $(this).stop().animate({'left':'-140px'},150);
    }
  );

  $('section#next').hover(
    function ()
    {
      $(this).stop().animate({'right':'0px'},150);
      $('section#slidecounter').stop().animate({'right':'0px'},300);
    },
    function ()
    {
      $(this).stop().animate({'right':'-20px'},150);
      $('section#slidecounter').stop().animate({'right':'-40px'},300);
    }
  );

  $('section#previous').hover(
    function ()
    {
      $(this).stop().animate({'right':'0px'},150);
      $('section#slidecounter').stop().animate({'right':'0px'},300);
    },
    function ()
    {
      $(this).stop().animate({'right':'-20px'},150);
      $('section#slidecounter').stop().animate({'right':'-40px'},300);
    }
  );

  $('nav#menu-supersized').stop().delay(delayValue).animate({'left':'-140px'},1500);
  $('section#next').stop().delay(delayValue).animate({'right':'-20px'},1500);
  $('section#previous').stop().delay(delayValue).animate({'right':'-20px'},1500);

  $('section#defaultLogo').fadeIn(2000);

  $(window).load(function()
  {
    $('section#splash-loader').remove();

    /*$('section#splash-inner').css('display', 'none');
    $('section#splash-inner').fadeIn(800);*/

    $('section#splash-inner').animate({'left':'0px'}, { duration: 1500, easing: 'easeOutBack', complete: function()
      {
        //$('section#splash-inner').css('display', 'none');
        //$('section#splash-inner').fadeIn(120);
      }
    });
  });

  //path
  $('section#headerHandler').hover(
    function ()
    {
      $('section#path').css('visibility', 'visible');
    },
    function ()
    {
      $('section#path').css('visibility', 'hidden');
    }
  );

  //customers
  $('div.customer-logo').hover(
    function ()
    {
      $(this).fadeTo(200, '0.7');
    },
    function ()
    {
      $(this).fadeTo(200, '1');
    }
  );

  //realisation
  $('div.realisation-image').hover(
    function ()
    {
      $(this).fadeTo(200, '0.7');
    },
    function ()
    {
      $(this).fadeTo(200, '1');
    }
  );

  $('p.work-title').hover(
    function ()
    {
      $(this).fadeTo(600, '0.5');
    },
    function ()
    {
      $(this).fadeTo(600, '1');
    }
  );

  //header icons
  $('a.headerIconSection').hover(
    function ()
    {
      $(this).fadeTo(200, '0.7');
    },
    function ()
    {
      $(this).fadeTo(200, '1');
    }
  );

});
