Mon Oct 30 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
  • 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
  • 694
  • 695
  • 696
  • 697
  • 698
  • 699
  • 700
  • 701
  • 702
  • 703
  • 704
  • 705
  • 706
  • 707
  • 708
  • 709
  • 710
  • 711
  • 712
  • 713
  • 714
  • 715
  • 716
  • 717
  • 718
  • 719
  • 720
  • 721
  • 722
  • 723
  • 724
  • 725
  • 726
  • 727
  • 728
  • 729
  • 730
  • 731
  • 732
  • 733
  • 734
  • 735
  • 736
  • 737
  • 738
  • 739
  • 740
  • 741
  • 742
  • 743
  • 744
  • 745
  • 746
  • 747
  • 748
  • 749
  • 750
  • 751
  • 752
  • 753
  • 754
  • 755
  • 756
  • 757
  • 758
  • 759
  • 760
  • 761
  • 762
  • 763
  • 764
  • 765
  • 766
  • 767
  • 768
  • 769
  • 770
  • 771
  • 772
  • 773
  • 774
  • 775
  • 776
  • 777
  • 778
  • 779
  • 780
  • 781
  • 782
  • 783
  • 784
  • 785
  • 786
  • 787
  • 788
  • 789
  • 790
  • 791
  • 792
  • 793
  • 794
  • 795
  • 796
  • 797
  • 798
  • 799
  • 800
  • 801
  • 802
  • 803
  • 804
  • 805
  • 806
  • 807
  • 808
  • 809
  • 810
  • 811
  • 812
  • 813
  • 814
  • 815
  • 816
  • 817
  • 818
  • 819
  • 820
  • 821
  • 822
  • 823
  • 824
  • 825
  • 826
  • 827
  • 828
  • 829
  • 830
  • 831
  • 832
  • 833
  • 834
  • 835
  • 836
  • 837
  • 838
  • 839
  • 840
  • 841
  • 842
  • 843
  • 844
  • 845
  • 846
  • 847
  • 848
  • 849
  • 850
  • 851
  • 852
  • 853
  • 854
  • 855
  • 856
  • 857
  • 858
  • 859
  • 860
  • 861
  • 862
  • 863
  • 864
  • 865
  • 866
  • 867
  • 868
  • 869
  • 870
  • 871
  • 872
  • 873
  • 874
  • 875
  • 876
  • 877
  • 878
  • 879
  • 880
  • 881
  • 882
  • 883
  • 884
  • 885
  • 886
  • 887
  • 888
  • 889
  • 890
  • 891
  • 892
  • 893
  • 894
  • 895
  • 896
  • 897
  • 898
  • 899
  • 900
  • 901
  • 902
  • 903
  • 904
  • 905
  • 906
  • 907
  • 908
  • 909
  • 910
  • 911
  • 912
  • 913
  • 914
  • 915
  • 916
  • 917
  • 918
  • 919
  • 920
  • 921
  • 922
  • 923
  • 924
  • 925
  • 926
  • 927
  • 928
  • 929
  • 930
  • 931
  • 932
  • 933
  • 934
  • 935
  • 936
  • 937
  • 938
  • 939
  • 940
  • 941
  • 942
  • 943
  • 944
  • 945
  • 946
  • 947
  • 948
  • 949
  • 950
  • 951
  • 952
  • 953
  • 954
  • 955
  • 956
  • 957
  • 958
  • 959
  • 960
  • 961
  • 962
  • 963
  • 964
  • 965
  • 966
  • 967
  • 968
  • 969
  • 970
  • 971
  • 972
  • 973
  • 974
  • 975
  • 976
  • 977
  • 978
  • 979
  • 980
  • 981
  • 982
  • 983
  • 984
  • 985
  • 986
  • 987
  • 988
  • 989
  • 990
  • 991
  • 992
  • 993
  • 994
  • 995
  • 996
  • 997
  • 998
  • 999
  • 1000
  • 1001
  • 1002
  • 1003
  • 1004
  • 1005
  • 1006
  • 1007
  • 1008
  • 1009
  • 1010
  • 1011
  • 1012
  • 1013
  • 1014
  • 1015
  • 1016
  • 1017
  • 1018
  • 1019
  • 1020
  • 1021
  • 1022
  • 1023
  • 1024
  • 1025
  • 1026
  • 1027
  • 1028
  • 1029
  • 1030
  • 1031
  • 1032
  • 1033
  • 1034
  • 1035
  • 1036
  • 1037
  • 1038
  • 1039
  • 1040
  • 1041
  • 1042
  • 1043
  • 1044
  • 1045
  • 1046
  • 1047
  • 1048
  • 1049
  • 1050
  • 1051
  • 1052
  • 1053
  • 1054
  • 1055
  • 1056
  • 1057
  • 1058
  • 1059
  • 1060
  • 1061
  • 1062
  • 1063
  • 1064
  • 1065
  • 1066
  • 1067
  • 1068
  • 1069
  • 1070
  • 1071
  • 1072
  • 1073
  • 1074
  • 1075
  • 1076
  • 1077
  • 1078
  • 1079
  • 1080
  • 1081
  • 1082
  • 1083
  • 1084
  • 1085
  • 1086
  • 1087
  • 1088
  • 1089
  • 1090
  • 1091
  • 1092
  • 1093
  • 1094
  • 1095
  • 1096
  • 1097
  • 1098
  • 1099
  • 1100
  • 1101
  • 1102
  • 1103
  • 1104
  • 1105
  • 1106
  • 1107
  • 1108
  • 1109
  • 1110
  • 1111
  • 1112
  • 1113
  • 1114
  • 1115
  • 1116
  • 1117
  • 1118
  • 1119
  • 1120
  • 1121
  • 1122
  • 1123
  • 1124
  • 1125
  • 1126
  • 1127
  • 1128
  • 1129
  • 1130
  • 1131
  • 1132
  • 1133
  • 1134
  • 1135
  • 1136
  • 1137
  • 1138
  • 1139
  • 1140
  • 1141
  • 1142
  • 1143
  • 1144
  • 1145
  • 1146
  • 1147
  • 1148
  • 1149
  • 1150
  • 1151
  • 1152
  • 1153
  • 1154
  • 1155
  • 1156
  • 1157
  • 1158
  • 1159
  • 1160
  • 1161
  • 1162
  • 1163
  • 1164
  • 1165
  • 1166
  • 1167
  • 1168
  • 1169
  • 1170
  • 1171
  • 1172
  • 1173
  • 1174
  • 1175
  • 1176
  • 1177
  • 1178
  • 1179
  • 1180
  • 1181
  • 1182
  • 1183
  • 1184
  • 1185
  • 1186
  • 1187
  • 1188
  • 1189
  • 1190
  • 1191
  • 1192
  • 1193
  • 1194
  • 1195
  • 1196
  • 1197
  • 1198
  • 1199
  • 1200
  • 1201
  • 1202
  • 1203
  • 1204
  • 1205
  • 1206
  • 1207
  • 1208
  • 1209
  • 1210
  • 1211
  • 1212
  • 1213
  • 1214
  • 1215
  • 1216
  • 1217
  • 1218
  • 1219
  • 1220
  • 1221
  • 1222
  • 1223
  • 1224
  • 1225
  • 1226
  • 1227
  • 1228
  • 1229
  • 1230
  • 1231
  • 1232
  • 1233
  • 1234
  • 1235
  • 1236
  • 1237
  • 1238
  • 1239
  • 1240
  • 1241
  • 1242
  • 1243
  • 1244
  • 1245
  • 1246
  • 1247
  • 1248
  • 1249
  • 1250
  • 1251
  • 1252
  • 1253
  • 1254
  • 1255
  • 1256
  • 1257
  • 1258
  • 1259
  • 1260
