Fri Oct 28 2016
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
var $normalexp;

function setNormalExp(){
	if(!$normalexp && $('#products').length){
		$normalexp = $('#products').children().detach();
	} 
}
 
$(function(){


var boxmarkup = '<div class=spo4_product><div class=g><h3 class=spo4_title>3 Month</h3><h4>Subscription</h4></div><span class=spo4_price><sup>$</sup><span class=monthly>26</span> </span><span class=spo4_sub style=font-size:1.3em;margin-top:0>Regular <span class=markoff><sup>$</sup><s>99</s></span></span><div class=g><a href="https://secure.rosettastone.com/us_en_store_view/checkout/cart/add/sku/24362/category_id/eng/?pc=amsterdam_S5">Add to Cart</a><form class=gift><label><img src=http://www.rosettastone.com/lp/catalogpages/img/gifting.png style=height:.8em;width:.8em;margin-right:.5em;position:relative;bottom:.05em><input style=margin-right:.5em type=checkbox>Give as a gift!</label></form></div></div>';



var cddlmarkup = '<div class=spo4_product><div class=g><h3 class=spo4_title>3 Month</h3><h4>Instant Download</h4></div><span class=spo4_price><sup>$</sup><span class=monthly>26</span></span> <span class=spo4_sub style=font-size:1.3em;margin-top:0>Regular <span class=markoff><sup>$</sup><s>99</s></span></span><div class=g><a href="https://secure.rosettastone.com/us_en_store_view/checkout/cart/add/sku/24362/category_id/eng/?pc=amsterdam_S5">Add to Cart</a><form class=gift><label><img src=http://www.rosettastone.com/lp/catalogpages/img/gifting.png style=height:.8em;width:.8em;margin-right:.5em;position:relative;bottom:.05em><input style=margin-right:.5em type=checkbox>Give as a gift!</label></form></div></div>';

var cdmarkup = '<div class="spo4_cdupsell"><p><img src="/assets/catalog16/cdicon.png" style="height: 1.5em; width: auto; position: relative; top: .33em; margin-right: .5em;">Or click here if you\'d like Rosetta Stone on CD-ROM or Instant Download</p></div>';



var upsellmarkup = '<div class=close>CLOSE</div><div class=cd_dl_overlay><div class=topcopy><figure></figure><section class=prodcopy><h2>Learn <span class=langname>Spanish</span></h2><h3>With Rosetta Stone<sup>®</sup></h3><img src=http://www.rosettastone.com/assets/stars.svg><span>(<a class=reviewlink href=/reviews><span itemprop=reviewCount>239</span> Reviews</a>)</span><p>If speaking French in the real world is your goal, you\'ve come to the right place. Our program lets you learn your second language the way you learned your first, with an intuitive, immersive method that\'s as fun to use as it is effective. There\'s also live interaction and real-time feedback to keep you making quick progress. And Rosetta Stone French is backed by over 20 years of success stories. Let\'s make yours the next one.<ul><li>Learn at your own pace with our course that never expires<li>Access for up to 5 family members<li>Speech Recognition<li>No internet connection required</ul></section></div><form class=cd_dl_select><label><input name=cd_dl_pick type=radio value=download checked><span>Instant Download</span></label><label><input name=cd_dl_pick type=radio value=box><span>CD-ROM Set</span></label></form><div class=insert_products></div><div class=guarantee></div></div>';


var spo_styles = '<style>.spo4_price sup,.spo4_product h3{font-family:GothamBold,sans-serif;font-size:1.5em}.spo4_product{display:flex;flex-flow:column nowrap;justify-content:space-around;align-items:center;margin:1.25em;width:15em;background-color:#fff;border:2px solid #ddd;padding:1em 1em .5em 1em;padding-bottom:1.75em;background-image:url(/assets/catalog16/corner_yellow.jpg);background-size:8em auto;background-position:top left;background-repeat:no-repeat;border-radius:3px}.spo4_product .g{align-items:center;display:flex;flex-flow:column}.spo4_product h3{font-size:1.33em;font-weight:700;margin-top:.5em;text-transform:uppercase}.spo4_product .g h4{text-transform:uppercase}.spo4_product .g:first-child::after{content:"";display:block;width:12em;height:1px;margin-top:1.5em;border-top:.15em solid #ccc}.spo4_price{margin-top:2em;margin-bottom:1em}.spo4_price sup{position:relative;top:-.5em;color:#0080cd}.spo4_price .monthly{font-family:GothamMedium,sans-serif;font-size:2.75em;color:#0080cd}.spo4_price span:nth-child(3){font-size:1.25em;font-family:GothamLight}.spo4_product a{font-family:GothamMedium,sans-serif;font-size:.93em;padding:.8em;width:10em;background:#0098db;border-radius:3px;color:#fff;text-decoration:none;text-transform:uppercase;text-align:center;margin-top:.5em}.spo4_product .gift{padding:.33em 0;font-family:GothamLight;vertical-align:middle;margin-top:.5em}.spo4_product .gift label{display:flex;flex-flow:row nowrap;justify-content:space-around;align-items:center}.spo4_sub{margin:1em 0;font-size:.75em;font-family:GothamLight}.spo4_sub s{color:red}.spo4_cdupsell{width:80%;max-width:50em;border:2px solid #ddd;padding:.65em;padding-bottom:1.45em;text-align:center;background-color:#fff;font-family:GothamBook;margin-top:3em;margin-bottom:6em;color:#0098db;cursor:pointer;background-image:url(/assets/catalog16/corner_gray.jpg);background-size:auto 1.5em;background-position:top left;background-repeat:no-repeat;border-radius:3px}.cdupselloverlay{display:flex;flex-flow:column nowrap;align-items:center;justify-content:center;overflow-y:auto}.cdupselloverlay .close{color:#fff;font-size:1.33em;width:70%;max-width:60em;text-align:right;box-sizing:border-box;font-family:GothamMedium;cursor:pointer;position:relative}.cdupselloverlay .close::before{content:"";display:inline-block;margin-right:.5em;width:1em;height:1em;background-image:url(/assets/catalog16/close_button.png);background-size:contain;background-repeat:no-repeat;background-position:center;position:relative;top:.1em}.cd_dl_overlay{font-size:.85em;background-color:#fff;width:70%;max-width:90em;padding:2em;display:flex;flex-flow:column;font-family:GothamLight}.cd_dl_overlay .topcopy{display:flex;flex-flow:row nowrap}.cd_dl_overlay .prodcopy{overflow-y:auto}.cd_dl_overlay .topcopy figure,.cd_dl_overlay .topcopy section{flex:1}.cd_dl_overlay .topcopy figure{background-image:url(/assets/catalog16/cddllockup.png);background-position:center;background-repeat:no-repeat;background-size:contain}.cd_dl_overlay .topcopy section h2{font-family:GothamLight,sans-serif;font-size:2em;color:#0098db}.cd_dl_overlay .topcopy section h3{font-family:GothamThin,sans-serif;font-size:3em;margin-bottom:.25em;line-height:1}.cd_dl_overlay .topcopy img{height:1em;width:auto}.cd_dl_overlay .topcopy p{margin-top:1em;line-height:1.5}.cd_dl_overlay .topcopy ul{margin-top:2em;line-height:1.33}.cd_dl_overlay .topcopy ul li{background:url(http://www.rosettastone.com/lp/catalog2015/spo2/check.png) left no-repeat;background-size:1.5em;padding-left:2.4em;list-style-type:none;text-align:left;font-size:.9em;margin-bottom:1em}.cd_dl_overlay form{align-self:center;margin:1em auto}.cd_dl_overlay .cd_dl_select input{display:none}.cd_dl_overlay form span{display:inline-block;background-color:#fff;color:#000;text-transform:uppercase;font-family:GothamMedium;border:1px solid #333;width:20em;text-align:center;padding:.5em}.cd_dl_overlay form input:checked+span{color:#fff;background-color:#000}.cd_dl_overlay .insert_products{display:flex;flex-flow:row nowrap;justify-content:center}#products .cd_dl_overlay{box-sizing:border-box;width:100%;max-width:100%;background-color:transparent;padding:3em 10em}#products .cd_dl_overlay figure{order:2;background-size:contain;background-image:url(/assets/catalog16/subs_lock.png);}#products .topcopy{justify-content:center}#products .cd_dl_overlay .prodcopy{font-size:1.3em;max-width:35em}#products .cd_dl_overlay .prodcopy sup{font-size:.5em;position:relative;bottom:.5em}#products .cd_dl_overlay .prodcopy p{font-family:GothamBook}#products .cd_dl_overlay .prodcopy ul{font-family:GothamBook;margin-left:2em}#products .insert_products{margin-top:1em}#products .spo4_product{width:20%;max-width:21em;font-size:1em}#products .spo4_cdupsell{font-size:1.25em;margin:3em auto 6em auto;padding:1em;padding-bottom:1.45em}</style>';
$('head').append($(spo_styles));


var spo_products = [
    {'lvl': '03', 'media': 'subscription'},
    {'lvl': '06', 'media': 'subscription'},
    {'lvl': '12', 'media': 'subscription'},
    {'lvl': '24', 'media': 'subscription'}
];

var monthly_index = {
    "03": 23,
    "06": 15,
    "12": 12,
    "24": 10
};



function getSubscriptionElements(lang) {
    return spo_products
        .map(function(v){ var q = v; v.cat = (lang || 'esp'); var inf = RSI(q); return inf.length ? inf[0] : null })
        .filter(function(v){ return v; })
        .map(function(v){
            var $el = $(boxmarkup);
            var islifetime = !!(v.lvl == 'lifetime');
            $el.find('.spo4_title').text( islifetime ? 'Lifetime' : parseInt(v.lvl, 10) + ' Month'  );
            //var monthlyprice = Math.ceil( ( parseFloat(v.price, 10)/12 ) * (12 / parseFloat(v.lvl, 10)) );
            var monthlyprice = v.price;
            $el.find('.spo4_price .monthly').text(monthlyprice);
            if(islifetime){
                $el.find('.spo4_price .monthly ~ span').remove();
                $el.find('.spo4_sub').text('One time payment');
            }
            else {
                $el.find('.spo4_full').text( v.price );
            }


            var $markoff = $el.find('.markoff');

            if(parseInt(v.msrp, 10) > parseInt(v.price, 10)){
                $markoff.find('s').text(v.msrp);
            }
            else {
                $markoff.closest('.spo4_sub').css('visibility','hidden');
            }

            $el.find('a').attr('href', v.cart);
            return $el;
        });
}


var cd_wash = {"L1":1,"S3":3,"S5":7};
function getDLElements(lang) {
    return RSI({family: "course", media: "download", cat: (lang || 'esp')})
        .filter(function(v){ return v.lvl in cd_wash })
        .sort(function(a,b){ return cd_wash[a.lvl] -  cd_wash[b.lvl] })
        .map(function(v){
            var $el = $(cddlmarkup);
            var titles = {"L1":"Level 1","S3":"Levels 1-3","S5":"Levels 1-5"};
            $el.find('.spo4_title').text( titles[v.lvl]  );
            $el.find('.spo4_price .monthly').text(v.price);
            $el.find('.markoff s').text(v.msrp);
            $el.find('a').attr('href', v.cart);
            return $el;
        });
}
//console.table(cd_elements)
function getCDElements(lang) {
    return RSI({family: "course", media: "box", cat: (lang || 'esp')})
        .filter(function(v){ return v.lvl in cd_wash })
        .sort(function(a,b){ return cd_wash[a.lvl] -  cd_wash[b.lvl] })
        .map(function(v){
            var $el = $(cddlmarkup);
            var titles = {"L1":"Level 1","S3":"Levels 1-3","S5":"Levels 1-5"};
            $el.find('.spo4_title').text( titles[v.lvl]  );
            $el.find('.spo4_price .monthly').text(v.price);
            $el.find('.markoff s').text(v.msrp);
            $el.find('h4').text('CD-ROM');
            $el.find('a').attr('href', v.cart);
            return $el;
        });
}


var $upselloverlay = $('<div class="cdupselloverlay" style="position: fixed; width: 100%; height: 100%; top: 0; left: 0; background-color: black; background-color: rgba(0,0,0,.7); z-index: 500;"></div>')

var $upsell = $(upsellmarkup);
$upselloverlay.append($upsell);
//$upsell.find('.insert_products').append(dl_elements);


function showCDDLOverlay(e) {
    lang = selectedLang || 'esp';
    $('body')
        .append($upselloverlay);
    $upsell.find('sup').css({'font-size': '.5em', 'position': 'relative', 'bottom': '.5em'});
    $upsell.find('.insert_products').empty();
    $upsell.find('.insert_products').append(getDLElements(lang));

    var langname = RSI({cat:lang,lvl:'24'})[0].language.replace(/\W\(.*/,'');
    $upsell.find('.langname').text(langname);
    var $copyp = $upsell.find('.prodcopy p');
    $copyp.text($copyp.text().replace(/French/g, langname));
    $('.cd_dl_select input[value="download"]').prop('checked', 1);
    $('.cd_dl_select input[value="box"]').removeProp('checked');
    $('.cd_dl_select').off('change');
    $('.cd_dl_select').on('change', function(e){ 
        var toswitch = e.target.getAttribute('value');

        $upsell.find('.insert_products').empty();
        $upsell.find('.insert_products').append(toswitch == 'box' ? getCDElements(lang) : getDLElements(lang));

    })
}

function closeCDDLOverlay() {
    $upselloverlay.remove();
}

$(document).on('click', '.cdupselloverlay', function(e){
   $(e.target).hasClass('cdupselloverlay') && closeCDDLOverlay();
});
$(document).on('click', '.cdupselloverlay .close', closeCDDLOverlay);
$(document).on('change', '.spo4_product .gift', function(e){
    var $el = $(e.target);
    var $a = $el.closest('.g').find('a');
    var crrt = $a.attr('href').replace('&gifting=1','');
    $a.attr( 'href', crrt.replace('&gifting=1','') );
    if(e.target.checked){
        crrt += '&gifting=1';
    }
    $a.attr( 'href', crrt);
});

$(document).on('click', '.spo4_cdupsell', showCDDLOverlay);

var _langselected = false;
var _setLanguageWrapped = setLanguageProducts;
setLanguageProducts = function(){
    //debugger;
    setNormalExp();
    if(arguments[0] in {fra:1,ita:1,deu:1,esp:1,esc:1}){
        _setTestProducts(arguments[0]);
    }
    else {
        $('#products').empty();
        $normalexp.appendTo('#products');
        $('.buynow').off('click');
        $('.buynow').on('click', AttachToBuyNow);
    }
    !_langselected && $('#products .topcopy').slideDown(); 
    _langselected = true;
     
    return _setLanguageWrapped.apply(this, arguments); 
}


function _setTestProducts(lang){
    var $mainprods = $(Array.prototype.slice.call($upsell.clone()).pop());
    $mainprods.find('.close').remove();
    $mainprods.find('.cd_dl_select').remove();
    $('#products').empty();
    $('#products').append($mainprods);
    var langname = RSI({cat:lang,lvl:'24'})[0].language.replace(/\W\(.*/,'');
    $mainprods.find('.langname').text(langname);
    var $copyp = $mainprods.find('.prodcopy p');
    $copyp.text($copyp.text().replace(/French/g, langname));
    $mainprods.find('.prodcopy li').each(function(i,v){
        var lis = [
        'Unlimited access to all 5 levels for selected duration',
        'Speech Recognition',
        'Learn anywhere on any device including use of our award-winning mobile app'
        ];
        var $v = $(v);
        if(i >= lis.length){
            $v.remove();
        }
        else {
            $v.text(lis[i]);
        }
    });
    !_langselected && $mainprods.find('.topcopy').css('display','none');

    var subs = getSubscriptionElements(lang);
    $mainprods.find('.insert_products').empty();
    $mainprods.find('.insert_products').append(subs);
    $mainprods.append(cdmarkup);

}
function pickLangIntercept(e){
    $('html, body').animate({scrollTop: 400}, 500);
    e.preventDefault(); return false;
}

//SETUP
$(function(){
    setNormalExp();
   _setTestProducts(_satellite.getQueryParam('lang') || 'esp');
    !_satellite.getQueryParam('lang') && $('#products .g a').text('SELECT LANGUAGE');
    !_satellite.getQueryParam('lang') && $('#products .spo4_product, #products .spo4_cdupsell').on('click', pickLangIntercept);
    	
})

});



function AttachToBuyNow(e) {
  e.preventDefault()
  var checked = $(this).parents('.product-form').find('.product-pricing input:checked')
  var carturl = checked.data('carturl')
  var lvl = checked.data('lvl')
  var error = false

  if ($(this).parents('.product-form').find('.cdbackup input').is(':checked')) {
    var cdproduct = jQuery.grep(shimskus, function( e, i ) {
      return ( e.cat == selectedLang.toUpperCase() && e.lvl == lvl + 'CD' );
    });
    

    if (cdproduct && cdproduct.length == 1) {
      
   
      var split = carturl.toLowerCase().split('category_id/'+selectedLang.toLowerCase())
     
      split.splice(1,0, 'category_id/' + selectedLang + '/related_sku/' + cdproduct[0].sku)
      
      carturl = split.join('')
    }
  }

  if ( $(this).parents('.product-form').find('.gifting input').is(':checked') ) {
    carturl += (~carturl.indexOf('?') ? '&' : '?') + 'gifting=1'
    
  }


  // Scroll up to select lang dropdown if no lang is selected
  if ($(this).hasClass('mobileButton')) {
    if($(this).text() != "ADD TO CART") {
        var error = true
        $('html, body').animate({
          scrollTop: $('#products-mobile').offset().top
        }, 500);
    }
  
  }

  // In Desktop, scroll and show langs if user tried to add
  // to cart without having a language selected
  if($langMenu.css('display') == "block") {
    var error = true
    $(this).attr('href',"#lang-menu");
    $('html, body').animate({scrollTop: $( $.attr(this, 'href') ).offset().top}, 500);
  }


  if (error == false) {
    window.location.href = carturl
  }





}