Thu Mar 14 2019
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
//append facebook api script
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


//Assign this to a URL on demo load, redirect after demo is closed.
var redirect;

/*========================== Open, close lightbox =====================*/
$(document).ready(function(){
/*Open on click*/
$(".open-demo-btn").on('click', function(){
  //preselct lang in button class name
  for (var c in this.classList) {
    if(typeof this.classList[c]==="string" && this.classList[c].match(/^\w\w\w$/)) {
      $("a[rel="+this.classList[c]+"]").click(); 
    }
  }
  // if no language found, go back to lang list
  if ($(".demo-drop li a.selected").length==0) {
    $("#demo-change-lang").click();
    $(".demo-lang-wrap").hide();
  }
  //create new yellow transition
  var tb = new TransitionBox(this,$(".demo-wrap")[0]);
  $(".demo-lightbox-mask").addClass("active");

  // demo analytics
  $(document).trigger('demo_events_version', { 
    version: 1,
    description: '',
    standard: 'http://tabbit.org/%E2%98%8D%E2%98%B9W'
  });

  // put focus in email text box
  setTimeout(function(){
    $('.demo-wrap .email-input:eq(0)').focus();
  }, 500);
});
// accessibility for demo opener
$(".open-demo-btn").attr('tabindex','0');
$(".open-demo-btn").on('keydown', function(e){
  if(e.keyCode===13){
    e.preventDefault();
    $(this).click();
  }
})
/*Close on click outside */
$(".demo-lightbox-mask").click(function(){closeLightbox()});

/* Close on ESC */
$(document).keyup(function(e){
  if (e.keyCode == 27) {
    closeLightbox();
  }
});
/*Close on 'close' click*/
$("span#close-lb").click(function(){closeLightbox()})
$("#demo-box .close-btn").click(function(){closeLightbox()});
closeLightbox();
});
function closeLightbox() {
$(".demo-lightbox-transition").css("background","#ecc200");
$(".demo-wrap").removeClass("play");
$(".demo-wrap").removeClass("active");
$(".demo-lightbox-mask").removeClass("active");
$(".arrow").removeClass("active");
$("html, body").removeClass("stop-scrolling");
$("#demo-box iframe").attr("src","");
if (typeof redirect != "undefined") {
  setTimeout(function() {window.location.href = redirect;},0);
}
}

function TransitionBox (from, to) { // yellow transition effect
var self = this;
this.from = from;
this.to = to;
this.tb = document.createElement("div");
this.tb.className = "demo-lightbox-transitions";
this.tb.style.width = from.offsetWidth+"px";
this.tb.style.height = from.offsetHeight+"px";
this.tb.style.top = from.className.match("demo-wrap")?window.scrollY+from.offsetTop-from.offsetHeight/2:from.offsetTop+"px";
this.tb.style.left = from.className.match("demo-wrap")?window.scrollX+from.offsetLeft-from.offsetWidth/2:from.offsetLeft+"px";
var par = document.getElementsByClassName("demo-lightbox-transition")[0];
par.parentNode.insertBefore(this.tb, par.nextSibling);
$(this.tb).animate({
  "top": $(to).offset().top + "px",
  "left": $(to).offset().left + "px",
  "width": $(to).outerWidth() + "px",
  "height": $(to).outerHeight() + "px"
}, 300, function() {
  if ($(".demo-lightbox-mask").hasClass("active")) {$(self.to).addClass("active");}
  $(this).fadeOut(300,function(){this.remove;});
});
}

/*========================= Open, close dropdowns =====================*/
$(document).ready(function(){
$(".demo-wrap").click(function (e) {
  var dd = $(e.target).find(".arrow").addBack('.arrow');
  if($(".dropdown-box").has($(e.target)).length>0) {
    e.stopPropagation(); return false; /* do nothing on click inside */
  }
  if($(e.target).hasClass("demo-drop") || $(e.target).hasClass("arrow")){
    if (dd.hasClass("active")) { /* toggle on dd click */
      dd.removeClass("active");
    } else {
      $(".arrow").removeClass("active");dd.addClass("active");
    }
    e.stopPropagation(); fade(); return false;
  }
    $(".arrow").removeClass("active"); /* and close on click outside */
    fade();
});
function fade() {
  var all = $(".arrow").parents(".lightbox-product-inner");
  var active = $(".arrow.active").parents(".lightbox-product-inner");
    if(active.length>0) {
      all.css("opacity","0.5");
    active.css("opacity","1");
  } else {
    all.css("opacity","1");
  }
}
});