// test: hide cddl - lp/sbsr
        $(function () {


            // comparison chart functionality

            function open_comparison_chart() {
                $('.comparison_chart_container').fadeIn();
                $('.comparison_table_container').focus();
            }

            function close_comparison_chart() {
                $('.comparison_chart_container').fadeOut();
            }

            $('.js_open_comparison_chart').on('click', function () {
                open_comparison_chart();
            });

            $('.js_close_comparison_chart').on('click', function () {
                close_comparison_chart();
            });
            $(document).on('keydown', function (e) {
                if (e.keyCode === 27) {
                    close_comparison_chart();
                }
            });

            // end comparison chart functionality

            // start cd|dl
            //$('.rs_classic').append(cd_close);
           // $('.meclabs_cd_close').on('click', hide_cd_section);
            // end cd| dl








            $('.js_cddl_test_toggle').on('click', function () {
                var tab = $(this).attr('data-productmix');

                var media;

                if (tab === 'online') {
                    media = 'subscription';

                    $('.js_nov_2016_online, .mobile-online-desc').show();

                    $('.js_nov_2016_cddl, .mobile-cd-desc').hide();
                } else {
                    media = $('input[name=nov_2016_cddl_toggle]:checked').attr('data-media');

                    $('.js_nov_2016_online, .mobile-online-desc').hide();
                    $('.js_nov_2016_cddl, .mobile-cd-desc').show();
                }

                $(document).trigger('product_change', {
                    'media': media
                });

                return false;
            });
        });
    </script>

    <!-- mobile and desktop product updates nov 16, 2016 -->
    <!-- <script src="../js/products_mobile.js"></script> -->
    <script src="../js/products.js"></script>


    <!-- <script src="../js/0rs.js" ></script> -->
    <script src="../js/main_module.js"></script>
    <script src="../js/clock.js"></script>
    <script src='../js/crescendo.js'></script> <!-- crescendo needs to be after clock in order to have access to clock -->
    <!-- <script src='../../globals/scripts/global.js'></script> -->    
    <script src="//connect.facebook.net/en_US/all.js"></script>
    <!--**********************************************************
    FACEBOOK LOGIN
    ***********************************************************-->
    <script type="text/javascript">
        $(document).ready(function () {
            // DEMO: FACEBOOK LOGIN
            FB.init({
                /*appId: rs.fbappid, "1091422140883673" */
                appId: "1091422140883673",
                status: true,
                cookie: true,
                xfbml: true,
                oauth: true,
                channelUrl: window.location.protocol + "//" + window.location.hostname + "/facebook/channel"
            });


            // unverified
            $('#facebook img').click(function () {
                FB.login(function (response) {
                    if (response.authResponse) {
                        FB.api("/me", function (me) {
                            if (me.email) {
                                var myemail = me.email;


                                s.addEvent ? s.addEvent("event21") : (function (s) { s.events = "event21"; })(s);
                                s.tl();
                                s.events = "";
                                RSUI.util.setCookie("curEmailIdsc", myemail);
                                submitEmailToEC(myemail, demoLang);
                            } else {

                                s.addEvent ? s.addEvent("event22") : (function (s) { s.events = "event22"; })(s);
                                s.tl();
                                s.events = "";
                            }
                        })
                    }
                });
            });
        });


$(document).ready(function () {

            // ***************************************
            // live mocha lightbox
            // ***************************************

            /* open/close live-mocha lightbox */
            $(".live-mocha-expose-mask, .lightbox-close").click(function () {
                $("#live-mocha-lightbox").removeClass('show')
            });
            $(document).keyup(function (e) {
                if (e.keyCode == 27) {
                    $("#live-mocha-lightbox").removeClass('show');
                }
            });

            function parameterExists(param) {
                var reg = new RegExp('[?&]' + param + '=', 'i');
                return !!window.location.search.match(reg);
            }

            function getParameter(param) {
                var reg = new RegExp('[?&]' + param + '=([^&]+)', 'i');
                return parameterExists(param) ? window.location.search.match(reg).pop() : '';
            }
            // ?prid=livemocha.com livemocha.net livemocha.org
            if (/livemocha.com|livemocha.org|livemocha.net/.test(getParameter('prid'))) {
                $("#live-mocha-lightbox").addClass('show');
            }

            /* Language drop down */
            function updateLanguageEquivalentURL(currentURL, element) {
                if (currentURL.match(/sbsr/)) {
                    element.attr('href', currentURL.replace('sbsr', 'sbsr-es') + "?lang_rd=0")
                }
            }

            var $site_lang_button = $('#site-language-button');
            updateLanguageEquivalentURL(window.location.pathname, $site_lang_button);


            // *************************************
            // hide mobile call button when liveperson chat button appears (I've pasted and refactored a bit)
            // *************************************
            if(!isDesktop){
                var $chatDiv = $('#mobile-chat');                           
                function hideCallButton(){
                    if( !isEmpty($chatDiv) ){
                        $('.topbar_call_button').css({"visibility":"hidden","width": "1px"});
                        $('#mobile-chat').css({"margin-right":"-10px"});
                    }else{
                        $('.topbar_call_button').css({"visibility":"visible","width": "auto"});
                        $('#mobile-chat').css({"margin-right":"10px"});                        
                    }
                }
                function isEmpty( element ){
                    return element.innerHTML == "";
                }
                setInterval(hideCallButton, 3500);
            }

        });


