jQuery( document ).ready( function( $ ) {

/*----------------------------------------------------------------------------------*/
/*  Mobile Menu
/*----------------------------------------------------------------------------------*/

$('.hamburger').click(function(e){
    $('.site-header .column__menu').toggleClass('open__mobile');
    e.preventDefault();
});

/*----------------------------------------------------------------------------------*/
/*  Modal
/*----------------------------------------------------------------------------------*/

var iframe = $('#vimeo');
var player = new Vimeo.Player(iframe);

$('a.open__modal, .open__modal a').click(function(e){

    var modalID = $(this).attr('href');

    $('.modal' + modalID).fadeIn();

    if ( modalID == '#video' ) {
        player.play();
    }

    e.preventDefault();
});

$('.modal .close').click(function(e){

    $('.modal').fadeOut();

    player.pause();

    e.preventDefault();
});

if (location.href.indexOf("#demo") != -1) {
    $('.modal#demo').fadeIn();
}

if (location.href.indexOf("#thanks") != -1) {
    $('.modal#thanks').fadeIn();
}


$(document).mouseup(function(e) {
    var container = $('.modal .inner');

    // if the target of the click isn't the container nor a descendant of the container
    if (!container.is(e.target) && container.has(e.target).length === 0) 
    {
        $('.modal').hide();
        player.pause();
    }
});

jQuery(document).bind('gform_confirmation_loaded', function(event, formId){
    // code to be trigger when confirmation page is loaded
    $('#demo .inner').addClass('thanks');
});

});