
// config settings
var _copySpeed  = 1;
var _copyStartX = 0;
var _copyEndX   = 0;
var _copyEase   = "none";


// exit
var exitBtn     = getById("exit_btn");
var _exitURL    = "https://www.hogarth.com";


// Create and provide timeline to Hoxton
var Creative = {

    tl: gsap.timeline( { defaults: { ease:"none" , duration:0 } } ),


    setExitURL: function( strURL )
    {
        _exitURL = strURL;
    },

    onExit: function( e ) 
    {
        hoxton.exit( "Exit" , _exitURL );
    },

    onBannerStart: function() 
    {
        console.log("Creative.onBannerStart()");
    },

    onBannerComplete: function() 
    {
        console.log("Creative.onBannerComplete()");
    },

    startAd: function() 
    {
        Creative.createButtons();
        Creative.displayBanner();
        Creative.setUpTimeline();

        Creative.init();
    },

    createButtons: function()
    {
        exitBtn.addEventListener( "click" , Creative.onExit , false );
    },

    setUpTimeline: function()
    {
        Creative.tl.eventCallback("onStart", Creative.onBannerStart);
        Creative.tl.eventCallback("onComplete", Creative.onBannerComplete);
    },

    displayBanner: function()
    {
        gsap.to(loading_content,{display:"none"});
        gsap.to(container,{display:"block"});
    },

    init: function() 
    {
        
        Creative.tl
            .addLabel("reset", 0.001)
                .to([copy_01, copy_02], {x:_copyStartX,alpha:0}, "reset")

                .to(copy_01, {duration:_copySpeed, alpha:1}, ">")
                .to(copy_01, {duration:_copySpeed, x:0, ease:_copyEase}, "<")

                .to(copy_01, {duration:_copySpeed, alpha:0}, ">2")
                .to(copy_01, {duration:_copySpeed, x:_copyEndX, ease:_copyEase}, "<")
                
                .to(copy_02, {duration:_copySpeed, alpha:1}, ">")
                .to(copy_02, {duration:_copySpeed, x:0, ease:_copyEase}, "<")

            .addLabel("end", ">");
    }

};

function getById( eleID ) 
{
    return document.getElementById(eleID);
}