(function(){
		var styl = '\n<style id="lang_select_styles">\n    \n\n    /* CD Offering */\n\n    .oct_2016_gold_bg .oct_2016_product_square_header {\n        display: none;\n    }\n\n    .oct_2016_price_container_square_cddl {\n        margin-top: 0;\n    }\n    \n    \n\n    .oct_2016_gold_bg .oct_2016_msrp_square {\n        display: inline-block;\n    }\n\n    .oct_2016_gold_bg .oct_2016_big_price_square {\n        font-size: 31px;\n        vertical-align: baseline;\n        color: black;\n\n        font-family: gothambook;\n        display: inline-block;\n\n        margin-left: .2em;\n    }\n\n    .oct_2016_gold_bg .oct_2016_msrp_square {\n        margin-bottom: 0;\n        vertical-align: middle;\n    }\n    .oct_2016_gold_bg .oct_2016_price_container_square_cddl {\n       display: inline-block;\n    }\n\n    .oct_2016_product_square_middle {\n        padding: .5rem 1.5rem .5rem 1.5rem;\n    }\n\n    .oct_2016_language_subhead {\n        display: none;\n    }\n\n    .oct_2016_container.oct_2016_gold_bg .comparison_chart_link {\n        display: none;\n    }\n\n    .oct_2016_gold_bg .oct_2016_addtocart_square {\n        margin: 0;\n    }\n\n    @media (min-width: 600px){\n\n        .oct_2016_product_square_content {\n            padding: 0;\n        }\n    }\n\n    .oct_2016_cd_download_container label {\n        font-size: 13px;\n    }\n\n    .oct_2016_product_square {\n        width: 260px;\n    }\n\n    @media (min-width: 560px) {\n        .oct_2016_cd_download_buttons {\n            width: 260px;\n        }\n    }\n    \n</style>';

		$('body').append(styl);

		//Download/CD offering:
		//adjust headings
		$('.meclabs_cd_title').html('<div class="oct_2016_language_header"> Learn <span class="js_langname_1">a language.</span></div>');
		$('.oct_2016_gold_bg .oct_2016_product_square:eq(0)').css('display', 'none');
		//pare down select elements
		$('label[for="oct_2016_download"]').text('download');
		$('label[for="oct_2016_cd"]').text('cd-rom');
		//swap price/description positions
		$('.oct_2016_gold_bg .oct_2016_big_price_square').each(function (i, el) {
			var $el = $(el).parent();var $span = $el.next();$el.detach();$span.after($el);
		});
		//Hide 3-month box when a language with a 5-month option is selected
		var $lthreebox = $('.oct_2016_gold_bg .oct_2016_product_square:eq(1)');
		$lthreebox.css('display', 'none');
		var $lfivebox = $('.oct_2016_gold_bg .oct_2016_product_square:eq(2)');
		$(document).on('lang_change', function (ev, data) {
			var cddl_count = RSI({ cat: data.lang, lvl: 'S5' }).length;
			var topbox = cddl_count && cddl_count > 0 ? $lfivebox : $lthreebox;
			return $lthreebox.css('display', topbox == $lfivebox ? 'none' : 'inline-block');
		});

		function msrpShow() {
			//Hide comparison if no promo
			if ($('.oct_2016_gold_bg [data-is-msrp="true"][data-lvl="S5"]').first().text() == $('.oct_2016_gold_bg .js_product_boxes_desktop .oct_2016_price_container_square_cddl > .js_cddl_media.js_oct_2016_price[data-lvl="S5"]').first().text()) {
				$('.oct_2016_gold_bg .oct_2016_msrp_square').css('display', 'none');
			}
			else {
				$('.oct_2016_gold_bg .oct_2016_msrp_square').css('display', 'inline-block');
			}
		}
		
		setTimeout(msrpShow, 1000);
		$(document).on('price_change', msrpShow);
		
		$('.oct_2016_gold_bg .oct_2016_guarantee_vertical').css('display','none');
	 })();






// SPO3 updates muck up the readability of this file.
// SETS VARIABLES

var $lightboxDemo = $('#lightbox-demo');
var $buttonList = $('#cdButton, #downloadButton, #subscriptionButton');
var $langMenu = $('#lang-menu');
var $langHeader = $('#selected-lang');
var $mobileContainer = $('#selected-lang, #lang-menu');
var container = $("#lightBoxInner");
var cButton = $('#compareButton');
var lButton = $('#learnButton');
var dButton = $('.container .demo div');
var hiwButton = $('#howitworks');
var originalHeight = {'min-height' : $lightboxDemo.css('min-height'),'height' : $lightboxDemo.css('height')};
var cdArr = [['#cdListMobile','cdM'],['.cdListIpad'],['#cdList','cd']];
var dlArr = [['#downloadListMobile','dlM'],['.downloadListIpad'], ['#downloadList','dl']];
var subArr = [['#subscriptionListMobile','subM'],['#subscriptionList','sub']];
var secure = /https:\/\/secure.rosettastone.com\/us_en_store_view\/checkout\/cart\/add\/sku/;
var selectedLang = '';
var demoLang = 'en-es';
var email = '';
var S3 = /S3|24/;
var S5 = /S5|24/;
var desiredProducts = function(){ return RSI({cat:selectedLang,lvl:'S5'}).length ? S5 : S3; };
var tViewcd = "";
var tViewdl = "";
var mViewdl = "";
var mViewcd = "";
var mViews = "";

isDesktop = (function() {
  if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
    return false
  }else{
    return true
  }
})();


// SETS LANGUAGE + POPULATES LISTS WITH NORMALIZED PRODUCTS

$('.language-buy-list li a').click(function changeLanguage(){
  // sets language + products
  selectedLang = $(this).attr('id');
  setLanguageProducts(selectedLang);
  // configures headers + buttons content
  $langMenu.slideUp('slow');
  $langHeader.slideDown('slow');
  $('.lang-mob').trigger('click')
  $("#dropdown-language").val(selectedLang).change();
  $('#your-lang span').text("Learn " + RSI({cat:selectedLang,media:'download'})[0].language);
  $buttonList.addClass('buynow').text("ADD TO CART");
  $('#mobileButton').text("ADD TO CART");
  // sets demo language
  var demoLangSet = {"deu":"en-de", "fra":"en-fr", "esp" :"en-es", "ita" :"en-it" , "eng" :"en-en"};
  if(demoLangSet[selectedLang] != undefined){demoLang = demoLangSet[selectedLang];}
  if(priceIsMsrp){$('.strike').remove()}
});


// FETCHES + ORGANIZES + OUTPUTS RSI PRODUCTS

function setLanguageProducts(someLang){
  var blvls = [];
  var dloadlvls = [];
  var slvls = [];
  // clears current product lists
  $('#cdList, #subscriptionList, #downloadList, select.cdListIpad, select.downloadListIpad, #cdListMobile, #subscriptionListMobile, #downloadListMobile').html("");
  // creates ordered arrays of products by media type
  for(var i = 0; i < RSI({cat:someLang}).length; i++){
    setProductArrays(someLang, blvls, 'box',i);
    setProductArrays(someLang, dloadlvls, 'download',i);
    setProductArrays(someLang, slvls, 'subscription',i);
  }
  // normalizes and prepends products to lists
  populateLanguageProducts(blvls, cdArr);
  populateLanguageProducts(slvls, subArr);
  populateLanguageProducts(dloadlvls, dlArr);
  tmView();
}


