function gotoRegistration(source, url) { url = url || "/subscribe"; track("regclick", "src=" + source, url); } function showFeedback(extra) { extra = extra || ""; // showPopup("/feedback/login" + extra, 404, 440); ABCmouseUtils.showIframePopup({url: '/feedback/login/ + extra', width: 404, height: 440}); //pl08042014 } function closeFeedback() { //closePopup(); ABCmouseUtils.closeIframePopup(); //pl08042014 } function showTestimonialBox() { //showPopup("/testimonialbox", 754, 597); ABCmouseUtils.showIframePopup({url: '/testimonialbox', width: 754, height: 597}); //pl08042014 } function closeTestimonialBox() { //closePopup(); ABCmouseUtils.closeIframePopup(); //pl08042014 } function showShortCut(langtype) { switch (langtype) { case "zhs": ABCmouseUtils.showIframePopup({url: '/shortcut_zhs', width:737, height:562}); //pl08042014 break; case "com": ABCmouseUtils.showIframePopup({url: '/shortcut', width:737, height:562}); //pl08042014 break; } } function closeShortCut() { ABCmouseUtils.closeIframePopup(); //pl08042014 } function PopupCover() { if(PopupCover.activeCover != null) return; PopupCover.activeCover = this; var cover = document.createElement("div"); cover.className = "popupcover"; this.close = function() { cover.parentNode.removeChild(cover); PopupCover.activeCover = null; }; document.body.appendChild(cover); } PopupCover.activeCover = null; PopupCover.close = function() { if(PopupCover.activeCover != null) { PopupCover.activeCover.close(); } }; function track(tag, kvp, redirectUrl) { var vars = {tag: tag, kvp: kvp}; if(redirectUrl != null) ajax('/xml/track.php', vars, function(){ location.href = redirectUrl; }); else ajax('/xml/track.php', vars, function(){}); } function showPopup(url, width, height, stylePosition) { var position = getPosition(width, height, (stylePosition) ? stylePosition : ""); var popupIframe = createElement("div", {id: "abcmouse-popup-iframe"}); popupIframe.innerHTML = ''; popupIframe.style.zIndex = "100"; popupIframe.width = width + "px"; popupIframe.height = height + "px"; popupIframe.style.position = (stylePosition) ? stylePosition : "fixed"; popupIframe.style.top = position.y + "px"; popupIframe.style.left = position.x + "px"; popupIframe.style.display = "block"; document.body.appendChild(popupIframe); new PopupCover(); } function closePopup() { var popupIframe = document.getElementById("abcmouse-popup-iframe"); if(popupIframe == null) return; popupIframe.innerHTML = ""; popupIframe.style.display = "none"; popupIframe.parentNode.removeChild(popupIframe); PopupCover.close(); } function resizePopup(height) { var popupIframe = document.getElementById("abcmouse-popup-iframe"); if(popupIframe == null) return; popupIframe.getElementsByTagName("iframe")[0].style.height = height + "px"; } function getPosition(width, height, stylePosition) { var pageSize = getPageSize(); var position = {x: 0, y: 0}; position.x = Math.round((pageSize.width - width)/2); position.y = Math.round((pageSize.height - height)/2); position.x = (position.x < 0) ? 0 : position.x; position.y = (position.y < 0) ? 0 : position.y; if(stylePosition == "absolute") { var scrollingPosition = getScrollXY(); position.x += scrollingPosition.x; position.y += scrollingPosition.y; } return position; } function getPageSize() { var width = 0 var height = 0; if(window.innerWidth == null) { width = document.documentElement.clientWidth; height = document.documentElement.clientHeight; } else { width = window.innerWidth; height = window.innerHeight; } return {width: width, height: height}; } function getScrollXY() { var scrOfX = 0, scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { //IE6 standards compliant mode scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return {x: scrOfX, y: scrOfY}; } function gotoURL(url) { window.location = url; } function setCookie(c_name, value, expiredays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + expiredays); document.cookie = c_name+ "=" + encodeURI(value) + ";domain=abcmouse.com;path=/" + ((expiredays==null) ? "" : ";expires=" + exdate.toUTCString()); } function getCookie(c_name) { if (document.cookie.length>0) { c_start = document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) c_end = document.cookie.length; return decodeURIComponent(document.cookie.substring(c_start,c_end)); } } return ""; } function deleteCookie(name, path, domain) { if (getCookie(name) != "") document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; } function createElement(element, parameters) { var newElement = document.createElement(element); for(var temp in parameters) { if(temp == "className" || temp == "class") { newElement.className = parameters[temp]; //newElement.setAttribute("class", parameters[temp]); } else if(temp == "style") { //work around for IE 7 newElement.style.cssText = parameters[temp]; } else { newElement.setAttribute(temp, parameters[temp]); } } return newElement; } function showElement(element) { element = document.getElementById(element); if(element == null) return; element.style.display = "block"; element.style.visibility = "visible"; } function hideElement(element, useVisibility) { element = document.getElementById(element); if(element == null) return; useVisibility = (useVisibility) ? useVisibility : false; if(useVisibility) { element.style.visibility = "hidden"; } else { element.style.display = "none"; } } function addClassName(element, className) { if(element != null && element.className != null) { element.className = element.className + " " + className; } } function removeClassName(element, className) { var pattern; if(element != null && element.className != null) { //for classes on the that have spaces at the beginning and at the end pattern = RegExp(" +" + className + " +"); element.className = element.className.replace(pattern, " "); //for the first class pattern = RegExp("^" + className + " *"); element.className = element.className.replace(pattern, ""); //for the last class pattern = RegExp(" +" + className + "$"); element.className = element.className.replace(pattern, ""); } } function preText(element, preText, color) { color = color || "#6b6b6b"; if(element.value == preText) { element.value = ""; element.style.color = color; } } function invalidateBackCache() { // necessary for Safari: mobile & desktop } if(typeof window.addEventListener == "function") { window.addEventListener("unload", invalidateBackCache, false); }