/*===================== Select Language from dropdown =================*/
$(document).ready(function(){
$(".demo-drop ul li a").click(function (e) {
  $(document).trigger('demo_language', {language: $(this).text(), lang_code: $(this).attr("rel").toUpperCase()});
  $(".lightbox-product-inner").find(".email-input").attr("required",false);
  $(".demo-drop ul li a").removeClass("selected");
  $(this).addClass("selected");
  $(".selected-lang").html($(this).html());
  $(".arrow").removeClass("active");
  $(".demo-lang-wrap").show();
  $(".demo-lang-wrap").removeClass("lang-select");
  $(".signup-options").slideDown();
  $(".start-demo-btn").slideDown();
  $(".demo-drop").slideUp();
  if (RSUI.util.getCookie("curEmailIdsc")) {
    $(this).parents(".lightbox-product-inner").find(".email-input").val(RSUI.util.getCookie("curEmailIdsc"));
  }
  $(this).parents(".lightbox-product-inner").find(".email-input").attr("required",true).focus();
});
});
/* ======================== Go back to lang list =========================*/
$(document).ready(function(){
$("#demo-change-lang").click(function () {
  if ($(".demo-lang-wrap").hasClass("lang-select")) {
    $(".demo-drop li a.selected").click();
  } else {
    $(".demo-lang-wrap").addClass("lang-select");
    $(".signup-options").slideUp();
    $(".start-demo-btn").slideUp();
    $(".demo-drop").slideDown();
  }
});
});
/* ========================= Facebook FB login ===========================*/
$(document).ready(function doFB(xn){
if(typeof FB == 'undefined'){
   var xn = xn || 100;
   return xn > 10000000 ? false : setTimeout(doFB, xn, 10 * xn);
}
FB.init({
  appId: "1091422140883673",
  status: true,
  cookie: true,
  xfbml: true,
  oauth: true,
  channelUrl: window.location.protocol + '//' + window.location.hostname + '/facebook/channel'
});
$("#facebook-login").click(function(){
  FB.login(function(response) {
        if (response.authResponse) {
            FB.api('/me', function(me) {
                //fb login success
                var selectedLang = $(".demo-drop .selected");
                var demoURL = selectedLang.attr("data-url");
                var demoLangCode = selectedLang.attr("rel");
                jQuery.when(submitEmailToEC(me.email, demoLangCode,"!!US_Web_Leads")).then(openDemo(demoURL));
            });
        } else {
            //facebook failed
            console.log("fb fail");
        }
    }, {
        scope: 'email'
  });
});
});
/* ============================ Validate Form ============================*/
$(document).ready(function(){
$(".start-demo-btn").click(function (e) {
  function validateEmail(email) {
      var re = /\S+@\S+\.\S+/; 
      re.test(email) ? verify_real_email(email,validateSuccess,validateFail) : validateFail();
  }
  function validateSuccess() {
      if (!RSUI.util.getCookie("curEmailIdsc")) { 
          jQuery.when(submitEmailToEC(email.val(), lang,"!!US_Web_Leads")).then(openDemo(demoURL)); 
      } else {
          openDemo(demoURL);
      } 
      return false;
  }
  function validateFail() {
      email.css("border","2px solid red").val("").prop("placeholder","PLEASE ENTER A VALID EMAIL").focus();
  }
  var selLang = $(this).parents(".lightbox-product-inner").find("li a.selected")
  var lang = selLang.attr("rel");
  var demoURL = selLang.attr("data-url")
  if (typeof lang == "undefined") {return false;}
  var email = $(this).parent().find(".email-input");
  if (email.attr("required")) {
      validateEmail(email.val())
  }
});
});



/**************************************************
BRITEVERIFY EMAIL VERIFICATION
***************************************************/

function verify_real_email(email, success_callback, failure_callback){

// make sure all parameters are used
if(!email || !success_callback || !failure_callback){
  return;
}

// if gdpr consent isn't given, skip the validation and go straight to the demo
var gdpr_consent_given = window.gdpr && window.gdpr.email_consent; // note: US country_code sets consent to 'implied'
if(!gdpr_consent_given){
  success_callback();
  return;
}

// if request isn't found in 2 sec or less, move on without it
var max_wait_seconds = 2;
window.briteverify_timeout_finished_first = false;
window.briteverify_api_finished_first = false;
setTimeout(function(){
  if(!window.briteverify_api_finished_first){
    window.briteverify_timeout_finished_first = true;
    success_callback && success_callback();
  }
}, max_wait_seconds*1000);


// hit briteverify api (https://support.briteverify.com/javascript-api)
var data = { 
  username: 'pestes',
  address: email
};
var url = 'https://bpi.briteverify.com/emails.json';

$.get(url, data, function (results) {

  if(!window.briteverify_timeout_finished_first && results && results.status){

    window.briteverify_api_finished_first = true;

    if(results.status==='invalid'){
      failure_callback && failure_callback();
    }
    else{
      success_callback && success_callback();
    }
  }

},'jsonp');
}