// CREATES ORDERED ARRAYS OF PRODUCTS BY MEDIA TYPE

function setProductArrays(langClicked,xlvls,mediaType,i){
  var langSet = RSI({cat:langClicked});
  if(langSet[i].media == mediaType){
    if(desiredProducts().test(langSet[i].lvl)){
      xlvls.push(langSet[i])
      xlvls.sort(function(a,b) {
        if (a.lvl < b.lvl){
          return 1;
        }else if(a.lvl > b.lvl){
          return -1;
        }else{
          return 0;
        }
      });
    }
  }
}


// NORMALIZES + PREPENDS PRODUCTS TO VARIOUS LISTS

function populateLanguageProducts(ylvls, mediaList){
  // normalize product name
  // concatenate each product to string, prepend to master string
  // sets default products for lightboxes
  // auto selects first product in lists
  var mOptions = "";
  var tOptions = "";
  var dOptions = "";
  for(var y = 0; y < ylvls.length; y++){
    var productName = ylvls[y].name;
    var prodNameSet = {
      "Levels 1, 2, 3, 4 & 5":"Level 1-5",
      "Levels 1-5 Instant Download":"Level 1-5",
      "Levels 1, 2 & 3":"Level 1-3",
      "Levels 1-3 Instant Download":"Level 1-3",
      "24-Month Online Subscription":"24 Month"
    };
    // normalizes name
    if(prodNameSet[productName] != undefined){productName = prodNameSet[productName];}
    // sorts products into lists for each device a user is using.
    for(var z = 0; z < mediaList.length; z++){
      // mobile
      if(/Mobile/.test(mediaList[z][0])){
        mOptions +=
          '<div class="prod-options"><label><input id="' +
          ylvls[y].media + '_' + ylvls[y].lvl.toLowerCase() +
          '" type="radio" name="' +
          mediaList[z][1] +
          '" value="' +
          ylvls[y].cart + '"><span> ' +
          productName +
          '</span><div class="strikethru"><div class="strike"><del>$' +
          ylvls[y].msrp +
          '</del> |</div><div class="sale">$' +
          ylvls[y].price +
          '</div></div></label></div>'
        ;
        var gOption = "<div style='text-align: center;padding-top: 15px;'><input id='" + ylvls[y].media + "Mobilegift' type='checkbox' autocomplete='off'><span style='vertical-align:text-bottom; padding-left: 25px;background: url(\"//www.rosettastone.com/lp/catalogpages/img/gifting.png\") no-repeat left;background-size: contain;background-position-x: 5px;font-family: gothamlight;color: #656565;font-size: 13px;'>Give as a gift!</span></div>";

        if(ylvls[y].media == 'subscription'){
          mViews = gOption +
            '<div class="strikethru">' +
            '<div class="strike"><del>$' + ylvls[y].msrp + '</del>'+
            '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEElEQVQIW2NcycDwnxFEAAAPpwNTfkl0/wAAAABJRU5ErkJggg==" style="height: 2px;width: 100%;margin: -65% 0 0;">' +
            '</div>' +
            '<div class="sale">$' + ylvls[y].price + '</div>' +
            '</div>' +
            '<input style="display:none;" id="' + ylvls[y].media + '_' + ylvls[y].lvl.toLowerCase() +
            '" type="radio" name="' + mediaList[z][1] + '" value="' + ylvls[y].cart + '" checked> '
          ;
        }
        if(ylvls[y].media == 'box'){
          mViewcd = gOption +
            '<div class="strikethru">' +
            '<div class="strike"><del>$' + ylvls[y].msrp + '</del>'+
            '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEElEQVQIW2NcycDwnxFEAAAPpwNTfkl0/wAAAABJRU5ErkJggg==" style="height: 2px;width: 100%;margin: -65% 0 0;">' +
            '</div>' +
            '<div class="sale">$' + ylvls[y].price + '</div>' +
            '</div>' +
            '<input style="display:none;" id="' + ylvls[y].media + '_' + ylvls[y].lvl.toLowerCase() +
            '" type="radio" name="' + mediaList[z][1] + '" value="' + ylvls[y].cart + '" checked> '
          ;
        }
        if(ylvls[y].media == 'download'){
          mViewdl = gOption +
            '<div class="strikethru">' +
            '<div class="strike"><del>$' + ylvls[y].msrp + '</del>' +
            '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEElEQVQIW2NcycDwnxFEAAAPpwNTfkl0/wAAAABJRU5ErkJggg==" style="height: 2px;width: 100%;margin: -65% 0 0;">' +
            '</div>' +
            '<div class="sale">$' + ylvls[y].price + '</div>' +
            '</div>' +
            '<input style="display:none;" id="' + ylvls[y].media + '_' + ylvls[y].lvl.toLowerCase() +
            '" type="radio" name="' + mediaList[z][1] + '" value="' + ylvls[y].cart + '" checked> '
          ;
        }
      // tablet
      }else if(/Ipad/.test(mediaList[z][0])){
        tOptions +=
          '<option value="' +
          ylvls[y].cart +
          '" data-sku="' +
          ylvls[y].sku +
          '" data-level="' +
          ylvls[y].lvl +
          '" data-sprice="' +
          ylvls[y].price +
          '" data-rprice="' +
          ylvls[y].msrp +
          '" data-code="' +
          ylvls[y].code +
          '" class="prod-cd">' +
          productName +
          ' $' +
          ylvls[y].price +
          '</option>'
        ;
        var gOption = "<div style='text-align: center;padding-top: 15px;'><input id='" + (ylvls[y].media == 'box' ? "cd" : ylvls[y].media ) + "Tabletgift' type='checkbox' autocomplete='off'><span style='padding-left: 25px;background: url(\"//www.rosettastone.com/lp/catalogpages/img/gifting.png\") no-repeat left;background-size: contain;background-position-x: 5px;font-family: gothamlight;color: #656565;font-size: 13px; vertical-align:text-bottom;'>Give as a gift!</span></div>";
        if(ylvls[y].media == 'box'){
          tViewcd = gOption +
            '<div class="strikethru">' +
            '<div class="strike"><del>$' + ylvls[y].msrp + '</del>' +
            '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEElEQVQIW2NcycDwnxFEAAAPpwNTfkl0/wAAAABJRU5ErkJggg==" style="height: 2px;width: 100%;margin: -30% 0 0;">' +
            '</div>' +
            '<div class="sale">$' + ylvls[y].price + '</div>' +
            '</div>'
          ;
        }
        if(ylvls[y].media == 'download'){
          tViewdl = gOption +
            '<div class="strikethru">' +
            '<div class="strike"><del>$' + ylvls[y].msrp + '</del>' +
            '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEElEQVQIW2NcycDwnxFEAAAPpwNTfkl0/wAAAABJRU5ErkJggg==" style="height: 2px;width: 100%;margin: -30% 0 0;">' +
            '</div>' +
            '<div class="sale">$' + ylvls[y].price + '</div>' +
            '</div>'
          ;
        }
      // desktop
      }else{

        dOptions +=
          "<div style='text-align: center;padding-top: 15px;'><input id='" + (ylvls[y].media == 'box' ? "cd" : ylvls[y].media ) +
          "gift' type='checkbox' autocomplete='off'><span style='padding-left: 25px;background: url(\"//www.rosettastone.com/lp/catalogpages/img/gifting.png\") no-repeat left;background-size: contain;background-position-x: 5px;font-family: gothamlight;color: #656565;font-size: 13px;'>Give as a gift!</span></div>" +
          '<div class="options"><label><input id="' +
          ylvls[y].media + '_' + ylvls[y].lvl.toLowerCase() + '" type="radio" name="' +
          mediaList[z][1] + '" value="' +
          ylvls[y].cart + '"> ' +
          productName + '<span></span></label>' +
          '<div class="strikethru">' +
          '<div class="strike"><del>$' + ylvls[y].msrp + '</del>' +
          '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEElEQVQIW2NcycDwnxFEAAAPpwNTfkl0/wAAAABJRU5ErkJggg==" style="height: 2px;width: 100%;margin: -0.75em 0 0;">' +
          '</div>'+
          '<div class="sale">$' + ylvls[y].price + '</div>' +
          '</div></div></div>'
        ;
      }
    }
    // sets default product for lightboxes
    if( typeof mediaList[2] != 'undefined' && mediaList[2][1] == 'dl' && y == ylvls.length - 1){
      if(ylvls[y].cat == 'eng' || ylvls[y].cat == 'fra' || ylvls[y].cat == 'esp' || ylvls[y].cat == 'deu' || ylvls[y].cat == 'ita'){
        $('#dropdown span').html(ylvls[y].language);
      }
    }
  }

  // prepends products to proper lists
  for(var z = 0; z < mediaList.length; z++){
    var type = mediaList[z][0];
    var option = /Mobile/.test(type) ? mOptions : /Ipad/.test(type) ? tOptions : dOptions;
    $(type).prepend(option);
  }


  // auto selects first list item
  $('.downloadListIpad').val($('.downloadListIpad option:first').val()).trigger('change');
  $('.cdListIpad').val($('.cdListIpad option:first').val()).trigger('change');
  $('#cdListMobile, #subscriptionListMobile, #downloadListMobile, #cdList, #downloadList, #subscriptionList').find('input[type=radio]:first').trigger('click');
}


