$(document).ready(function() {
    
    // CSS Animation on Navigation Bar
    $('.navbar-default .navbar-nav li, aside ul li, .footer-social a, .footer-sitemap a, .slider-content-container .slide-button, .masthead-vid-thumbnails-container .vidthumb.vidthumb-landing').hover(function() {
        $(this).siblings('li, a').css({
            'opacity': '0.5', 
            '-webkit-transition': 'opacity 1s', 
            '-moz-transition': 'opacity 1s', 
            'transition': 'opacity 1s'
        });
    }, function() {
        $(this).siblings('li, a').css({
            'opacity': '1', 
            '-webkit-transition': 'opacity 1s',
            '-moz-transition': 'opacity 1s',
            'transition': 'opacity 1s'
        });
    });

    //Now using GTM
    // $('#banner-apply-retail').click(function() {
    //     ga('send', {
    //       hitType: 'event',
    //       eventCategory: 'Go to job page (external)',
    //       eventAction: 'Homepage banner button clicked',
    //       eventLabel: 'Apply for retailer jobs'
    //     });
    // });
    // $('#banner-apply-head-office').click(function() {
    //     ga('send', {
    //       hitType: 'event',
    //       eventCategory: 'Go to job page (external)',
    //       eventAction: 'Homepage banner button clicked',
    //       eventLabel: 'Apply for head office jobs'
    //     });
    // });
    // $('#menu-apply-retail').click(function() {
    //     ga('send', {
    //       hitType: 'event',
    //       eventCategory: 'Go to job page (external)',
    //       eventAction: 'Menu current positions links clicked',
    //       eventLabel: 'Apply for retailer jobs'
    //     });
    // });
    // $('#menu-apply-head-office').click(function() {
    //     ga('send', {
    //       hitType: 'event',
    //       eventCategory: 'Go to job page (external)',
    //       eventAction: 'Menu current positions links clicked',
    //       eventLabel: 'Apply for head office jobs'
    //     });
    // });
    // $('.homepage-sign-up-job-alert').click(function() {
    //     ga('send', {
    //       hitType: 'event',
    //       eventCategory: 'Go to job page (external)',
    //       eventAction: 'Homepage job alert clicked',
    //       eventLabel: 'Go to PageUp job alert page'
    //     });
    // });
});


/**
 * Sends Google Analytics event *via* Tag Manager
 * (via a workaround since GA is not embedded in the same way)
 * 
 * Does NOT currently support events that fire *before* analytics
 * (That would require buffering of events and polling to detect when it's loaded)
 */
function gaSendViaTagManager(eventCategory, eventAction, eventLabel, eventValue) {
    if (!window.ga || !window.ga.getAll) {
        window.console && console.warn('Oops. Tried to send Analytics event, but Google Analytics does not appear to have loaded yet.', eventCategory, eventAction, eventLabel, eventValue);
        return;
    }
    if (!ga.getAll().length) {
        window.console && console.warn('GA has loaded but could not find any active trackers.');
        return;
    }
    ga.getAll()[0].send('event', eventCategory, eventAction, eventLabel, eventValue);    
}