/* ============================ Open Demo ============================*/
function openDemo(demoURL) {

// EFIGS languages have a two character code because of the way the Demo URLs are formatted
var langMap = {
  'en': 'english',
  'fr': 'french',
  'it': 'italian',
  'de': 'german',
  'es': 'spanish',
  'ara': 'arabic',
  'chi': 'chinese',
  'dar': 'dari',
  'ned': 'dutch',
  'ebr': 'english(british)',
  'tag': 'filipino',
  'grk': 'greek',
  'heb': 'hebrew',
  'hin': 'hindi',
  'ind': 'indonesian',
  'gle': 'irish',
  'jpn': 'japanese',
  'kor': 'korean',
  'lat': 'latin',
  'pas': 'pashto',
  'far': 'persian',
  'pol': 'polish',
  'por': 'portuguese',
  'rus': 'russian',
  'esc': 'spanish(spain)',
  'kis': 'swahili',
  'sve': 'swedish',
  'tur': 'turkish',
  'urd': 'urdu',
  'vie': 'vietnamese'
};

var startlang = demoURL.match(/lang=en-(..)/) || demoURL.match(/lang=(...)/);
startlang = startlang.length > 1 && startlang.pop();
var _demolang = startlang && langMap[startlang];
var startopts = {
  version: 'd4',
  version_description: 'desktop_demo',
  start_time: new Date()
};
!!_demolang && (startopts['lang'] = _demolang);
$(document).trigger('demo_start', startopts);
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
  setTimeout(function() {
    window.location.href = demoURL;
  }, 350);
}
$("#demo-box iframe").remove();
var iframe = document.createElement("iframe");
iframe.src = demoURL;
iframe.width = "100%";
iframe.height = "100%";
iframe.scrolling = "no";
iframe.frameborder = "0";
$(".demo-wrap").addClass("play");
$("#demo-box").append(iframe);

// put keyboard focus in iframe for accessibility
setTimeout(function(){
  iframe.contentWindow.focus();
},900);

if (~demoURL.indexOf("type=k12")) redirect = "https://www.rosettastone.com/k12";
if (~demoURL.indexOf("type=busn")) redirect = "https://www.rosettastone.com/business";
}