// new view for ipad/iphone products (spo3 update)
function tmView(){
  $('#cdViewIpad').html(tViewcd);
  $('#downloadViewIpad').html(tViewdl);
  $('#downloadListMobile').html(mViewdl);
  $("#subscriptionListMobile").html(mViews);
  $('#cdListMobile').html(mViewcd);
}

// LANGUAGE SELECTION: DESKTOP + TABLET

$('#your-lang button').click(function langSelection(){
  $langHeader.slideUp('slow');
  $langMenu.slideDown('slow');
  $buttonList.removeClass('buynow').text("SELECT A LANGUAGE");
})


// LANGUAGE SELECTION: MOBILE

$('.lang-mob').click(function langSelectionM(e){
  e.preventDefault();
  $('.select-holder').css('display','block');
})

$('select#dropdown-language').change(function(){
  selectedLang = $(this).val();
  if (selectedLang == 'eng') {
    demoLang = 'en-en'
  } else if (selectedLang == 'esp') {
    demoLang = 'en-es'
  } else if (selectedLang == 'esc') {
    demoLang = 'en-es'
  } else if (selectedLang == 'deu') {
    demoLang = 'en-de'
  } else if (selectedLang == 'ita') {
    demoLang = 'en-it'
  } else if (selectedLang == 'fra') {
    demoLang = 'en-fr'
  } else {
    demoLang = 'en-es'
  }

  setLanguageProducts(selectedLang);
  $('.lang-mob').text($('select#dropdown-language>option:selected').text());
  $('#your-lang span').text("Learn " + RSI({cat:selectedLang,media:'download'})[0].language);
  $('#mobileButton').text("ADD TO CART");
});


// MEDIA SELECTION: TABLET

function tMediaSelect(selected, deselected, display, nodisplay,show){
  $('.menu a.' + selected).click(function mediaSelectionT(e){
    e.preventDefault();
    $('.prod-container.' + display).css('display','inline-block');
    // $('select.' + show + 'ListIpad').css('display','block');
    $('.prod-container.' + nodisplay + ', select.' + deselected + 'ListIpad').css('display','none');
  })
}

tMediaSelect('dl','cd','download','cdrom','download');
tMediaSelect('cd','dl','cdrom','download','cd');


// MEDIA SELECTION: MOBILE

  // download selection: via download button and desktop button
$('.menu a.desktop, .cd-download a.download-option').click(function mediaSelectionD(e){
  e.preventDefault();
  // adds styling to download button and sets background image for download products
  $('.desk-on-container .menu a.desktop, .cd-download a.download-option').addClass('selected');
  $('.desk-on-container .menu a.online, .cd-download a.cd-option').removeClass('selected');
  $('#products-mobile .select-prod .desk-on-container .content.desktop').css('background-image','url("../assets/download.png")');
  // shows download list and download verbage
  $('#downloadListMobile').show();
  $('#cdListMobile, #subscriptionListMobile').hide();
  $('#pOne').html("Instant download for your desktop");
  $('#pTwo').html("Try our award-winning mobile app for 3 months");
  $('#pThree').html("Learn at your own pace with our course that never expires");
  $('#pFour').html("Access for up to 5 family members");
  // make desktop media options visible
  $('.cd-download').show();
});

  // cd selection: via cd button
$('.cd-download a.cd-option').click(function mediaSelectionCD(e){
  e.preventDefault();
  // adds styling to cd button and sets background image for cd products
  $('.desk-on-container .menu a.desktop, .cd-download a.cd-option').addClass('selected');
  $('.desk-on-container .menu a.online, .cd-download a.download-option').removeClass('selected');
  $('#products-mobile .select-prod .desk-on-container .content.desktop').css('background-image','url("../assets/cd-box.png")');
  // shows cd list and cd verbage
  $('#cdListMobile').show();
  $('#downloadListMobile, #subscriptionListMobile').hide();
  $('#pOne').html("Shipped directly to you");
  $('#pTwo').html("Try our award-winning mobile app for 3 months");
  $('#pThree').html("Learn at your own pace with our course that never expires");
  $('#pFour').html("Access for up to 5 family members");
});

  // online selection: via online button
