Wed Jan 31 2018
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
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604
  • 605
  • 606
  • 607
  • 608
  • 609
  • 610
  • 611
  • 612
  • 613
  • 614
  • 615
  • 616
  • 617
  • 618
  • 619
  • 620
  • 621
  • 622
  • 623
  • 624
  • 625
  • 626
  • 627
  • 628
  • 629
  • 630
  • 631
  • 632
  • 633
  • 634
  • 635
  • 636
  • 637
  • 638
  • 639
  • 640
  • 641
  • 642
  • 643
  • 644
  • 645
  • 646
  • 647
  • 648
  • 649
  • 650
  • 651
  • 652
  • 653
  • 654
  • 655
  • 656
  • 657
  • 658
  • 659
  • 660
  • 661
  • 662
  • 663
  • 664
  • 665
  • 666
  • 667
  • 668
  • 669
  • 670
  • 671
  • 672
  • 673
  • 674
  • 675
  • 676
  • 677
  • 678
  • 679
  • 680
  • 681
  • 682
  • 683
  • 684
  • 685
  • 686
  • 687
  • 688
  • 689
  • 690
  • 691
  • 692
  • 693
$(function(){
  
  
    // for experiences 2 or 4 (3-month or 1-month, respectively)
    var current_experience = '2';
  
  
    // if 1-month is turned on (ws-1590)
    if(window.location.search.match(/onemonth=true/i)){
  
      // change experience to one-month (on desktop)
      current_experience = '4';
  
      // change data lvls from 3-month to 1-month (on mobile)
      $('*[data-lvl=03]').attr('data-lvl','01');
  
      // change product name from 3-month to 1-month (on mobile)
      $('.js_product_name').html(function(i,txt){return txt.replace('3-Month','1-Month')});
  
      // update prices and msrps to account for change from 3-month to 1-month (on mobile)
      window.update_prices();
      window.update_msrps();
  
      // update masthead (desktop and mobile)
      $('head').append('<style type="text/css"> body #masthead{ background-image: url(\'http://www.rosettastone.com/lp/spo/desktop_sbsr_nov_2016/assets/holiday_2016_1m_mobile.jpg\'); } @media(min-width:600px){ body #masthead{ background-image: url(\'http://www.rosettastone.com/lp/spo/desktop_sbsr_nov_2016/assets/holiday_2016_1m_desktop.jpg\'); } } </style>');
    }
  
  
  
    // *******************************************
    // INITIALIZE LANGUAGE AND PAGE
    // *******************************************
  
    window.current_lang = 'eng';
  
    // can turn figs-only state on or off (using true or false)
    function isFIGS(lang){
      var figs_only = false;
      return figs_only ? /esp|fra|ita|deu/i.test(lang) : true;
    }
  
  
    function getLangUrlParam(){
      return ( (window.location.search.match(/lang(uage)*=([^&]+)/i)||[])[2] || '').toLowerCase();
    }
  
  
    function respondToPreselectedLang(){
  
      // if lang in url parameter
      if( getLangUrlParam() && isFIGS(getLangUrlParam()) ){
        $(document).trigger('lang_change', {
          'lang': getLangUrlParam()
        });
      }
  
      // if lang in catalog
      if(isCatalog() && isFIGS(getCatalogLang())){
        $(document).trigger('lang_change', {
          'lang': getCatalogLang()
        });
      }
    }
  
    function isCatalog(){
      return window.location.pathname.match(/aprende-/i);
    }
  
    function getCatalogLang(){
      return window.lang;
    }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
    // *******************************************
    // INIT - RENDER EXPERIENCES AND FILL IN DATA
    // *******************************************
  
    function initPage(current_experience){
  
      render_experience(current_experience);
  
      set_up_pre_language();
  
      respondToPreselectedLang();
  
      $(document).trigger('price_update');
      $(document).trigger('cart_update');
    }
  
  
  
  
  
  
  
  
  
  
  
  
    // *******************************************
    // EMIT LANGUAGE CHANGE EVENTS
    // *******************************************
  
  
    // emit event when language changes in test mode
    $('#temporary_lang_dropdown').on('change',function(){
      var lang = this.value;
  
      $(document).trigger('lang_change', {
        'lang': lang
      });
    });
  
  
    // emit event when language changes on sbsr or ppc
    $('.language-buy-list a').click(function(){
      var lang = this.id;
  
      $(document).trigger('lang_change', {
        'lang': lang
      });
    });
  
  
  
  
  
  
  
  
  
  
    // *******************************************
    // RESPOND TO LANGUAGE CHANGE EVENTS
    // *******************************************
  
  
    // update everything when language changes
    $(document).on('lang_change', function(e,data){
  
      // show correct button copy
      var button_copy = 'AÑADIR AL CARRITO';
      if(window.location.search.match(/gifting=1/i)){
        button_copy = '¡Dar como regalo!';
      }
  
      // restore cart button functionality now that we have a language
      $('.js_oct_2016_addtocart').off('click').html(button_copy);
  
      var lang = data.lang;
  
      current_lang = lang; // just so this is available
  
      check_if_s3_lang(lang);
  
      // if top langs, run test code
      if(lang.length===3 && isFIGS(lang)){
  
        // show test products and hide regular products
        // $('#multivariate_container').show();
        // $('#products').hide();
  
        var lang_map = {
          esp: 'Español (Latinoamérica)',
          eng: 'Inglés (Americano)',
          fra: 'Francés',
          deu: 'Alemán',
          ita: 'Italian',
          ara: 'Árabe',
          chi: 'Chino (Mandarin)',
          ned: 'Holandés',
          ebr: 'Inglés (Británico)',
          tgl: 'Filipino (Tagalog)',
          grk: 'Griego',
          heb: 'Hebreo',
          hin: 'Hindi',
          gle: 'Irlandés',
          jpn: 'Japonés',
          kor: 'Coreano',
          far: 'Persa (Farsi)',
          pol: 'Polaco',
          por: 'Portugués (Brasil)',
          rus: 'Ruso',
          esc: 'Español (España)',
          sve: 'Sueco',
          tur: 'Turco',
          vie: 'Vietnamita'
        };
  
        var lang_name_parts = {
          first : lang_map[lang].split(' (')[0],
          last : (lang_map[lang].match(/\(.+/)||[])[0],
          full : lang_map[lang]
        };
  
        // update language display names
        $('.js_langname_1').html(lang_name_parts.first);
        $('.js_langname_2').html(lang_name_parts.last);
        $('.js_langname').html(lang_name_parts.full);
  
        // update cart buttons
        $('.js_oct_2016_addtocart').attr('data-lang', lang);
  
        $(document).trigger('cart_update');
      }
  
  
      // if not top langs, hide test and show regular products
      else{
        // $('#multivariate_container').hide();
        // $('#products').show();
      }
    });
  
  
    function hasS5(lang){
      return !!RSI({cat:lang, lvl:'S5'})[0];
    }
  
    function check_if_s3_lang(lang){
  
      if(hasS5(lang)){
        // enable s5 cart button
        $('.js_oct_2016_no_s5').removeClass('js_oct_2016_no_s5').addClass('js_oct_2016_addtocart');
  
        // show s5 product
        $('.js_oct_2016_addtocart[data-lvl=S5]').closest('.js_oct_2016_product').show();
      }
  
      if(!hasS5(lang)){
        // hide s5 product
        $('.js_oct_2016_addtocart[data-lvl=S5]').closest('.js_oct_2016_product').hide();
  
        // disable s5 cart button
        $('.js_oct_2016_addtocart[data-lvl=S5]').removeClass('js_oct_2016_addtocart').addClass('js_oct_2016_no_s5');
      }
    }
  
  
  
  
  
  
  
  
  
  
  
  
  
    // *******************************************
    // SET CORRECT PRICES EVERYWHERE
    // *******************************************
  
    function update_prices(selector){
      
      //Control: default is set by var above. Default will be overridden in either case by setting "showfull" or "showmonthly"
      window.__showFullPrices = showfullpricesasdefault;
      window.location.search.match(/showfull=/) && (window.__showFullPrices = 1);
      window.location.search.match(/showmonthly=/) && (delete window.__showFullPrices);
      
      var prices = document.querySelectorAll(selector);
      var rsidata, lvl, media, isMsrp, multipay_divisor, msrp, price, isMobile;
  
      for(var i=0; i<prices.length; i++){
        lvl = prices[i].getAttribute('data-lvl');
        media = prices[i].getAttribute('data-media');
        isMsrp = prices[i].getAttribute('data-is-msrp');
        isMobile = /mobile_/.test(prices[i].className);
  
        multipay_divisor = prices[i].getAttribute('data-multipay-divisor');
  
        rsidata = RSI({'lvl':lvl, 'media':media})[0];
  
        // check if rsidata exists (to avoid errors such as looking for S5 data in an S3 product)
        if(rsidata){
  
          msrp = multipay_divisor ? Math.ceil(rsidata.msrp/multipay_divisor) : rsidata.msrp;
          price = multipay_divisor ? Math.ceil(rsidata.price/multipay_divisor) : rsidata.price;
  
          if(isMsrp){
            //Reset MSRPs:
            if(!window.__showFullPrices && rsidata.lvl in {'24':1,'12':1,'06':1,'03':1,'01':1}){
              //Monthly
              if(prices[i].getAttribute('class').match(/mobile_msrp/gi)){
                //Mobile MSRP & Label Adjust
                
                var mpc = prices[i].parentNode;
                mpc.removeChild(prices[i]);
                var mobileproductlabel = mpc.parentNode;
                mobileproductlabel.style.top = '7px';
                mobileproductlabel.style['border-radius'] ='unset';
                if(rsidata.lvl == '24'){
                  !mobileproductlabel.querySelector('.labelcontain.topper') && mobileproductlabel.insertAdjacentHTML('beforebegin','<div class="labelcontain topper">MEJOR VALOR</div>');
                  mobileproductlabel.style['margin-top'] = '0';
                }
                else {
                  mobileproductlabel.style['border-top-left-radius'] = '5px';
                  mobileproductlabel.style['border-top-right-radius'] = '5px';
                }
                (mobileproductlabel.getAttribute('class') || '').match(/mobile_product_label/gi) && !((mobileproductlabel.nextElementSibling.getAttribute('class') || '').match(/monthly_mobilebottom/gi)) && !(mobileproductlabel.style.display.match(/none/gi)) && mobileproductlabel.insertAdjacentHTML('afterend', '<div class="monthly_mobilebottom labelcontain">'+ prices[i].outerHTML +'<span class="mobile_msrp js_oct_2016_price">'+ rsidata.msrp +'</span><strong style="font-family: GothamBold; display: inline-block; margin: 0 .1em;">$'+ rsidata.price +'</strong> paga hoy</div>');
                
              }
              else {
                //Desktop
                prices[i].innerHTML = msrp;
                var msrpcontainer = prices[i].parentNode.parentNode;
                var nodes = Array.prototype.slice.call(msrpcontainer.childNodes);
                nodes[0] && nodes[0].nodeName.match(/text/gi) && nodes[0].parentNode.removeChild(nodes[0]);
                if(!msrpcontainer.querySelector('.msrpstrong')){
                  msrpcontainer.insertAdjacentHTML('beforeend','<strong class="msrpstrong" style="display: inline-block; margin: 0 .5em; font-family: GothamBold;">$' + rsidata.price + '</strong><span>paga hoy</span>');
                }
              }
              
            }
            else {
              //Full
              prices[i].innerHTML = msrp;
              
              if(msrp===price){
                if(isMobile){
                  prices[i].style.visibility = 'hidden';
                }
                else{
                  prices[i].parentElement.parentElement.style.visibility = 'hidden';
                }
              }
            }
          }
          else{
            //Reset prices:
            if(!window.__showFullPrices && rsidata.lvl in {'24':1,'12':1,'06':1,'03':1,'01':1}){
              var fn = parseFloat;
            var monthlyprice = (Math.ceil((fn(rsidata.price, 10)/parseInt(rsidata.lvl, 10))*100)/100).toFixed(2);
              //Monthly
              if(prices[i].getAttribute('class').match(/mobile_price/gi)){
                //Mobile
                var mpc = prices[i].parentNode;
                prices[i].textContent = monthlyprice.split('.')[0];
                prices[i].style['font-size'] ='2.5em';
                !mpc.querySelector('.productcents') && mpc.insertAdjacentHTML('beforeend','<div class="productcents" style="display: inline-block; font-size: 1em; vertical-align: top; text-align: left; margin-top: 0.3em"><p>.' + monthlyprice.split('.')[1] + '</p><p>/Mes</p></div>');
              }
              else {
                //Desktop				
                prices[i].innerHTML = monthlyprice.split('.')[0];
                prices[i].insertAdjacentHTML('beforeend', '<div style="display: inline-block; font-size: 0.385em; vertical-align: top; text-align: left; margin-top: 0.3em; vertical-align: baseline; line-height: 1.2;"><p>.' + monthlyprice.split('.')[1] + '</p><p>/Mes</p></div>');
              }
            }
            else {
              //Full
              prices[i].innerHTML = price;
            }
          }
        }
        
        
        if (msrp == price)
        {
          
          //console.log(`price: ${price}    msrp: ${msrp}     ${prices[i]}`)
          $(prices[i]).parents('.oct_2016_multipay_strikeprice_square').hide()
          if ($(prices[i]).hasClass('mobile_msrp'))
          {
            $(prices[i]).hide()
          }                
        }
         // Hide 24D & egift strikethrough if same as price
        try
        {
          if (RSI({cat: 'esp', media: 'box', lvl: '24D'})[0].price == RSI({cat: 'esp', media: 'box', lvl: '24D'})[0].msrp)
          {
            $('.oct_2016_gold_bg .oct_2016_msrp_square').hide()
          }
  
         
        }
        catch (e)
        {
  
        }
  
  
  
      }
    }
  }
  

    
  
  
  
  
  
  
  
  
  
  
    // *******************************************
    // TOGGLE GIFTING
    // *******************************************
  
    $('.js_oct_2016_gifting').on('change', function(){
  
      // update data-gifting attribute on nearest cart button
      $(this).closest('.js_oct_2016_product').find('.js_oct_2016_addtocart').attr('data-gifting', this.checked || '');
  
      // tell cart buttons about the change
      $(document).trigger('cart_update');
    });
  
  
  
  
  

  
  
  
  
  
    // *******************************************
    // PUT CORRECT URLS IN EACH CART BUTTON
    // *******************************************
  
    function update_cart_urls(cart_selector){
  
      $(cart_selector).attr('href', function(){
        var lang = this.getAttribute('data-lang');
        var media = this.getAttribute('data-media');
        var lvl = this.getAttribute('data-lvl');
        var gifting = this.getAttribute('data-gifting');
  
        // var carturl = lang+'/'+media+'/'+lvl;
  
        var carturl = RSI({'cat':lang, 'media':media, 'lvl':lvl})[0].cart;
  
        // this is espanol catalog...
        try
        {
          carturl = carturl.replace('us_en_store_view', 'hispanic_store_view')
        }
        catch (e)
        {
  
        }
  
         // add or remove gifting as needed
        if(gifting){
          var separator = carturl.indexOf('?')>-1 ? '&' : '?';
          carturl += separator + 'gifting=1';
        }
        else{
          carturl = carturl.replace(/[?&]gifting=1/gi, '');
        }
  
        return carturl;
      });
    }
  
  
  
  
  
  
    // *******************************************
    // RESPOND TO CART UPDATE EVENT
    // *******************************************
  
    $(document).on('cart_update', function(){
      update_cart_urls('.js_oct_2016_addtocart');
    });
  
  
  
  
  
  
    // *******************************************
    // RESPOND TO PRICE UPDATE EVENT
    // *******************************************
  
    $(document).on('price_update', function(){
      update_prices('.js_oct_2016_price');
    });
  
  
  
  
  
  
    // *******************************************
    // RENDER CORRECT EXPERIENCE
    // *******************************************
  
    function render_experience(exp){
      if(exp===2 || exp==='2' || exp==='f'){
        render_experience_f();
      }
    }
  
    // experience f changes 1-month sub to 3-month sub
    function render_experience_f(){
  
      // change product title to 3-Month
      //document.querySelector('.oct_2016_product_square_header > span').innerHTML = '3-MES';
  
      // change multipay divisor to 3
      // $('.oct_2016_big_price_square[data-lvl="01"]').attr('data-multipay-divisor','3');
  
      // change 1m multipay duration to 3m
      $('.js_sub_duration_1m').html('3 months');
  
      // change data-lvl to "03"
      $('.js_oct_2016_product *[data-lvl="01"]').attr('data-lvl','03');
    }
  
  
  
  
  
  
    // *******************************************
    // SET CART BEHAVIOR BEFORE LANGUAGE IS SELECTED
    // *******************************************
  
    function set_up_pre_language(){
      $('.js_oct_2016_addtocart').html('Select Language').on('click',function(){
        smoothScrollTo('lang-menu');
        return false;
      });
    }
  
  
  
  
  
    // **********************************************************************
    // SMOOTH SCROLL
    // **********************************************************************
    function smoothScrollTo(scrolltargetid){
      var target = document.getElementById(scrolltargetid);
      if(target){
        $('html,body').animate({scrollTop : target.getBoundingClientRect().top + window.scrollY}, 'fast');
      }
    }
  
  
  
  
  
    // *****************************************************
    // BEST VALUE
    // *****************************************************
    function add_best_value(lvl){
      var $product_box = $('.js_oct_2016_price[data-lvl='+lvl+']').closest('.js_oct_2016_product');
      var $product_content = $('.js_oct_2016_price[data-lvl='+lvl+']').closest('.oct_2016_product_square_content');
  
      // $product_box.css({'border':'10px solid gold'});
      $product_content.prepend('<div class="oct_2016_best_value">MEJOR VALOR</div>');
    }
    add_best_value('24');
  
  
  
  
    // *****************************************************
    // CHANGE COPY FROM "ALL 5 LEVELS" TO "ALL LEVELS" (because of S3)
    // *****************************************************
    /*(function(){
      var levels_copy = 'Unlimited access to all levels for selected duration';
      var mobile_bullet = document.querySelector('.oct_2016_ul li');
      var desktop_bullet = document.querySelector('.js_nov_2016_online li');
      if(mobile_bullet){
        mobile_bullet.innerHTML = levels_copy;
      }
      if(desktop_bullet){
        desktop_bullet.innerHTML = levels_copy;
      }
    })();*/
  
  
  
  
  
    // *****************************************************
    // INITIALIZE PAGE
    // *****************************************************
    initPage(current_experience);
  
  
  
  
  
    // *****************************************************
    // UPDATE PAGE IF GIFTING IS TURNED ON (?gifting=1 in url)
    // *****************************************************
  
    // using a function instead of a variable to avoid worrying where it was declared
    function isGifting(){
      // check cached value first
      if(isGifting.val){
        return isGifting.val;
      }
      // if no cache, then look in url
      else if(window.location.search.match(/gifting=1/i)){
  
        // if found, store in cache to avoid rechecking url
        isGifting.val = true;
      }
      return !!isGifting.val;
    }
  
  
    if(isGifting()){
      // select and hide gifting
      $('.js_oct_2016_gifting, .js_nov_2016_gifting').click();
      $('.oct_2016_gifting_square, .nov_2016_gifting_square').hide();
  
  
      // change cta (note: this has been added on lang change only)
      // $('.js_oct_2016_addtocart, .js_nov_2016_addtocart').html('Give as a Gift');
  
      // change to gifting masthead
      (function(){
        var masthead_html = '<style type="text/css"> .gifting_2016_content{font-family: gothambook, helvetica, sans-serif;} .gifting_2016_masthead{ background-image: url(\'http://www.rosettastone.com/lp/spo/gifting_2016/img/gifting_2016_masthead_mobile.jpg\'); padding-top: 64.9%; background-size: cover; background-position: center; } @media(min-width: 450px){ .gifting_2016_masthead{ background-image: url(\'http://www.rosettastone.com/lp/spo/gifting_2016/img/gifting_2016_masthead_desktop.jpg\'); padding-top: 46%; } } @media(min-width: 780px){ .gifting_2016_masthead{ padding-top: 36%; } } @media(min-width: 1000px){ .gifting_2016_masthead{ padding-top: 30%; } } @media(min-width: 1200px){ .gifting_2016_masthead{ padding-top: 26.75%; } } .gifting_2016_intro{ margin: 20px auto; padding: 0px 10px; text-align: center; color: #333; } @media(min-width: 600px){ .gifting_2016_intro{ margin: 35px auto 30px; } } .gifting_2016_intro_col{ display: inline-block; vertical-align: middle; max-width: 550px; text-align: left; } .gifting_2016_title{ font-size: 20px; color: #0098db; } .gifting_2016_ul{ color: #0098db; list-style-type: disc; margin: 0px 20px; padding: 0px; font-size: 16px; line-height: 1.3; } .gifting_2016_ul li{ margin: 10px 0px; padding: 0px; } .gifting_2016_ul span{ color: #333; } .gifting_2016_mistletoe{ background-image: url(\'http://www.rosettastone.com/lp/spo/gifting_2016/img/gifting_2016_mistletoe.png\'); background-repeat: no-repeat; padding: 50px 20px; background-size: contain; background-position: center; max-width: 380px; text-align: center; vertical-align: middle; line-height: 1.3; font-size: 20px; display: none; } @media(min-width: 1000px){ .gifting_2016_mistletoe{ display: inline-block; } } </style> <div class="gifting_2016_content"> <div class="gifting_2016_masthead"></div> <div class="gifting_2016_intro"> <div class="gifting_2016_intro_col"> <div class="gifting_2016_title"> Here\'s why Rosetta&nbsp;Stone makes a fantastic&nbsp;gift: </div> <ul class="gifting_2016_ul"> <li><span><span class="toggle_bold">Proven to work.</span> Designed by linguists with 20+ years of experience, our award-winning course has been used successfully by millions of people worldwide. </span></li> <li><span><span class="toggle_bold">Never boring.</span> No dry translation or memorization. Our immersive and engaging program is easy to use and fun. </span></li> <li><span><span class="toggle_bold">Convenient.</span> They can learn anytime, anywhere and on any device (desktop, tablet, and mobile).15 minutes a day is all they need! </span></li> <li><span><span class="toggle_bold">Features no one else has.</span> With a proven curriculum, accent training technology, live native speaking tutors, and more, our complete program gives them everything they need to see success on their language journey. </span></li> </ul> </div> <div class="gifting_2016_mistletoe"> This holiday season, get them the language program that sparked a revolution. Gift them the world with Rosetta&nbsp;Stone. </div> </div> </div>';
        $('#masthead').hide().after(masthead_html);
      })();
  
      // change product description bullets for gifting
      (function(){
        var subscription_html = '<li>Everything they need to start speaking&mdash;from Day 1.</li> <li>Fun, immersive and engaging&mdash;they’ll never get bored.</li> <li>Perfect for their schedule&mdash;bite-sized lessons + mobile capability for ultimate convenience.</li> <li>A life changing experience&mdash;every day is an adventure with another language!</li>';
        var cddl_html = '<li>Course that never expires&mdash;Includes total course and bonus content (language games and online community)</li> <li>Access for up to 5 family members</li> <li>Live online tutoring sessions with a Native Speaker - 3-month trial included</li> <li>Access to award winning mobile app for 3-months - available on Kindle Fire HD, iOS, and Android</li> <li>Instant digital download or CD-ROM by mail</li>';
        $('.oct_2016_ul').eq(0).html(subscription_html);
        $('.nov_2016_ul').eq(0).html(subscription_html);
        $('.oct_2016_ul').eq(1).html(cddl_html);
        $('.nov_2016_ul').eq(1).html(cddl_html);
      })();
  
      // in case they ask to toggle bold parts in gifting intro
      (function(){
        var they_want_bold = true;
        if(they_want_bold){
          $('.toggle_bold').css({'font-family':'gothambold, gothambook, sans-serif'});
        }
      })();
  
  
      // gifting design changes requested by albert in ws-1610
      $('.nov_2016_product_intro, .oct_2016_product_intro').hide();
      $('.oct_2016_ul').css({'padding-left':'32px'});
    }
  
  
  
  
  
  
    // *****************************************************
    // SHOW USD FOR CANADA
    // *****************************************************
    (function(){
      var userFromCanada = /rosettastone\.ca/i.test(window.location.href) || /rosettastone\.ca/i.test(document.referrer) || /showUSD=true/i.test(document.cookie);
  
      function showUSD(){
        $('.oct_2016_big_price_square, .nov_2016_big_price_square').after('<span style="font-size: 20px;font-family: gothambold;bottom: 3px;position: relative;padding-left: 5px;">(USD)</span>');
      }
  
      if( userFromCanada ){
        showUSD();
      }
    })();
  
  
  
  
  
  });