-1) {
var s = source.indexOf("", e);
var script = source.substring(s_e+1, e);
if(script == '') {
script = source.substring(s+8, e);
var start = script.indexOf("src=");
if(start > -1){
var end = script.indexOf(">", start);
var srcfile = script.substring(start+5, end-1);
var cbScript = document.createElement('script');
cbScript.type= 'text/javascript';
cbScript.src = srcfile;
loadcnt++;
loadedPopupScripts[name].push(cbScript);
tempLoadedScripts.push(cbScript);
}
}else{
scripts.push(script);
}
source = source.substring(0, s) + source.substring(e_e+1);
}
//IE & general fix over all to handle an issue of writeNavDivFinal getting repeatedly called rather then being
// called once. DAG 10.30.13
if(tempLoadedScripts.length > 0 ){
for(var i=0;i= 0 && BROWSER.indexOf('11') == -1){ // MAG 03/19/2014: Added this condition to fix IE11 bug ('onreadystatechange' event deprecated on IE11)
cbScript.onreadystatechange = function(){
//modified by TJ on 9/26/2012, count only when file is loaded
if(this.readyState == undefined || this.readyState == 'complete' || this.readyState == 'loaded'){
loadcnt--;
}
if((loadcnt <= 0) && divNotWroteYet){
writeDivFinal(name, div, source, scripts,bScreen);
divNotWroteYet = false;
}
};
}else{
cbScript.onload = function(){
//modified by TJ on 9/26/2012, count only when file is loaded
if(this.readyState == undefined || this.readyState == 'complete' || this.readyState == 'loaded'){
loadcnt--;
}
if((loadcnt <= 0) && divNotWroteYet){
writeDivFinal(name, div, source, scripts,bScreen);
divNotWroteYet = false;
}
};
}
}
}else{
writeDivFinal(name, div, source, scripts,bScreen);
}
}
}
/*
function showPopup(name, divid, blockScreen, inPayWall){
inPayWall = (inPayWall !== void 0 ? inPayWall : true);
if(openPopups.length>0){
for(i=0;i -1 || source.indexOf(" -1) {
var s = source.indexOf("", e);
var script = source.substring(s_e+1, e);
if(script == '') {
script = source.substring(s+8, e);
var start = script.indexOf("src=");
if(start > -1)
{
//someone added this and it broke the popups. Len - 9/17/13
//var quote = script.charAt(start+4);
//var end = script.indexOf(quote, start);
var end = script.indexOf(">", start);
var srcfile = script.substring(start+5, end-1);
var cbScript = document.createElement('script');
cbScript.type= 'text/javascript';
loadcnt++;
cbScript.onload = cbScript.onreadystatechange = function()
{
//modified by TJ on 9/26/2012, count only when file is loaded
if(this.readyState == undefined || this.readyState == 'complete' || this.readyState == 'loaded') {
loadcnt--;
}
if((loadcnt <= 0) && divNotWroteYet){
writeDivFinal(name, div, source, scripts,bScreen);
divNotWroteYet = false;
}
};
cbScript.src = srcfile;
loadedPopupScripts[name].push(cbScript);
document.body.appendChild(cbScript);
}
}
else {
scripts.push(script);
}
source = source.substring(0, s) + source.substring(e_e+1);
}
if(loadcnt == 0) {
writeDivFinal(name, div, source, scripts, bScreen);
}
}
}
*/
// if scripts needed to be loaded finish up after they are ready
function writeDivFinal(name, div, content, scripts, blockScreen){
//alert('test');
var dragger_handle;
div.innerHTML = content;
var bScreen = document.getElementById(blockScreen);
var offsets = nodeOffsets(blockScreen);
for(var i=0;i 0){
var div = openPopups[0];
/* if(document.createEvent) {
var closepopup = document.createEvent('Event');
closepopup.initEvent('closepopup', true, true);
}else if(document.createEventObject) {
var closepopup = document.createEventObject();
closepopup.type = 'closepopup';
}
var dispatchDiv = document.getElementById(div.getAttribute('popupFrameId'));
if(dispatchDiv && dispatchDiv.dispatchEvent){
dispatchDiv.dispatchEvent(closepopup);
} */
dispatchClosePopup(div, closeIframe);
if(div.parentNode) {
div.parentNode.removeChild(div);
}
//trace("callback? ", typeof window.popupCallback, "id--", div.id);
if(typeof window.popupCallback == 'function'){
window.popupCallback();
window.popupCallback = null;
trace('no more callback ', typeof window.popupCallback);
}
for(i=0; i < openPopups.length;i++){
if(openPopups[i] == div){
if (openPopups[0].id == 'password_check_popup')
passwordPopupVisible = false;
openPopups.splice(i,1);
if(loadedPopupScripts[div.id].length > 0){
for(var j=loadedPopupScripts[div.id].length-1;j>-1;j--){
if(loadedPopupScripts[div.id][j]){
loadedPopupScripts[div.id][j].parentNode.removeChild(loadedPopupScripts[div.id][j]);
}
}
loadedPopupScripts[div.id] = [];
}
}
}
if(openPopups.length>0){
openPopups[0].style.visibility = 'inherit';
if(openPopups[0].id == 'volumeslider.php')
{
var iframe = document.createElement("IFRAME");
iframe.setAttribute("src", "js-call:showVolumeSlider:198:424:365:41");
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
}
}
}
if(openPopups.length==0){
if(smallScreen) {
smallScreen.style.display = 'none';
}
if(typeof closeSidepanels == 'function' && reopenSidepanelWhenNoOpenPopups == true) {
reopenSidepanels();
}
if (typeof SidePanel == 'function') {
if (last_sidepanel_index != -1)
side_panels[last_sidepanel_index].show();
}
}else {
smallScreen.style.display = 'block';
}
}
// 1.6.17 - added `closeIframe` param; if true, send a message to the parent frame to tell it
// to close the iframe containing the popup
function closeAllPopups(callback, closeIframe){
var dispatch, smallScreen = document.getElementById('small_screen');
for(i=openPopups.length-1; i > -1;i--){
if(loadedPopupScripts[openPopups[i].id].length > 0){
for(var j=loadedPopupScripts[openPopups[i].id].length-1;j>-1;j--){
if(loadedPopupScripts[openPopups[i].id][j]){
loadedPopupScripts[openPopups[i].id][j].parentNode.removeChild(loadedPopupScripts[openPopups[i].id][j]);
}
}
loadedPopupScripts[openPopups[i].id] = [];
}
// 4.7.14 dh - dispatch for each popup
dispatchClosePopup(openPopups[i]);
openPopups[i].parentNode.removeChild(openPopups[i]);
//Added to resolve the small_screen div issue where it would not be hidden when all popups were gone in IE
if (i === 0) {
openPopups = [];
closeBlockScreen();
if (callback && typeof callback === 'function') {
if (smallScreen ) {
smallScreen.style.display = 'none';
}
callback();
}
}
}
if (closeIframe) {
window.parent.postMessage({
type: 'iframe-popup-closed',
payload: document.location.href
}, '*');
}
}
// 4.7.14 dh - dispatch closepopup
// 1.6.17 - added `closeIframe` param; if true, send a message to the parent frame to tell it
// to close the iframe containing the popup
function dispatchClosePopup(div, closeIframe) {
if(document.createEvent) {
var closepopup = document.createEvent('Event');
closepopup.initEvent('closepopup', true, true);
}else if(document.createEventObject) {
var closepopup = document.createEventObject();
closepopup.type = 'closepopup';
}
var dispatchDiv = document.getElementById(div.getAttribute('popupFrameId'));
if(dispatchDiv && dispatchDiv.dispatchEvent){
dispatchDiv.dispatchEvent(closepopup);
}
if (closeIframe) {
window.parent.postMessage({
type: 'iframe-popup-closed',
payload: document.location.href
}, '*');
}
}
//////////////////////Navigate To////////////////////////////////////////////////////////////////////
var navAjax;
function navTo(name, skipHistory) {
if (!skipHistory) {
currentHash = name.replace('php','');
currentHash = currentHash.replace('/html5/','');
window.location.hash = currentHash;
}
cancelAjax(navAjax);
navAjax = ajax(name, null, function(data) { writeNavCssScripts('content_area' , data);});
}
//work around for non-hash system
function goBack(name){
var div = document.getElementById('content_area');
currentHash = name.replace('php','');
cancelAjax(navAjax);
//navAjax = ajax(name, null, function(data) { writeCssScripts(div.id , data);});
}
function writeNavCssScripts(name,content){
var source = content;
var includes = new Array();
var loadcnt = 0;
var div = document.getElementById(name);
var scripts = new Array();
if(div) {
if(loadedPageScripts.length > 0){
for(var i=loadedPageScripts.length-1;i>-1;i--){
if(loadedPageScripts[i]){
loadedPageScripts[i].parentNode.removeChild(loadedPageScripts[i]);
loadedPageScripts[i] = null;
}
}
loadedPageScripts = [];
}
// Strip out tags
while(source.indexOf(" -1 || source.indexOf(" -1) {
var startIndex = source.indexOf("", startIndex);
var script = source.substring(startIndex+1, endIndex+1);
if(script != '') {
var start = script.indexOf("href=");
if(start > -1){
var end = script.indexOf(">", start);
var srcfile = script.substring(start+6, end-1);
var cbScript = document.createElement('link');
cbScript.type= 'text/css';
cbScript.rel = "stylesheet";
cbScript.href = srcfile;
loadedPageScripts.push(cbScript);
document.body.appendChild(cbScript);
}
}
source = source.substring(0, startIndex) + source.substring(endIndex+1);
}
writeNavDiv(name, div, source, scripts);
}
}
// put contents of popup in div, loading and executing scripts as needed
function writeNavDiv(name, div, content, pageScript) {
var div = document.getElementById(name);
var source = content;
var loadCount = 0;
var scripts = pageScript;
var tempLoadedScripts = [];
var currentScriptTag;
var currentScriptSrc;
var cbScript;
var currentScriptBody;
var startTagSearch;
var endTagSearch;
var speculativeScriptBody;
var innerStartTagCount;
var lastEndTagStartIndex;
if (div) {
// Strip out scripts
while (source.indexOf(' -1) {
startTagSearch = /', lastEndTagStartIndex) + 1);
}
//IE & general fix over all to handle an issue of writeNavDivFinal getting repeatedly called rather then being
// called once. DAG 10.30.13
if (tempLoadedScripts.length > 0) {
for (var i = 0; i < tempLoadedScripts.length; i++) {
cbScript = tempLoadedScripts[i];
document.body.appendChild(cbScript);
//This is to fix IE not loading on 1st load issues. DAG 11.6.13
if (typeof BROWSER == 'undefined') {
BROWSER = '';
} //BROWSER is not always defined!! (scotth 20141010)
if (BROWSER.indexOf('IE') >= 0 && BROWSER.indexOf('11') == -1) {
// MAG 03/19/2014: Added this condition to fix IE11 bug ('onreadystatechange' event deprecated on IE11)
cbScript.onreadystatechange = function() {
//modified by TJ on 9/26/2012, count only when file is loaded
if (this.readyState == undefined || this.readyState == 'complete' || this.readyState == 'loaded') {
loadCount--;
}
if (loadCount == 0) {
writeNavDivFinal(name, div, source, scripts);
}
};
} else {
cbScript.onload = function() {
//modified by TJ on 9/26/2012, count only when file is loaded
if (this.readyState == undefined || this.readyState == 'complete' || this.readyState == 'loaded') {
loadCount--;
}
if (loadCount == 0) {
writeNavDivFinal(name, div, source, scripts);
}
};
}
}
} else {
writeNavDivFinal(name, div, source, scripts);
}
}
}
// if scripts needed to be loaded finish up after they are ready
function writeNavDivFinal(name, div, content, scripts){
if (document.getElementById("app-container") != null) {
document.getElementById("app-container").style.visibility = 'hidden';
addClass('preventClicks', 'mouse');
if (document.getElementById('preventClicks') != null)
document.getElementById('preventClicks').setAttribute('rolloverSound', IMGHOST+'/html5/abc/student_homepage/bt/snd/home.mp3');
removeClass('home-view-wrapper', 'app-view-wrapper-visible');
removeClass('map-view-wrapper', 'app-view-wrapper-visible');
app.dragTut_left.style.display = 'none';
app.dragTut_right.style.display = 'none';
}
//hack for low end mobiel devices to force redraw the document - arsen
setTimeout(function() {
var dummy = document.createElement('DIV');
dummy.style.position = 'absolute';
dummy.style.width = '10px';
dummy.style.height = '10px';
dummy.style.top = '50%';
dummy.style.left = '50%';
dummy.style.marginTop = '-5px';
dummy.style.marginLeft = '-5px';
dummy.style.backgroundColor = 'rgba(255, 255, 255, 0.02)';
document.body.appendChild(dummy);
setTimeout(function() {
document.body.removeChild(dummy);
}, 100);
}, 1000);
/////////////////////////
//if (usingCordova && !isAndroid) {
if (isUnity) {
unityCall.hideSpinner();
} else if(usingCordova){
appCall('hideSpinner'); // Testing
}
var div = document.getElementById(name);
div.style.backgroundImage = '';
div.innerHTML = content;
for(var i=0;i') !== -1) {
enterFullScreen && enterFullScreen();
}
else {
exitFullScreen && exitFullScreen();
}
}
//////////////////////////////////////////////////////////////////////
function removeIntervals(){
for(var i=0;i 0 && mouseYpos > 0) {
/* isBtRot is always true now.
if(typeof USINGAPP != 'undefined' && USINGAPP && APP_VERSION >= 1.94 && !isBtRot)
{
if(APP_VERSION >= 1.97)
appCall('showSparkle:'+(mouseXpos+88)+':'+(mouseYpos+95));
else
appCall('showSparkle:'+(mouseXpos)+':'+(mouseYpos));
return null;
}
*/
if (
//THIS WHOLE FUNCTION NEEDS TO BE RE-DONE /arsen
(MOBILE != '' && document.location.href.search('student_home') > -1)
|| (MOBILE != '') ) {
burst.style.left = (mouseXpos/pageScaleLocal) + 'px';
burst.style.top = (mouseYpos/pageScaleLocal) + 'px';
}
else {
//trace('option 2');
burst.style.left = ((mouseXpos/pageScaleLocal) - 50) + 'px';//diff for android 1.15.14 DAG
burst.style.top = ((mouseYpos/pageScaleLocal) - 50) + 'px';//diff for android 1.15.14 DAG
}
burst.style.zIndex = 40000;
document.body.appendChild(burst);
burst.style.display = '';
var d = new ImageSequence(burst, 9, true);
d.start();
return d;
}
}
/////////////////////////////////////////////////////////////////////
function hexcolor(color) {
var hex = '000000'+color.toString(16);
return '#' + hex.substring(hex.length-6);
}
function rgbacolor(c,a) {
if(a == undefined) a = 1;
return "rgba("+(c>>16&0xFF)+","+(c>>8&0xFF)+","+(c&0xFF)+","+a+")";
}
/////////////////////////////////////////////////////////////////////
function shiftColor(color,pct) {
var r = (color >> 16) & 0xFF;
var g = (color >> 8) & 0xFF;
var b = color & 0xFF;
if(pct < 0) {
r = r + Math.round(r*pct);
g = g + Math.round(g*pct);
b = b + Math.round(b*pct);
}
else {
r = r + Math.round((255-r)*pct);
g = g + Math.round((255-g)*pct);
b = b + Math.round((255-b)*pct);
}
r = Math.min(255, Math.max(0,r));
g = Math.min(255, Math.max(0,g));
b = Math.min(255, Math.max(0,b));
return ((r << 16) & 0xFF0000) | ((g << 8) & 0xFF00) | (b & 0xFF);
}
/////////////////////////////////////////////////////////////////////
function round(x, places) {
if(places == undefined) places = 0;
var mult = Math.pow(10,places);
return Math.round(x*mult)/mult;
}
/////////////////////////////////////////////////////////////////////
// return t value for highest value of curve
function bezierMax(anchor1, control, anchor2) {
var pos = 0.5;
var diff = 0.25;
var midval = bezierValue(anchor1, control, anchor2, pos);
var max = Math.max(anchor1, anchor2, midval);
for(var i=0;i<6;i++) {
var val1 = bezierValue(anchor1, control, anchor2, pos - diff);
var val2 = bezierValue(anchor1, control, anchor2, pos + diff);
if(val1 > val2) pos -= diff;
else pos += diff;
diff = diff/2;
max = Math.max(max, val1, val2);
}
return pos;
}
/////////////////////////////////////////////////////////////////////
// return t value for lowest value of curve
function bezierMin(anchor1, control, anchor2) {
var pos = 0.5;
var diff = 0.25;
var midval = bezierValue(anchor1, control, anchor2, pos);
var min = Math.min(anchor1, anchor2, midval);
for(var i=0;i<6;i++) {
var val1 = bezierValue(anchor1, control, anchor2, pos - diff);
var val2 = bezierValue(anchor1, control, anchor2, pos + diff);
if(val1 < val2) pos -= diff;
else pos += diff;
diff = diff/2;
min = Math.min(min, val1, val2);
}
return pos;
}
/////////////////////////////////////////////////////////////////////
// bezier t value for any position (if validly on the curve)
function bezierPosition(anchor1, control, anchor2, target) {
if(anchor1 == target) return 0;
var sqroot = control*control - anchor1*anchor2 + anchor2*target - 2*control*target +anchor1*target;
if(sqroot < 0) return 0;
sqroot = Math.sqrt(sqroot);
var val1 = round((anchor1 - control + sqroot)/(anchor2 - 2*control + anchor1),4);
var val2 = round((anchor1 - control - sqroot)/(anchor2 - 2*control + anchor1),4);
if((val1 > 1 || val1 < 0) && (val2 > 1 || val2 < 0)) return 0;
if(val1 > 1 || val1 < 0) return val2;
if(val2 > 1 || val2 < 0) return val1;
if(Math.abs(val1 - anchor1) < Math.abs(val2 - anchor1)) return val1;
return val2;
}
/////////////////////////////////////////////////////////////////////
// return anchor for subsection of curve
function bezierSlice(anchor1, control, anchor2, pos) {
return anchor1 + (control-anchor1)*pos;
}
/////////////////////////////////////////////////////////////////////
// return position for any t value
function bezierValue(anchor1, control, anchor2, pos) {
var Ax = anchor1 + (control-anchor1)*pos;
var Bx = control + (anchor2-control)*pos;
return round((Ax + (Bx-Ax)*pos),2);
}
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// add event listening and dispatching to an object
function enableEventHandling(obj)
{
obj.prototype.addEventListener = function(type, func, bubbles) {
if(typeof(func) != 'function') return;
if(this.eventListeners == undefined) this.eventListeners = new Array();
for(var i=0;i= 0; i--) {
eventListType = eventList[i].hasOwnProperty('type') ? eventList[i].type : null;
if(eventListType == type_){
if(eventList[i].func) eventList[i].func.call(this, evt);
}
}
};
}
// returns currentTarget for an event cross-browser
function getEventTarget(event) {
event = event || window.event;
//added by MS, needed for IE8
if(window.attachEvent && event.customTarget) {
return event.customTarget;
}
var obj = (event.currentTarget) ? event.currentTarget : (event.srcElement) ? event.srcElement : event.customTarget; //modified
// by TJ on 2/6/2013, if regular event target is null, use custom event target
if((obj == null || obj == undefined) && window.event) obj = window.event.srcElement;
if((obj == null || obj == undefined) && this != window) obj = this;
return obj;
}
// stop event from propagating
function cancelEvent(event) {
if(event) {
if(event.stopPropagation){event.stopPropagation();}
if(event.preventDefault){event.preventDefault();}
event.cancelBubble = true;
event.cancel = true;
//event.returnValue = false;
}
}
function stopPropagation(event) {
if(event) {
if(event.stopPropagation)
event.stopPropagation();
event.cancelBubble = true;
}
}
////////////////////////////////////
function assignObjectId(obj) {
if(obj == null || obj == undefined) return null;
object_list.push(obj);
//obj.id = 'object_'+object_list.length;
return object_list.length;
}
function getObjectById(id) {
//var id = parseInt(idstr.substring(7));
if(id <= 0 || id > object_list.length) return null;
return object_list[id-1];
}
function getObjectByRef(domElement, attrid) {
if(domElement) {
var objrefid = domElement.getAttribute(attrid);
return getObjectById(objrefid);
}
}
////////////////////
//Opacity function compatible with IE 8
//added by JCD 8-14-2012
function setElementOpacity(node, opacity) //opacity should be between 0 and 1
{
if(opacity > 1){opacity = 1;}else if(opacity < 0){opacity = 0;}
node.style.opacity = opacity;
if(nohtml5) node.style.filter = 'alpha(opacity=' + Math.round(opacity * 100) + ')';
}
////////////////////
function getCookie(cname) {
var cookies=document.cookie.split(";");
for(var i=0;i 0) {
document.cookie = cname + "=" + encodeURI(value) + "; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
limit--;
}
document.cookie = cname + "=" + encodeURI(value) + "; expires=" + exdate.toUTCString() + "; domain=" + domain + "; path=/";
}
/**
* Same as setCookie, but takes expiration seconds instead of days, and if
* expiry is undefined then cookie will expire with session.
*/
function setCookie2(cname, value, expireSecs) {
var expiry = '';
if (typeof expireSecs !== 'undefined') {
var exdate = new Date();
exdate.setSeconds(exdate.getSeconds() + expireSecs);
expiry = ';expires=' + exdate.toUTCString();
}
var domain = '.' + (/\babcmouse\b.*$/.exec(document.domain) || [''])[0];
var limit = 5;
while (getCookie(cname) != '' && limit > 0) {
document.cookie = cname + "=" + encodeURI(value) + "; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
limit--;
}
document.cookie = cname + "=" + encodeURI(value) + expiry + "; domain=" + domain + "; path=/;";
}
////////////////////
// Remove cookie by cookie name. 5/28/2014 RL
function removeCookie(cname) {
document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
var domain = '.' + (/\babcmouse\b.*$/.exec(document.domain) || [''])[0];
document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=" + domain + "; path=/";
}
/////////////////////////////
function setNavCookie(value){
var exdate = new Date();
var overideContinue = getCookie('overrideContinueTo');
if(overideContinue != ''){
value = overideContinue;
setCookie('overrideContinueTo','',-1);
}
if (isUnity) {
unityCall.clearCookie('continueTo');
} else if(deviceType == 'ios'){
//Delete cookie for IOS
appCall('deleteCookieWithName:continueTo');
}
removeCookie('continueTo');// This is done because this cookie has been set to undefined and is causing users to
// load
// up a 404 page if the continue a coloring activity from a
// coloring activity.
setCookie('continueTo',value,365);
}
/////////////////////////////////////////////////////////////////////
function comingSoon(cs_layout){
showPopup('coming_soon.php?cs_layout='+cs_layout);
}
/////////////////////////////////////////////////////////////////////
function Authenticator() // constructor
{
// used by popups/password
// methods are defined when popup is created
}
enableEventHandling(Authenticator);
function YesNoPopup() // constructor
{
// used by popups/password
// methods are defined when popup is created
}
enableEventHandling(YesNoPopup);
function HelpTopics() // constructor
{
//made for helpTopic
}
enableEventHandling(HelpTopics);
////////////////////////////////////////////
// shows popup unless the cookie says pw was checked not too long ago
// added by jcd 2012-10-16
function pwVerifyPopup(url, divid)
{
if(window.userIsParent != true && !(getCookie('pwcheck') == 'true'))
{showPopup(url, divid);}
}
//////////////////////////////////////
// sets a cookie indicating the password has been verified.
// added by jcd
function setPwVerifyCookie()
{
//set cookie indicating password has been verified
var cookieLifeMinutes = 10;
var now = new Date();
var exdate = new Date();
var domain = '.' + (/\babcmouse\b.*$/.exec(document.domain) || [''])[0];
exdate.setTime(now.getTime() + 1000 * 60 * cookieLifeMinutes);
removeCookie('pwcheck');
document.cookie = 'pwcheck=true; expires=' + exdate.toUTCString() + '; domain=' + domain + ';path=/';
}
function setMyAccountAccessCookie(minutes)
{
//set cookie indicating password has been verified - arsen
var cookieLifeMinutes = minutes;
var now = new Date();
var exdate = new Date();
exdate.setTime(now.getTime() + 1000 * 60 * cookieLifeMinutes);
document.cookie = 'myaccountaccess=true; expires=' + exdate.toUTCString() + ';path=/';
}
/////////////////////////////////////////////////////////////////////////////
function buildRegSideBar(number){
document.getElementById('progress_panel').style.visibility='inherit';
switch(number){
case 1: break;
case 2:
if (!isUnity) {
appCall('mml:#green_dot_1.hidden=0');
appCall('mml:#progress_step_2.alpha=1');
}
document.getElementById('green_1').style.visibility='inherit';
document.getElementById('blue_2').style.visibility='inherit';
document.getElementById('prog_back_2').style.visibility='inherit';
document.getElementById('prog_2').style.opacity='1';
document.getElementById('blue_span_2').style.opacity ='1';
break;
case 3:
if (!isUnity) {
appCall('mml:#green_dot_1.hidden=0');
appCall('mml:#progress_step_2.alpha=1');
appCall('mml:#green_dot_2.hidden=0');
appCall('mml:#progress_step_3.alpha=1');
}
document.getElementById('green_1').style.visibility='inherit';
document.getElementById('green_2').style.visibility='inherit';
document.getElementById('blue_2').style.visibility='inherit';
document.getElementById('blue_3').style.visibility='inherit';
document.getElementById('prog_back_2').style.visibility='inherit';
document.getElementById('prog_back_3').style.visibility='inherit';
document.getElementById('prog_2').style.opacity='1';
document.getElementById('prog_3').style.opacity='1';
document.getElementById('blue_span_2').style.opacity ='1';
document.getElementById('blue_span_3').style.opacity='1';
break;
case 4:
if (!isUnity) {
appCall('mml:#green_dot_1.hidden=0');
appCall('mml:#progress_step_2.alpha=1');
appCall('mml:#green_dot_2.hidden=0');
appCall('mml:#progress_step_3.alpha=1');
appCall('mml:#green_dot_3.hidden=0');
appCall('mml:#progress_step_4.alpha=1');
}
document.getElementById('green_1').style.visibility='inherit';
document.getElementById('green_2').style.visibility='inherit';
document.getElementById('green_3').style.visibility='inherit';
document.getElementById('blue_2').style.visibility='inherit';
document.getElementById('blue_3').style.visibility='inherit';
document.getElementById('blue_4').style.visibility='inherit';
document.getElementById('prog_back_2').style.visibility='inherit';
document.getElementById('prog_back_3').style.visibility='inherit';
document.getElementById('prog_back_4').style.visibility='inherit';
document.getElementById('prog_2').style.opacity='1';
document.getElementById('prog_3').style.opacity='1';
document.getElementById('prog_4').style.opacity='1';
document.getElementById('blue_span_2').style.opacity ='1';
document.getElementById('blue_span_3').style.opacity='1';
document.getElementById('blue_span_4').style.opacity='1';
break;
case 5:
if (!isUnity) {
appCall('mml:#green_dot_1.hidden=0');
appCall('mml:#progress_step_2.alpha=1');
appCall('mml:#green_dot_2.hidden=0');
appCall('mml:#progress_step_3.alpha=1');
appCall('mml:#green_dot_3.hidden=0');
appCall('mml:#progress_step_4.alpha=1');
appCall('mml:#green_dot_4.hidden=1');
}
document.getElementById('green_1').style.visibility='inherit';
document.getElementById('green_2').style.visibility='inherit';
document.getElementById('green_3').style.visibility='inherit';
document.getElementById('green_4').style.visibility='inherit';
document.getElementById('blue_2').style.visibility='inherit';
document.getElementById('blue_3').style.visibility='inherit';
document.getElementById('blue_4').style.visibility='inherit';
document.getElementById('prog_back_2').style.visibility='inherit';
document.getElementById('prog_back_3').style.visibility='inherit';
document.getElementById('prog_back_4').style.visibility='inherit';
document.getElementById('prog_2').style.opacity='1';
document.getElementById('prog_3').style.opacity='1';
document.getElementById('prog_4').style.opacity='1';
document.getElementById('blue_span_2').style.opacity ='1';
document.getElementById('blue_span_3').style.opacity='1';
document.getElementById('blue_span_4').style.opacity='1';
break;
}
}
// Added by MS, this is needed for IE8
if(!Array.prototype.indexof) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
function track(tag, kvp, redirectUrl)
{
var vars = {tag: tag, kvp: kvp};
if (
typeof digitalData != 'undefined' &&
typeof digitalData.page != 'undefined' &&
typeof digitalData.page.pageInfo != 'undefined' &&
typeof digitalData.page.pageInfo.page_detail != 'undefined'
) {
vars.page_detail = digitalData.page.pageInfo.page_detail;
}
if(redirectUrl != null) {
ajax('/xml/track.php', vars, function(){
if(typeof(redirectUrl) == 'function') {
redirectUrl.call();
} else {
location.href = redirectUrl;
}
});
} else {
ajax('/xml/track.php', vars, function(){});
}
}
function setFlashCookie(id, cookiename, cookievalue)
{
var vars = new Object();
if(id == undefined | id == 0 | cookiename == undefined |cookievalue == undefined )
return;
var key = id + "|~|" + cookiename;
vars[key] = cookievalue;
ajax("/xml/cookie_update.php", vars, function(){});
}
//added by TJ on 8/16/2013, if your activity uses bad word filter, be sure call this function when page is loaded to
// grab data.
function BadWordFilter(_string, _exact_match)
{
if(_exact_match == undefined) _exact_match = true;
if(badword_list.length == 0)
{
ajax('/xml/badwordslist.php', '', function(_result){
for(var i = 0; i < _result.words.length; i++)
{
str = '';
for(var j = 0; j < _result.words[i].length; j+=2)
{
str += String.fromCharCode(parseInt(_result.words[i].substr(j, 2), 16));
}
badword_list.push(str);
}
});
return undefined;
}
else if(_exact_match) //quick search mode, check string matches exactly with one of bad word lists.
{
if(badword_list.indexOf(_string.toLowerCase()) != -1) return true;
return false;
}
else //if exact match option is set to false, it will go through each list to check if string contains badword
{
for(var i = 0; i < badword_list.length; i++)
{
if(_string.toLowerCase().indexOf(badword_list[i]) != -1) return true;
}
return false;
}
}
function isEmpty(obj) {
// null and undefined are empty
if (obj == null) return true;
// Assume if it has a length property with a non-zero value
// that that property is correct.
if (obj.length && obj.length > 0) return false;
if (obj.length === 0) return true;
for (var key in obj) {
if (hasOwnProperty.call(obj, key)) return false;
}
// Doesn't handle toString and toValue enumeration bugs in IE < 9
return true;
}
/////////////////////////////////
//Added By MG 11/25/13 - Stops a div from being selected on doulbe click in and improve performance in IE9 & IE10
function stopDragEvent(div)
{
var divelement = document.getElementById(div);
for( var i=0; i< divelement.children.length; i++)
{
divelement.children[i].setAttribute('draggable', false);
divelement.children[i].setAttribute('unselectable', 'on');
if(divelement.children[i].tagName == 'DIV')
{
stopDragEvent(divelement.children[i].id);
}
}
}
/////////////////////////////////////
//Added by MG 11/25/13 - Used to detect if mousevent is being called by the Left button click
//Returns Boolean
function detectLeftButton(e)
{
e = e || window.event;
var gamebutton;
if (e.which == null)
{
gamebutton = (e.button < 2) ? 'left' :
((e.button == 4) ? 'middle' : 'right');
}
else
{
gamebutton = (e.which < 2) ? 'left' :
((e.which == 2) ? 'middle' : 'right');
}
if(gamebutton == 'left')
{
return true;
}
else
{
return false;
}
}
// Arsen Ghazaryan - add ".is-scrollable" to any html element to enable scrolling/touchmove event
function touchMove(event) {
//alert('test');
if(! hasClass(event.target.id, 'is-scrollable')) {
event.preventDefault();
}
else {
return true;
}
}
/**
* Shorter DOM functions
*/
function hasClass(id, name){
var el = typeof id == 'string' ? document.getElementById(id) : id;
if (!el){
return;
}
return new RegExp('(\\s|^)'+name+'(\\s|$)').test(el.className);
};
function addClass(id, name){
var el = typeof id == 'string' ? document.getElementById(id) : id;
if (el == null)
return;
if (!hasClass(el, name)) { el.className += (el.className ? ' ' : '') +name; }
};
function removeClass(id, name){
var el = typeof id == 'string' ? document.getElementById(id) : id;
if (el == null)
return;
if (hasClass(el, name)) {
el.className=el.className.replace(new RegExp('(\\s|^)'+name+'(\\s|$)'),' ').replace(/^\s+|\s+$/g, '');
}
};
/////////////////////////////////////
//add by TM 12/20/13 to use when listening for the touchcancel event. to fix touch movement issues on android
function touchCancelPreventDefault(event)
{
event.preventDefault();
}
// for activity display instruction popup. RL 7/7/2014 - modded by Len - 8/27/14
function checkInstructions(cid) {
var vars = {action:'hasdesc',cid:cid};
ajax('/html5/xml/curriculum_description.php', vars, function(hasDesc){
if(hasDesc && !(uinfo.settings.displayInstructions == 'no')){
showPopup('instructions.php?cid='+cid);
}else{
var snd = SoundControl.addContentSound(IMGHOST+'/snd/color/page_audio/default_audio_'+cid+'.mp3');
snd.play();
}
});
}
//////////////////////////////////
function keys(object) {
var results = [];
for (var property in object) {
if (object.hasOwnProperty(property)) {
results.push(property);
}
}
return results;
}
/////////////////////////////////////
//added by marc martinez - 2014/02/20
//allows control of ticket machine screen outside of gametracker instance.
function hideTicketMachine(){
try{
document.getElementById('tm_morebtn').style.pointerEvents = 'none';
document.getElementById('tm_playagainbtn').style.pointerEvents = 'none';
document.getElementById('tm_playagainlbl').style.pointerEvents = 'none';
document.getElementById('tm_favbtn').style.pointerEvents = 'none';
document.getElementById('tm_contbtn').style.pointerEvents = 'none';
document.getElementById('tm_contlbl').style.pointerEvents = 'none';
document.getElementById('tm_shoppingbtn').style.pointerEvents = 'none';
document.getElementById('tm_shoppinglbl').style.pointerEvents = 'none';
document.getElementById('tm_learningPathbtn').style.pointerEvents = 'none';
document.getElementById('tm_learningPathlbl').style.pointerEvents = 'none';
if(document.getElementById('ticket_machine_top')){document.getElementById('ticket_machine_top').style.left = '-135px';}
if(document.getElementById('ticket_machine_bottom')){document.getElementById('ticket_machine_bottom').style.left = '-135px';}
if(document.getElementById('ticket_machine_mask')){document.getElementById('ticket_machine_mask').style.width = '0px';}
if(document.getElementById('ticket_number_holder')){document.getElementById('ticket_number_holder').style.display = 'block';}
if(document.getElementById('ticket_navigation')){document.getElementById('ticket_navigation').style.visibility = 'hidden'; document.getElementById('ticket_navigation').style.display= 'none';}
}catch(a){}
}
/////////////////////////////////////
//added by ET - 2014/07/24
//allows control of tracking of more games on the ticket machine
function dtmMore(){
dtmVars('link name', 'tickets more');
dtmTrack('link click');
}
function dtmContinue(){
dtmVars('link name', 'tickets continue');
dtmTrack('link click');
}
function dtmPlayAgain(){
dtmVars('link name', 'tickets play again');
dtmTrack('link click');
}
/////////////////////////////Ticket Machine Tracking for More value events
function ticketMachineMoreBooks(){
dtmMore(); loadPage('/html5/abc/bookshelf'); hideTicketMachine();
}
function ticketMachineMoreSongs(){
dtmMore(); loadPage('/html5/abc/musicshelf'); hideTicketMachine();
}
function ticketMachineMoreArt(){
dtmMore(); loadPage('/html5/abc/colors'); hideTicketMachine();
}
function ticketMachineMorePuzzles(){
dtmMore(); loadPage('/html5/abc/puzzles'); hideTicketMachine();
}
function ticketMachineMoreBasics(){
dtmMore();loadPage('/html5/abc/basics'); hideTicketMachine();
}
function ticketMachineMoreGames(){
dtmMore();loadPage('/html5/abc/games'); hideTicketMachine();
}
function ticketMachineMorePrints(){
dtmMore(); loadPage('/html5/abc/print'); hideTicketMachine();
}
//////// Child Setiings
function dtmGeneralSettings(){
dtmVars('link name','child settings general settings');
dtmTrack('link click');
}
//////////////////////////////////////////
//Fix for IE, IE doesn't have a console object
if(typeof(console) == 'undefined') {
var console = {};
console.log = function() {
//fix for IE
};
}
/**
* Disable site shell buttons by placing semi transparent cover on top of them.
* @param string template Site rotation like "round10"
* @author Arsen Ghazaryan
*/
function disableShellButtons(template) {
var coverContainer = '';
switch (template) {
case 'round10':
coverContainer = 'panel-left';
break;
// case 'oldHtml5':
// coverContainer = 'panel-left';
// break;
}
if (coverContainer != '') {
domCoverContainer = document.createElement('DIV');
domCoverContainer.id = 'panel-left-cover-mask';
domCoverContainer.style.position = 'absolute';
domCoverContainer.onclick = doNothing;
domCoverContainer.style.top = '0px';
domCoverContainer.style.left = '0px';
domCoverContainer.style.width = '100%';
domCoverContainer.style.height = '100%';
domCoverContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
document.getElementById(coverContainer).appendChild(domCoverContainer);
}
}
/**
* Remove site shell buttons cover. Reference: disableShellButtons(template)
* @param string template Site rotation like "round10"
* @author Robert Lai
*/
function enableShellButtons(template) {
var coverContainer = '';
switch (template) {
case 'round10':
coverContainer = 'panel-left';
break;
// case 'oldHtml5':
// coverContainer = 'panel-left';
// break;
}
if (coverContainer != '') {
domCoverContainer = document.getElementById('panel-left-cover-mask');
if (domCoverContainer) {
domCoverContainer.parentNode.removeChild(domCoverContainer);
}
}
}
//---------------------------------------------------------------------------------->
/**
* ApiService
* @class
* @classdesc Calls the AbcMouseWebServiceLayer api. Acts as a static class and doesn't need to be instantiated
* @author Brandon Turner
* @version 0.1
*/
var ApiService =
{
/** @member {Object} */
endpoints: {
},
/**
* @type {boolean}
*/
retrieved_endpoints:false,
/**
* @type {boolean}
* Set this to true to enable debugging messages
*/
DEBUG:false,
/** @constant
* @type {string}
* @default
*/
ENUMERATE_ENDPOINT:'/apis/abc/0.1/json/Resource/Enumerate/init',
api_domains: {},
// check for environment for debug flag
/**
* Makes an Ajax call to the Enumerate Resource to return endpoints in AbcMouseWebServiceLayer
* @method
* @memberof ApiService
* @todo How do I do this without setting async to false
*/
setEndpoints:function()
{
try {
ajax(ApiService.ENUMERATE_ENDPOINT,'',ApiService.constructEndpoint,ApiService,false);
} catch(e) {
if (ApiService.DEBUG) {
console.log('Error making AJAX call to set API endpoints');
console.log('Error message: ' + e.message)
}
}
},
/**
* Callback function that takes the response(data), parses it as JSON, and populates the endpoint object
* with key value pairs mapping endpoint_name to endpoint_url
* @method
* @memberof ApiService
* @param {string} data Ajax Response from httpRequest in setEndpoints function
*/
constructEndpoint:function(json)
{
if (json.hasOwnProperty('success') && (json.success == 'TRUE' )) {
// Sets the api endpoints
ApiService.api_domains = json.payload.api_domains;
for (var endpoint in json.payload.api_endpoints) {
ApiService.endpoints[endpoint] = json.payload.api_domains.api_root_url.slice(json.payload.api_domains.api_root_url.indexOf('apis'))
+ json.payload.api_endpoints[endpoint];
}
}
ApiService.retrieved_endpoints = true;
},
/**
* Calls the AbcMouseWebServiceLayer. If endpoint_String(optional) is not defined, get's all endpoints and defaults
* to the store_get endpoint
* @method
* @memberof ApiService
* @param {string} endpoint_string The name of the api endpoint that you want to call.
* @param {object} params (optional) Post variables object where arguments -> Name of API Catalog
* @param {function} callback Callback function to handle the response from the API call
*/
call:function(endpoint_string, params, callback)
{
endpoint_string = endpoint_string || undefined;
if (ApiService.retrieved_endpoints == false) {
ApiService.setEndpoints();
}
if (ApiService.endpoints.hasOwnProperty(endpoint_string)) {
try {
ajax(ApiService.endpoints[endpoint_string], params, callback,ApiService, true);
} catch(e) {
if (ApiService.DEBUG) {
console.log('Error making AJAX call to API endpoints');
console.log('Error message: ' + e.message);
}
}
} else {
if (ApiService.DEBUG) {
console.log('Error: endpoint string is incorrect or has not been set');
}
}
}
}
//////////////////////////////////////////
// File Download function.
// Added 4/30/2014 Robert Lai
//
// It's used to download file by passing the file path to this function
// It used '/html5/abc/file_download.php' together to perform the action
//
// sUrl: File Path to the downloading file
// The downloading file is set to the IMGHOST directory
// eg: 'html5/popups/library_resources/library_printoutflyer.pdf'
// Example:
// downloadFile('html5/popups/library_resources/library_printoutflyer.pdf');
//////////////////////////////////////////
function downloadFile(sUrl) {
window.downloadFile.isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
window.downloadFile.isSafari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
window.downloadFile.isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
window.downloadFile.isIE = navigator.userAgent.toLowerCase().indexOf('ie') > -1;
// iOS devices do not support downloading. We have to inform user about this.
if (/(iP)/g.test(navigator.userAgent)) {
alert('Your device does not support files downloading. Please try again in desktop browser.');
return false;
}
sUrl = window.location.origin+'/artwork/'+sUrl;
downloadFileWithAjax(sUrl);
return true;
}
function downloadFileWithAjax(sUrl) {
var ua = navigator.userAgent;
var re = new RegExp("Trident/");
var re2 = new RegExp("Edge/");
if ((navigator.appName == 'Netscape') && ((re.exec(ua) != null) || (re2.exec(ua) != null))) {
var oReq = new XMLHttpRequest();
oReq.open("GET", sUrl, true);
oReq.responseType = "arraybuffer";
oReq.onload = function (oEvent) {
var newBlob = new Blob([new Uint8Array(oEvent.target.response)]);
window.navigator.msSaveOrOpenBlob(newBlob, "download_resource");
};
oReq.send(null);
}
else {
var oReq = new XMLHttpRequest();
oReq.open("GET", sUrl, true);
oReq.responseType = "blob";
oReq.onload = function (oEvent) {
var blob = oReq.response;
if (blob) {
var a = new FileReader();
a.onload = function(e) {
var anchor = document.createElement("a")
anchor.download = 'download_resource';
anchor.href = e.target.result;
document.body.appendChild(anchor);
setTimeout(function(){
anchor.click();
});
document.body.removeChild(anchor);
delete anchor;
}
a.readAsDataURL(blob);
}
};
oReq.send(null);
}
}
/*
Wrapping this in a conditional to check for the "Element" object works on all Browesers, including IE 9-11
If this is not wrapped in the conditional, IE fails
*/
if(window.Element){
Element.prototype.addClass = function(classname) {
if (this.className.search(classname) != -1)
return;
else {
this.className = this.className+' '+classname;
}
}
Element.prototype.removeClass = function(classname) {
if (this.className.search(classname) == -1)
return;
else {
this.className = this.className.replace( classname , '' ).replace(/\s{2,}/g, ' ');
}
}
Element.prototype.hasClass = function(classname){
return (this.className.search(classname) != -1);
};
}
function dtmTrack(eventName){
if(typeof Analytics != 'undefined' && eventName === "link click" && window.linkName)
Analytics.trackClick(window.linkName);
}
function dtmArgs(key1, key2, key3, value){
if(typeof digitalData != 'undefined')
{
if(typeof digitalData[key1][key2] != 'undefined'){
value = value.toString().replace( /([A-Z])/g, " $1" ).toLowerCase();
digitalData[key1][key2][key3] = value;
dtmTrace('DTM Tracking: Property Set Success "' + key1 + '.' + key2 + '.' + key3 +': ' + value + '"');
}
else{
dtmTrace('DTM Tracking: Property Set Failure "' + key1 + '.' + key2 + '.' + key3 +'"');
}
}
}
function dtmTransaction(data){
if(typeof digitalData != 'undefined')
{
if(typeof digitalData['transaction'] != 'undefined'){
//value = value.toString().replace( /([A-Z])/g, " $1" ).toLowerCase();
digitalData['transactionID'] = data['id'];
items = data.items;
for(i=0;i 15) return numVal; //Number too big not supported
var digitAr = numVal.split("");
var textNumber = "";
var h = 0;
for (var i = 0; i < numLength; i++) {
if ((numLength - i) % 3 == 2) {
if ("1" == digitAr[i]) {
textNumber += teenNumTxt[Number(digitAr[i + 1])] + " ";
i++;
h = 1;
} else if (0 != digitAr[i]) {
textNumber += tensNumTxt[digitAr[i] - 2] + " ";
h = 1;
}
} else if (0 != digitAr[i]) {
textNumber += simpleNumTxt[digitAr[i]] + " ";
if ((numLength - i) % 3 == 0) textNumber += "hundred ";
h = 1;
}
if ((numLength - i) % 3 == 1) {
if (h) textNumber += lrgNumTxt[(numLength - i - 1) / 3] + " ";
h = 0;
}
}
if (numLength != numVal.length) {
var j = numVal.length;
textNumber += "point ";
for (var i = numLength + 1; i < j; i++) textNumber += simpleNumTxt[digitAr[i]] + " ";
}
return textNumber.replace(/\s+/g, " ");
}
//////////////////////////////////////////////////////////////
// This is used to disable the Control key combination
function disableCtrlKeyCombination(e) {
// list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'j' , 'w');
var key;
var isCtrl;
// To identify the Ctrl Key has been clicked
if (window.event) {
key = window.event.keyCode; //IE
if (window.event.ctrlKey) {
isCtrl = true;
} else {
isCtrl = false;
}
} else {
key = e.which; //firefox
if (e.ctrlKey) {
isCtrl = true;
} else {
isCtrl = false;
}
}
// if ctrl is pressed, check if other key is in forbidenKeys array
if(isCtrl) {
for (i=0; i
Unlimited Use During Your Membership!
Special Offer
First Month Free
Award-Winning Curriculum
Parents’ Choice Gold Award