$('.menu a.online').click(function mediaSelectionS(e){
  e.preventDefault();
  // adds styling to online button and sets background image for online products
  $('.desk-on-container .menu a.online').addClass('selected');
  $('.desk-on-container .menu a.desktop').removeClass('selected');
  $('#products-mobile .select-prod .desk-on-container .content.desktop').css('background-image','url("../assets/online.png")');
  // shows online list and online verbage
  $('#subscriptionListMobile').show();
  $('#downloadListMobile, #cdListMobile').hide();
  $('#pOne').html("Instant access to learn online");
  $('#pTwo').html("Learn online with our award-winning mobile apps for 24 months");
  $('#pThree').html("Unlimited access for 24 months");
  $('#pFour').html("Individual access");
  // make desktop media options hidden
  $('.cd-download').hide();
});


// ADD TO CART: DESKTOP + TABLET + MOBILE


// testing affiliate code addition
var affiliateCodes = {
    "employeemall":"af-pg-ey-zz-us",
    "jmu":"af-pg-jm-zz-us",
    "beneplace":"af-pg-be-zz-us",
    "usatfmembers":"af-pg-ut-zz-us",
    "usatfathlete":"af-pg-uf-zz-us",
    "perkspot":"af-pg-pk-zz-us",
    "hbfuller":"af-pg-hb-zz-us",
    "boehringer-ingelheim":"af-pg-bi-zz-us",
    "cbp":"af-pg-cb-zz-us",
    "cypress":"af-pg-cs-zz-us"
};

function addCart(prodType){
  $('#' + prodType + 'Button').click(function addToCart(){
    if($langMenu.css('display') == "block"){
      $(this).attr('href',"#lang-menu");
      $('html, body').animate({scrollTop: $( $.attr(this, 'href') ).offset().top}, 500);
    }else{
      var url = $('#' + prodType + 'List').css('display') == "block" ? $('#' + prodType + 'List input[type=radio]:checked').val() : $('select.' + prodType + 'ListIpad option:selected').val();
      var gifting = $('#' + prodType + 'List').css('display') == "block" || prodType == 'subscription' ? $('#' + prodType + 'gift').is(':checked') : $('#' + prodType + 'Tabletgift').is(':checked');

      if(secure.test(url)){url = gifting ? url + "&gifting=1" : url;}

      // if affiliate page, pass affiliate page cid to cart
      var pageName = window.location.pathname.slice(9,-1);
      url = typeof affiliateCodes[pageName] == "undefined" ? url : url + "&cid=" + affiliateCodes[pageName];
      window.location.href = url;
    }
    return false;
  })
}

addCart('cd');
addCart('download');
addCart('subscription');


$('#mobileButton').click(function addToCartM(){
  if($('#mobileButton').text() == "ADD TO CART"){
    var media = $('#cdListMobile').css('display') == "block" ? "#cd" : $('#downloadListMobile').css('display') == "block" ? "#download" : "#subscription";
    var url = $(media + 'ListMobile input[type=radio]:checked').val();
    var gifting = media == '#cd' ? $('#boxMobilegift').is(':checked') : $(media + 'Mobilegift').is(':checked');

    if(secure.test(url)){url = gifting ? url + "&gifting=1" : url;}
    // if affiliate page, pass affiliate page cid to cart
    var pageName = window.location.pathname.slice(9,-1);
    url = typeof affiliateCodes[pageName] == "undefined" ? url : url + "&cid=" + affiliateCodes[pageName];
    window.location.href = url;

  }else{
    $('html, body').animate({
      scrollTop: $('#products-mobile').offset().top
    }, 500);
  }
  return false;
})

// OPENING LIGHTBOXES: DESKTOP + TABLET
  // compare products + what you'll learn
function showLightBox(contentType,lightBoxContent){
  $(contentType).click(function openLightBox(){
    $('html,body').scrollTop(0);
    $('#lightboxes, #lightBoxInner, ' + lightBoxContent).fadeIn('slow');
  })
}

showLightBox('#compareButton','#compare');
showLightBox('#learnButton','.wyl-wrapper');
showLightBox('#works-hov img, .works', '#howitworks')

  // appends video to how it works lightbox
$('.works').click(function howitworksappend(){
  $('#howitworks').append('<video autoplay controls="" style="width: 80%; margin-left:10%;"><source src="//www.rosettastone.com/lp/globals/videos/features-hd.mp4" type="video/mp4">Your browser does not support the <code>video</code> element.</video>');
})

  // demo: determines if email form should or should not be shown based on demotaken/fb email cookie
$('.container .demo, .js_start_demo').click(function initiateDemo(){
  if(RSUI.util.getCookie('demotaken') || RSUI.util.getCookie('curEmailIdsc')){
    $('html,body').scrollTop(0);
    $('#lightboxes, #lightBoxInner').fadeIn('slow');
    openDemo(demoLang);
  }else{
    $('html,body').scrollTop(0);
    $('#lightboxes, #lightBoxInner, #demo').fadeIn('slow');
  }
})


// CLOSING LIGHTBOXES: DESKTOP + TABLET
  // clicking close button
$('.close').click(function closeLightBox(){
  $('#lightboxes, .wyl-wrapper, #compare, #demo, #howitworks').fadeOut('slow');
  $('#howitworks video').remove();
  $(container).fadeOut('slow');
});
  // clicking outside the lightbox content while also not clicking one of the buttons to open a lightbox
$(document).mouseup(function(e){
  if (!lButton.is(e.target) && !cButton.is(e.target) && !dButton.is(e.target) && !hiwButton.is(e.target) && !container.is(e.target) && container.has(e.target).length === 0){
    $('#lightboxes, .wyl-wrapper, #compare, #demo, #howitworks').fadeOut('slow');
    $('#howitworks video').remove();
    $(container).fadeOut('slow');
    $lightboxDemo.fadeOut().css('height', originalHeight['height']).css('min-height', originalHeight['min-height']).find('iframe').fadeOut('fast').remove();
  }
});


// COMPARE PRODUCTS LIGHTBOX FUNCTIONALITY: DESKTOP + TABLET

function compareLB(shown,hidden){
  $('#' + shown + 'Button').click(function compareProds(){
    $('#' + hidden + '-table').fadeOut('fast');
    $('#' + shown + '-table').fadeIn('fast');
    $('#' + hidden + 'Button').removeClass('active');
    $(this).addClass('active');
  });
}

compareLB('features','devices');
compareLB('devices','features');






// LANGUAGE SET VIA PARAM

