Mon May 22 2017
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
_satellite.pushAsyncScript(function(event, target, $variables){
  /*
 * This is the RTO to show $10 off current page.
 * It will redirect the user to a page where
 * S5 is $10 less.
 */

var config = {

  // number of seconds til RTO shows
  delay: 5,

  // If we cant find a template with rs.template, use this
  defaultTemplate : 'sbsr',

  // if page is sitewide, rmsitewide, or sale - use this page
  defaultBase: 'gradgift',

  // pages with these pricepoints will show the RTO
  applicablePrices: [199, 249],

  // Must be parallel with the prices above. Will display in html.
  dollarsOff: [20, 20],

  // Pricepoint of pages this rto redirects to, if accepted.
  /* In future can we expand this to be array as well */
  destinationPriceCode : 'agi',

}





function rtorouter(config) {

    // If user has rtoseen cookie, quit.
    if (document.cookie.match(/rtoseen/)) return;

    // clock stuff
    var timeinterval;

    function close_popup_rto() {
        $('#popup_rto').remove()
        $('#popup_rto_shade').fadeOut('fast')
        document.cookie='rtoseen=true; path=/; domain=.rosettastone.com';
    }

    function getTimeRemaining(endtime){
        var t = endtime - Date.now();
        var seconds = Math.floor( (t/1000) % 60 );
        var minutes = Math.floor( t/1000/60 );
        return { 'total': t, 'minutes': minutes, 'seconds': seconds };
    }

    var clock = document.getElementById('popup_clock');

    function startClock(endtime) {

        clock.style.display = 'inline-block';

        var values = ['minutes','seconds'];
        var spans = [];

        for(var i=0; i<values.length; i++){
            spans.push( clock.querySelector('.'+values[i]) );
        }

        function updateClock() {
            var t = getTimeRemaining(endtime);

            for(var i=0; i<spans.length; i++){
                spans[i].innerHTML = ('0' + t[values[i]]).slice(-2);
            }

            if(t.total<=0){
                clock.style.display = 'none';
                clearInterval(timeinterval);
                close_popup_rto();
            }
        }
        timeinterval = setInterval(updateClock,1000);
    }



/* Hardcoding because its friday */
  var pricepoint = 249;
  
  if(!window.location.pathname.match(/learn-/)){
    pricepoint = parseInt(RSI({cat: 'esp', media: 'box', lvl: 'S5'})[0].price)
  }

  // If this page's pricepoint isnt in the applicablePrices array, quit.
  var priceindex = config.applicablePrices.indexOf(pricepoint)

  if (priceindex == -1) return

  // update html to show right amount of dollars off
  var dollarDiv = document.getElementById('popup_rto_amount')
  if (dollarDiv)
    dollarDiv.innerHTML = config.dollarsOff[priceindex]

  if (rs.template == 'ppc') {
     $('.save_ten').css({'line-height':'115px'})
     .find('sup').css({position:'relative', top: '-50px'})
  }


    // Find out base name of this. This is everything before the
    // vcrypt(tm) characters - bii, bai, boi, etc. This is because
    // we want to redirect to a lower page with same base. So
    // cybermondabii goes to cybermondaybai, bfbbii goes to bfbai, etc.
    var pagename = typeof RSI != 'undefined' ? RSI.rsi : 'sitewide'

    var destinationpage;

    var pricecodes = ['bgi', 'bgd', 'bdi', 'bbi', 'bai', 'boi', 'aii','ahi', 'agi', 'ahd', 'aei']
    if (pricecodes.indexOf(pagename.slice(-3)) > -1) {
        destinationpage = pagename.slice(0, -3) + config.destinationPriceCode
    } else {
        // This current page is sitewide, rmsitewide, sale, etc.
        destinationpage = config.defaultBase + config.destinationPriceCode
    }

/* Fix to override 249 to go to bbi */
if( pricepoint === 249){
   config.destinationTemplate = 'sbsr';
   destinationpage = config.defaultBase + 'bbi' 
}


/* something to do with crazy additinol 12 month sku gets 15 month RTO */
    // var destinationTemplate = typeof rs != 'undefined' ? rs.template : config.destinationTemplate

    var destinationUrl = 'http://rosettastone.com/lp/' + config.destinationTemplate + '/' + destinationpage + window.location.search


    $('#popup_cta').attr('href', destinationUrl)


  startClock(Date.now()+10*60*1000);


  // Show the RTO
  $('#popup_rto').show()
  $('#popup_rto_shade').fadeIn('fast')

  startClock(Date.now()+10*60*1000)


  $('#popup_cta').click(function(e) {
    e.preventDefault()
    document.cookie='rtoseen=true; path=/; domain=.rosettastone.com';
    window.location.href = $(e.target).attr('href')
  })

  $('#popup_rto_x').click(function(e) {
    e.preventDefault()
    close_popup_rto()
  })


 }



window.setTimeout(function() {
    rtorouter(config)
}, config.delay * 1000)


});