var exitURL = '';

$(function ()
{
    var interstitialModal = new ModalPopup(
    {
        dynamic: false,
        popupSelector: "#interstitialModal",
        triggerSelector: ".leavingSite",
        closeSelector: ".closeModal, #modalBackground, .modalCancelBtn, .modalContinueBtn"
    });

    //On click of link, pull interstitial information
    $('.leavingSite').click(function ()
    {
        exitURL = $(this).attr('href');
    });

    $('.modalContinueBtn').click(function ()
    {
        $('#interstitialModal').hide();
        $('#modalBackground').remove();

        var newWindow = window.open(exitURL, '_blank');

        return false;
    });

    /********* Scroll to location *********/
    $('.scrollToLocation, .scrollToLocationBackToTop').click(function(e)
	{
        var getHref = $(this).attr('href');
        var correctAnchor = getHref.replace(/#/, '');

        processScrollTo(correctAnchor);

        return false;
    });
});

function processScrollTo(id)
{
    var targetOffset = $('#' + id).offset().top;
    $('html, body').animate({ scrollTop: targetOffset }, 500);
}