function getUrlParameter(sParam){
  // selects the url search params and subtracts the leading ?
  var sPageURL = window.location.search.substring(1);
  // splits the variable string into an array at every & symbol
  var sURLVariables = sPageURL.split('&');
  // loops through the the entire array
  for (var i = 0; i < sURLVariables.length; i++){
    // splits the string into an array at every = symbol
    var sParameterName = sURLVariables[i].split('=');
    // checks it see if this particular param name == the sParam name you entered
    if (sParameterName[0] == sParam) {
        // returns the associated param you were looking for
        return sParameterName[1];
    }
  }
};

selectedLang = getUrlParameter('lang') || getUrlParameter('language');

if(typeof selectedLang != "undefined" && selectedLang != ""){
  $('#' + selectedLang).trigger('click');
}else{}


// SET INITIAL WYL LIGHTBOX PRODUCT
$(document).ready(function(){
  var rsop1 = RSI({cat:'esp',media:'download',lvl:'L1'})[0]
  $('#access #course-heading').html( rsop1.language + '<br> Level 1');
  $('.wyl-buy-wrapper .wyl-price .wyl-regular').html("$" + rsop1.msrp);
  $('.wyl-buy-wrapper .wyl-price .wyl-discount').html("$" + rsop1.price);
  $('.wyl-buy-wrapper .wyl-buybutton').attr('href',rsop1.cart);
})



// FIXES DOWNLOAD/CD DISPLAY ISSUES WHEN SCALING: TABLET + DESKTOP

$(window).resize(function() {
  var $downContainer = $('.prod-container.download');
  var $diskContainer = $('.prod-container.cdrom')
    // if desktop, show both download and cd products
  if($(window).width() > 1039){
    $diskContainer.css('display','inline-block');
    $downContainer.css('display','inline-block');
    // hide tablet dropdowns
    $('.prices-pad').css('display','none');
    $('.prices').css('display','block');
    // if not desktop
  }else{
    // if resizing down from desktop, show download
    if( $diskContainer.css('display') == 'inline-block' && $downContainer.css('display') =='inline-block'){
      $diskContainer.css('display','none');
      $downContainer.css('display','inline-block');
    }
    // if download is showing, continue to show
    if($diskContainer.css('display') == 'none' && $downContainer.css('display') =='inline-block'){
      $diskContainer.css('display','none');
      $downContainer.css('display','inline-block');
    }
    // if cd is showing, continue to show
    if($diskContainer.css('inline-block') == 'none' && $downContainer.css('display') == 'none'){
      $diskContainer.css('display','inline-block');
      $downContainer.css('display','none');
    }
    // show tablet dropdown
    $('.prod-container.download .prices, .prod-container.cdrom .prices').css('display','none');
    $('.prices-pad').css('display','block');
  }
});


// HIDES/SHOWS LANG MENU/SELECTION BUTTON: DESKTOP + TABLET + MOBILE
/*
$(window).resize(function() {
  // if not mobile, consistent resizing
  if($(window).width() > 743){
    // if menu is showing, continue to show
    if($langMenu.css('display') == 'block'){
      $langHeader.hide();
      $langMenu.show();
    }
    // if header is showing, continue to show
    if($langHeader.css('display') == 'block'){
      $langHeader.show();
      $langMenu.hide();
    }
    // if resizing up from mobile, show header
    if($langMenu.css('display') == 'none' && $langHeader.css('display') == 'none'){
      $langHeader.show();
      $langMenu.hide();
    }
    // if mobile hide menu and header
  }else{
      $langHeader.hide();
      $langMenu.hide();
  }
});
  // needed?
$(document).ready(function(){
  if($(window).width() <= 743){
    $mobileContainer.hide();
  }
})
*/

// HOVER STATES FOR DEMO + HIW + WPS: LINO

$("#demo-hov, #works-hov, #reviews-hov").hover(function(){
    $(this).find("img").animate({opacity: 0}, 500);
}, function() {
    $(this).find("img").animate({opacity: 1}, 500);
});

// IF NO LANGUAGE: SET INITIAL PAGE LOAD TO SPANISH PRICES
$('document').ready(function(){
  if(!/\?lang|&lang/.test(window.location.href)){
    selectedLang = "esp"
    setLanguageProducts(selectedLang);
  }
})





/* Alters Demo Area with TnT winning code */

// preselect spanish in mobile
if (!isDesktop && grabUrlParam('language') == null && grabUrlParam('lang') == null) {
  // preselect spanish
  // $('#dropdown-language option:nth-of-type(2)').prop('selected', true).trigger('change')
  setTimeout(function(){
	  $(document).trigger('lang_change', {
	    'lang': 'esp'
	  });
  },200);
}
if (!isDesktop){
  $('a.online').click()
}
/*
if (isDesktop) {
  // alters demo look
   var demohov = $('#demo-hov').detach();
  $('a.demo').html('<b>Experience</b> the NEW Rosetta Stone Demo').append(demohov)
  $('#tryit a.demo').append("<span class='democta'><span> Enjoy a special, interactive tour<br> of our award-winning method.</span><button>START YOUR FREE DEMO</button>")
}

// alters demo look too
$('#reviews-hov > img').attr('src', '../assets/grace.jpg')
$('#works-hov > img').attr('src', '../assets/watch.jpg')
$('#demo-hov > img').attr('src', '../assets/tryit.jpg')
*/

mboxCreate('US_RS_Landing_SBSR_1')

/*
var priceIsMsrp = false;

$(document).ready(function (){

  priceIsMsrp = RSI()[0].price == RSI()[0].msrp;

  if(priceIsMsrp){

      // mastheads
      $('#regular-price').hide()

      // sbsr / ppc
      $('.strike').remove()

  }
})
*/



















// DEMO LIGHTBOX FUNCTIONALITY: DESKTOP + TABLET
  // choose language
$('#dropdown').click(function(e){
  $('#lang-drop').slideToggle();
});

$('#demolang li').click(function chooseDemoLang(){
  demoLang = $(this).children('a').data('id');
  $('#dropdown span').html($(this).children('a').html());
});






function grabUrlParam( name ) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null ){
    return null;
  }else{
    return results[1];
  }
}

function validateEmail(email){
  var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return re.test(email);
}

function hideEmailInput() {
  $('#field-email').hide()
  $('.formFoot').css('display','none');
}