/* ========================== Send Email To EC ========================*/
function submitEmailToEC(email, langCode, cis_name) {
  var isDesktop=!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
    var defer = jQuery.Deferred();

    var gdpr_consent_given = window.gdpr && window.gdpr.email_consent; // note: US country_code sets consent to 'implied'

    // if we don't have consent, skip the email collection and go directly to demo
    if(!gdpr_consent_given){
      defer.resolve('success');
    }

    else if(gdpr_consent_given){

      $(document).trigger('demo_email', {
        email: email,
        is_offer: false
      });

      var baseURL = (window.location.href.search(/(\.stg\.)|(local)/i)>-1 ?
            'https://www.stg' : 
            'https://www') 
            + '.rosettastone.com/?p_p_id=rosettaajaxsubmit_WAR_rosettaajaxsubmitportlet&p_p_lifecycle=2&data=';
      
  
      var lead_page = window.location.href
      var form_url = window.location.pathname
      
      
      if (window.location.href.match(/\.com\/$/i) != null) {
        // home page
        lead_type = 'demo_video';
        lead_page = 'homepage'
        form_url = 'rosettastone.com'
        if (window.location.href.match(/espanol/i)) {
          // espanol home page
          lead_type = 'demo_video';
          lead_page = 'homepage'
          form_url = 'espanol.rosettastone.com'
        }
      }
      if (window.location.href.match(/learn-*/i) != null) {
        lead_type = 'demo_video';
        lead_page = 'learn_page'
        form_url = 'learn pages'
      }
      if (window.location.href.match(/speak-*/i) != null) {
        lead_type = 'demo_video';
        lead_page = 'speak_page'
        form_url = 'speak pages'
      }
      if (window.location.href.match(/buy-*/i) != null) {
        lead_type = 'demo_video';
        lead_page = 'learn_page'
        form_url = 'buy pages'
      }
      if (window.location.href.match(/opdemo2/i) != null) {
        lead_type = 'demo_video';
        lead_page = 'demo_page'
        form_url = '/lp/opdemo2'
      }
      if (window.location.href.match(/\/demo\//i) != null) {
        lead_type = 'demo_video';
        lead_page = 'demo_page'
        form_url = '/demo'
      }
      if (window.location.href.match(/\/freetrial\//i) != null) {
        lead_type = 'freetrial';
        lead_page = 'trial_page'
        form_url = '/freetrial'
      }
      if (window.location.href.match(/\/reviews\//i) != null) {
        lead_type = 'demo_video';
        lead_page = 'reviews'
        form_url = '/reviews'
      }
      if (window.location.href.match(/\/testimonials\//i) != null) {
        lead_type = 'demo_video';
        lead_page = 'testimonials'
        form_url = '/testimonials'
      }
      if (window.location.href.match(/\/opdemo-es\//i) != null) {
        lead_type = 'demo_video';
        lead_page = 'demo_page'
        form_url = '/lp/opdemo-es'
      }
      if (window.location.href.match(/\/aprende-*\//i) != null) {
        lead_type = 'demo_video';
        lead_page = 'learn_page'
        form_url = 'aprende pages'
      }
      if (window.location.href.match(/\/homeschool\/reviews\//i) != null) {
        lead_type = 'demo_video';
        lead_page = 'homeschool_reviews'
        form_url = '/homeschool/reviews'
      }
      if (window.location.href.match(/\/homeschool\/demo\//i) != null) {
        lead_type = 'demo_video';
        lead_page = 'homeschool_demo'
        form_url = '/homeschool/demo'
      }

      
      
      var data = {
          email : email,  // required
          cis_name : '!!US_Web_Leads', // required
          form_url : form_url,  // required
          website: 'US_WEBSITE', // required
          lead_type : lead_type,
          lead_page : lead_page,
          form_type : form_url, // not required, but if omitted, lead_page defaults to 'PE'
          demo_lang : langCode,
          consent_type : ( window.gdpr && window.gdpr.email_consent ) || null,          
          visit_country_code : ( window.gdpr && window.gdpr.country_code ) || null,                
          cid: _satellite.getVar('mostrecentcampaign'),
          demo_device: isDesktop ? 'desktop' : 'mobile',
      }

      var request = jQuery.post(baseURL + encodeURIComponent(JSON.stringify(data)), data);

      request.done(function(msg) {
        if (!!msg.match(/true/))
        {
          // record the email in a cookie that expires in 30 days
          RSUI.util.setCookie("curEmailIdsc",email)
          //document.cookie = 'curEmailIdsc='+email+'; max-age='+60*60*24*30+'; path=/;';
          defer.resolve('success')
        }
      });
    }

    return defer.promise()
}
/* ======================= Send Email To Eloqua ======================*/
function submitEmailToEloqua(email, elqFormName) {
function GetElqCustomerGUID(){
  var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); return v.toString(16);});
  return guid;
}
var elqURL = "http://s1294.t.eloqua.com/e/f2?C_EmailAddress="+email+"&redirect_url=&elqFormName="+elqFormName+"&elqSiteID=1294&elqCustomerGUID="+GetElqCustomerGUID()+"&elqCookieWrite=0";
ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", elqURL);
ifrm.style.width = "0px";
ifrm.style.height = "0px";
ifrm.style.display = "none";
$("body").append(ifrm);
  // Doty's demo pixel
// $('body').append('<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1041440066/?label=WzGCCNzOy1gQwrrM8AM&amp;guid=ON&amp;script=0"/>')
$(document).trigger('demo_email', {
  email: email,
  is_offer: false
});
// record the email in a cookie that expires in 30 days
document.cookie = 'curEmailIdsc='+email+'; max-age='+60*60*24*30+'; path=/;';

}
/* ===================== Remove v3 demo for tablet ===================*/
$(document).ready(function(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
  $(".drop-col:not(:first-child)").remove();
  $(".drop-col ul").css("width","16.5em");
}
});
/* ===================== extend addBack for old jQuery ===================*/
$(document).ready(function(){
jQuery.fn.addBack = function (selector) {
    return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector));
}
});