function openDemo(lang) {

  lang = typeof lang !== 'undefined' ? lang : 'en-es'
  console.log('---- OPEN DEMO lang: ', lang)
  if (!isDesktop && lang != 'en-en') {
    var map = {
      'en-fr' : 'french',
      'en-de' : 'german',
      'en-it' : 'italian',
      'en-en' : 'english',
      'en-es' : 'spanish'
    }
    // liveperson lead generation
    var lpParam = typeof lpl == 'undefined' ? "" : lpl == true ? "&lpl=true" : "";
    console.log('---- OPEN DEMO lang: ', map[demoLang])

    var stg_or_not = /\.stg\./i.test(window.location.href) ? 'stg.' : '';
    window.location.href = 'https://www.'+stg_or_not+'rosettastone.com/lp/demo-mdot/?lang=' + map[demoLang] + lpParam;

  } else {
    var demoFrame = ""
      + "<iframe "
      + " id='demo'"
      + " src='//resources.rosettastone.com/CDN/us/rs-i-demo-6/?lang=" + lang + "'"
      + " width='100%'"
      + " height='100%'"
      + " scrolling='no'"
      + "></iframe>"
      ;

    if (!isDesktop && lang == 'en-en')
    {
      window.location.href = '//resources.rosettastone.com/CDN/us/rs-i-demo-6/?lang=' + lang
      return
    }

    $lightboxDemo.append(demoFrame)
    var marginLeft = ((window.innerWidth - $lightboxDemo.innerWidth()) / 2) + 'px'
    $lightboxDemo.css({
      'margin-left' :  marginLeft
    })
    $lightboxDemo.fadeIn()
    originalHeight = {
      'min-height' : $lightboxDemo.css('min-height'),
      'height' : $lightboxDemo.css('height')
    };
    $lightboxDemo.find('img').click(function() {
      $lightboxDemo.find('iframe').fadeOut('fast').remove();
      $('#demo').hide();
      $lightboxDemo.fadeOut();
      $lightboxDemo.css('height', originalHeight['height']);
      $lightboxDemo.css('min-height', originalHeight['min-height']);
    })
  }
}


function submitEmailToEC(email, lang) {
    var defer = jQuery.Deferred()

    var map = {
      'en-fr' : 'fra',
      'en-de' : 'deu',
      'en-it' : 'ita',
      'en-en' : 'eng',
      'en-es' : 'esp'
    }

    var data = {
      email : email,
      demo_lang : map[demoLang],
      cis_name : 'Flash demo',
      website: 'US_WEBSITE',
      form_type : 'demo',
      demo_type : isDesktop ? 'Demo_Desktop' : 'Demo_Mobile',
      form_url : window.location.pathname,
      newsletter_type : "Bottom_Landing_SBSR",
      cid : _satellite.getVar("mostrecentcampaign")
    }



    var url = (window.location.href.search(/(\.stg\.)|(\.local)/i)>-1 ?'//www.stg' :'//www')
    + '.rosettastone.com/?p_p_id=rosettaajaxsubmit_WAR_rosettaajaxsubmitportlet&p_p_lifecycle=2&redirect2mobile=no';

    var request = $.ajax({
      url: url,
      type: "POST",
      data: data
    });

    request.done(function(msg) {
      if (JSON.parse(msg)[0]['cisFlag']  == 'true') {
        $(document).trigger('demo_email', {"email": email});
        RSUI.util.setCookie('demotaken', "1", 1, 30 * 1000 * 60 * 60 * 24);
        hideEmailInput();
        var days_till_expiration = 30;
        var expiration = new Date(new Date().getTime() + days_till_expiration*24*60*60*1000).toUTCString();
        document.cookie='rsDemoEmail='+email+'; expires='+expiration+'; path=/; domain=.rosettastone.com';

        // liveperson lead generation
        if(!isDesktop && typeof lpTag == "object" && typeof lpl != 'undefined'){lpl = true;};

        defer.resolve('success')
      } else {
        defer.reject('fail')
        $('#emailForm input[type=text]').addClass('input-error').attr('placeholder', 'Sorry, try again!')
      }
    })

    return defer.promise()

}

//initiate demo events coverage
$(document).trigger('demo_events_version', {version: 1});
var $form = $('#emailForm');

$form.submit(function(e) {
  e.preventDefault()
  email = $('#field-email').val();
  var $inputEmail = $('#emailForm input[type=text]')
  var error = false;
  if (typeof demoLang == "undefined") {
    error = true
    $('#field-email').css('border', 'solid thick red');
  } else {
    error = false
    $('#field-email').css('border', 'solid 1px #d7d7d7');
  }
  // Only validate email if user doesn't have the demotaken cookie
  if (!RSUI.util.getCookie('demotaken')) {
    if (!validateEmail(email)) {
      error = true
      $('#field-email').css('border', 'solid thick red');
    } else {
      $('#field-email').css('border', 'solid 1px #d7d7d7');
    }
    $(document).trigger('demo_start');
    
  }

  if (!error) {
    //$('#demo').hide();
    verify_real_email(email, emailAccepted, emailRejected)

  }
})



function emailAccepted(email)
{
  var email = email || $inputEmail.val()

  $.when( submitEmailToEC(email, selectedLang) ).then(
    // Success
    function() {

      openDemo(demoLang)
    },
    // Rejected
    function() {

      $('#field-email').css('border', 'solid thick red');
    }
  )
}

function emailRejected()
{

  $('#field-email').css('border', 'solid thick red');
}


/*
 * Bright Verify.
 */

function get_token()
{
  window.briteverifyToken = false;

  var form_token = '4047df1c-5078-4e96-b335-f61aa2b92891'; // public key
  var url = 'https://forms-api-v1.briteverify.com/api/submissions/view.json?callback=getBriteverifyToken&form_token='+form_token+'&_='+Date.now();

  // append script to body to get cross-domain jsonp data
  var script = document.createElement('script');
  script.src = url;
  document.body.appendChild(script);

  window.getBriteverifyToken = function(data)
  {

    window.briteverifyToken = data.token;
    delete window.getBriteverifyToken;
    document.body.removeChild(script);
  }
}


// if the demo hasn't already been taken, get an email verification token
if (!RSUI.util.getCookie('demotaken'))
{
  get_token();
}

function verify_real_email(email,success,failure)
{

  if (!success) success = function(){};
  if (!failure) failure = function(){};


  if(window.briteverifyToken)
  {


    var token = window.briteverifyToken;
    var url = 'https://forms-api-v1.briteverify.com/api/submissions/verify.json?callback=briteverify&form_token=4047df1c-5078-4e96-b335-f61aa2b92891&token='+token+'&email='+email+'&_='+Date.now();

    var script = document.createElement('script');
    script.src = url;
    document.body.appendChild(script);


    // if the script url doesn't work (maybe they changed the api)
    script.onerror = function(e)
    {
      // ignore verification and move on

      success(email);
    };


    window.briteverify = function(data)
    {
      try
      {

        if(data.status!=='invalid')
        {
          // email is valid

          success(email);
        }
        else
        {

          // email is invalid
          failure();
        }

        document.body.removeChild(script);
      }
      catch(e)
      {

        // if error, ignore verification and move on
        success(email);
      }
      delete window.briteverify;
    }
  }
  else
  {
    // if no token, ignore verification and move on

    success(email);
  }
}