var javascriptReady = false; var addToCartRefreshId = null; if (launchModalOnPageLoad === undefined) { var launchModalOnPageLoad = false; var ModalPopupID = "" } if (showVideoOnPageLoad === undefined) { var showVideoOnPageLoad = false; var pageLoadVideoPath = "" } function TrapEnterKey(event, exeFunction) { var keyCode = (event.keyCode) ? event.keyCode : (event.which) ? event.which : event.charCode; if (keyCode == 13) { if (exeFunction) { eval(exeFunction); return false } } } function HideImageOnError(a) { a.style.display = "none" } function DisplayContentModal(a) { Melaleuca.Web.AjaxManager.DisplayContent(a, ReturnDisplayContentModal) } function ReturnDisplayContentModal(a) { getGeneralPopUp(a) } function RadioButtonInRepeater_Click(a, c, b) { re = new RegExp(a + ".*" + c); for (i = 0; i < document.forms[0].elements.length; i++) { elm = document.forms[0].elements[i]; if (elm.type == "radio") { if (re.test(elm.name)) { elm.checked = false } } } b.checked = true } function PageManager(a) { this.PageCountLinkArr = a } PageManager.prototype.SetPageCountLinkStyle = function(b) { for (var a in this.PageCountLinkArr) { this.PageCountLinkArr[a].className = (this.PageCountLinkArr[a].id == b.id) ? "pageCountSelected" : "pageCountNotSelected" } }; function pageLoad() { if (window.showIpodPopup) { window.showIpodPopup(); } javascriptReady = true; if (launchModalOnPageLoad) { showModalPopup(ModalPopupID) } if (showVideoOnPageLoad) { ViewVideo(pageLoadVideoPath) } } function showModalPopup(a) { stopAddAnimation(); $find(a).show(); window.scrollTo(0, 0) } function closeModalPopup(a) { var b = $find(a); if (b) { b.hide() } } function GoToPage(b, d) { var c = b; var a = "/"; if (c.indexOf("/") == 0 && c.length > 1) { c = b.substr(1).toLowerCase() } c = c.toLowerCase(); switch (c) { case "checkout": a = "/ProductStore/Checkout.aspx"; break; case "cart": a = "/ProductStore/Cart.aspx"; break; case "signin": a = "/Shared/SignIn.aspx"; break; case "mypreferences": a = "/MyAccount/MyPreferences.aspx"; break; case "productstore": a = "/ProductStore/ProductStore.aspx"; break; case "helpcenter": a = "/HelpCenter/HelpCenter.aspx"; break; case "introduction": a = "http://www.melaleuca.com/Introduction/"; break; case "myfavorites": a = "/ProductStore/MyFavorites.aspx"; break; default: a = b; break } if (d === undefined) { window.location = a } else { window.open(a, d) } } function RedirectFromDropDown(a) { if ($get(a).options[$get(a).selectedIndex].value != "none") { location = $get(a).options[$get(a).selectedIndex].value } } function executeLinkButton(btnID) { var btn = $get(btnID); if (btn) { try { eval(btn.getAttribute("href")) } catch (err) { window.location = btn.getAttribute("href") } } } function getGeneralPopUp(a) { $get("GeneralMessageContent").innerHTML = a; showModalPopup("GeneralMessageDisplayPopUp") } function gotoProductPage(a) { window.location = "/ProductStore/Product.aspx?sku=" + a } String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, "") }; String.prototype.lTrim = function() { return this.replace(/^\s*/g, "") }; String.prototype.rTrim = function() { return this.replace(/\s*$/g, "") }; function GetValueFromControl(a) { return $get(a).value } function getSelectedValueFromDropDown(a) { var c = null; var b = $get(a); if (b != null) { c = b.options[b.selectedIndex].value } return c } function isBtnEnabled(a) { if (a != null && a.className.search(/disabled/) == -1) { return true } else { return false } } function addToCartRefresh() { if (addToCartRefreshId != null) { __doPostBack(addToCartRefreshId, "") } } function rtnAddToCart(rtn) { if (rtn.Omniture != null) { eval(rtn.Omniture) } if (rtn.Javascript != null) { eval(rtn.Javascript) } else { if (rtn.HtmlMessage != null) { alert(rtn.HtmlMessage) } } addToCartRefresh() } var addToDestTweens = new Array(); function AnimateAddToDest(b, c) { try { elemBtn = b; elemBox = $get("animatedCartBox"); elemDest = $get(c); startPos = findPosition(elemBtn); endPos = findPosition(elemDest); stopAddAnimation(); elemBox.style.left = startPos[0]; elemBox.style.top = startPos[1]; elemBox.style.width = elemBtn.offsetWidth; elemBox.style.height = elemBtn.offsetHeight; elemBox.style.display = "block"; addToDestTweens[0] = t1 = new Tween(elemBox.style, "left", null, startPos[0], endPos[0], 0.8, "px"); addToDestTweens[1] = t2 = new Tween(elemBox.style, "top", null, startPos[1], endPos[1], 0.8, "px"); addToDestTweens[2] = t3 = new Tween(elemBox.style, "width", null, elemBtn.offsetWidth, elemDest.offsetWidth, 0.8, "px"); addToDestTweens[3] = t4 = new Tween(elemBox.style, "height", null, elemBtn.offsetHeight, elemDest.offsetHeight, 0.8, "px"); t2.onMotionFinished = function() { elemBox.style.display = "none" }; t1.start(); t2.start(); t3.start(); t4.start() } catch (a) { } } function stopAddAnimation() { elemBox = $get("animatedCartBox"); elemBox.style.display = "none"; if (addToDestTweens.length > 0) { for (var a = 0, b = addToDestTweens.length; a < b; a++) { addToDestTweens[a].stop() } } } function findPosition(a) { if (typeof (a.offsetParent) != "undefined") { for (var c = 0, b = 0; a; a = a.offsetParent) { c += a.offsetLeft; b += a.offsetTop } return [c, b] } else { return [a.x, a.y] } } function Delegate() { } Delegate.create = function(g, e) { var c = new Array(); var b = arguments.length; for (var d = 2; d < b; d++) { c[d - 2] = arguments[d] } return function() { var a = [].concat(arguments, c); e.apply(g, a) } }; Tween = function(f, g, d, c, b, e, a) { this.init(f, g, d, c, b, e, a) }; var t = Tween.prototype; t.obj = new Object(); t.prop = ""; t.func = function(e, a, g, f) { return g * e / f + a }; t.begin = 0; t.change = 0; t.prevTime = 0; t.prevPos = 0; t.looping = false; t._duration = 0; t._time = 0; t._pos = 0; t._position = 0; t._startTime = 0; t._finish = 0; t.name = ""; t.suffixe = ""; t._listeners = new Array(); t.setTime = function(a) { this.prevTime = this._time; if (a > this.getDuration()) { if (this.looping) { this.rewind(a - this._duration); this.update(); this.broadcastMessage("onMotionLooped", { target: this, type: "onMotionLooped" }) } else { this._time = this._duration; this.update(); this.stop(); this.broadcastMessage("onMotionFinished", { target: this, type: "onMotionFinished" }) } } else { if (a < 0) { this.rewind(); this.update() } else { this._time = a; this.update() } } }; t.getTime = function() { return this._time }; t.setDuration = function(a) { this._duration = (a == null || a <= 0) ? 100000 : a }; t.getDuration = function() { return this._duration }; t.setPosition = function(c) { this.prevPos = this._pos; var b = this.suffixe != "" ? this.suffixe : ""; this.obj[this.prop] = Math.round(c) + b; this._pos = c; this.broadcastMessage("onMotionChanged", { target: this, type: "onMotionChanged" }) }; t.getPosition = function(a) { if (a == undefined) { a = this._time } return this.func(a, this.begin, this.change, this._duration) }; t.setFinish = function(a) { this.change = a - this.begin }; t.geFinish = function() { return this.begin + this.change }; t.init = function(f, g, d, c, b, e, a) { if (!arguments.length) { return } this._listeners = new Array(); this.addListener(this); if (a) { this.suffixe = a } this.obj = f; this.prop = g; this.begin = c; this._pos = c; this.setDuration(e); if (d != null && d != "") { this.func = d } this.setFinish(b) }; t.start = function() { this.rewind(); this.startEnterFrame(); this.broadcastMessage("onMotionStarted", { target: this, type: "onMotionStarted" }) }; t.rewind = function(a) { this.stop(); this._time = (a == undefined) ? 0 : a; this.fixTime(); this.update() }; t.fforward = function() { this._time = this._duration; this.fixTime(); this.update() }; t.update = function() { this.setPosition(this.getPosition(this._time)) }; t.startEnterFrame = function() { this.stopEnterFrame(); this.isPlaying = true; this.onEnterFrame() }; t.onEnterFrame = function() { if (this.isPlaying) { this.nextFrame(); setTimeout(Delegate.create(this, this.onEnterFrame), 0) } }; t.nextFrame = function() { this.setTime((this.getTimer() - this._startTime) / 1000) }; t.stop = function() { this.stopEnterFrame(); this.broadcastMessage("onMotionStopped", { target: this, type: "onMotionStopped" }) }; t.stopEnterFrame = function() { this.isPlaying = false }; t.continueTo = function(a, b) { this.begin = this._pos; this.setFinish(a); if (this._duration != undefined) { this.setDuration(b) } this.start() }; t.resume = function() { this.fixTime(); this.startEnterFrame(); this.broadcastMessage("onMotionResumed", { target: this, type: "onMotionResumed" }) }; t.yoyo = function() { this.continueTo(this.begin, this._time) }; t.addListener = function(a) { this.removeListener(a); return this._listeners.push(a) }; t.removeListener = function(d) { var b = this._listeners; var c = b.length; while (c--) { if (b[c] == d) { b.splice(c, 1); return true } } return false }; t.broadcastMessage = function() { var b = new Array(); for (var f = 0; f < arguments.length; f++) { b.push(arguments[f]) } var g = b.shift(); var d = this._listeners; var c = d.length; for (var f = 0; f < c; f++) { if (d[f][g]) { d[f][g].apply(d[f], b) } } }; t.fixTime = function() { this._startTime = this.getTimer() - this._time * 1000 }; t.getTimer = function() { return new Date().getTime() - this._time }; Tween.backEaseIn = function(g, e, l, k, f, j) { if (h == undefined) { var h = 1.70158 } return l * (g /= k) * g * ((h + 1) * g - h) + e }; Tween.backEaseOut = function(g, e, l, k, f, j) { if (h == undefined) { var h = 1.70158 } return l * ((g = g / k - 1) * g * ((h + 1) * g + h) + 1) + e }; Tween.backEaseInOut = function(g, e, l, k, f, j) { if (h == undefined) { var h = 1.70158 } if ((g /= k / 2) < 1) { return l / 2 * (g * g * (((h *= (1.525)) + 1) * g - h)) + e } return l / 2 * ((g -= 2) * g * (((h *= (1.525)) + 1) * g + h) + 2) + e }; Tween.elasticEaseIn = function(g, e, l, k, f, j) { if (g == 0) { return e } if ((g /= k) == 1) { return e + l } if (!j) { j = k * 0.3 } if (!f || f < Math.abs(l)) { f = l; var h = j / 4 } else { var h = j / (2 * Math.PI) * Math.asin(l / f) } return -(f * Math.pow(2, 10 * (g -= 1)) * Math.sin((g * k - h) * (2 * Math.PI) / j)) + e }; Tween.elasticEaseOut = function(g, e, l, k, f, j) { if (g == 0) { return e } if ((g /= k) == 1) { return e + l } if (!j) { j = k * 0.3 } if (!f || f < Math.abs(l)) { f = l; var h = j / 4 } else { var h = j / (2 * Math.PI) * Math.asin(l / f) } return (f * Math.pow(2, -10 * g) * Math.sin((g * k - h) * (2 * Math.PI) / j) + l + e) }; Tween.elasticEaseInOut = function(g, e, l, k, f, j) { if (g == 0) { return e } if ((g /= k / 2) == 2) { return e + l } if (!j) { var j = k * (0.3 * 1.5) } if (!f || f < Math.abs(l)) { var f = l; var h = j / 4 } else { var h = j / (2 * Math.PI) * Math.asin(l / f) } if (g < 1) { return -0.5 * (f * Math.pow(2, 10 * (g -= 1)) * Math.sin((g * k - h) * (2 * Math.PI) / j)) + e } return f * Math.pow(2, -10 * (g -= 1)) * Math.sin((g * k - h) * (2 * Math.PI) / j) * 0.5 + l + e }; Tween.bounceEaseOut = function(e, a, g, f) { if ((e /= f) < (1 / 2.75)) { return g * (7.5625 * e * e) + a } else { if (e < (2 / 2.75)) { return g * (7.5625 * (e -= (1.5 / 2.75)) * e + 0.75) + a } else { if (e < (2.5 / 2.75)) { return g * (7.5625 * (e -= (2.25 / 2.75)) * e + 0.9375) + a } else { return g * (7.5625 * (e -= (2.625 / 2.75)) * e + 0.984375) + a } } } }; Tween.bounceEaseIn = function(e, a, g, f) { return g - Tween.bounceEaseOut(f - e, 0, g, f) + a }; Tween.bounceEaseInOut = function(e, a, g, f) { if (e < f / 2) { return Tween.bounceEaseIn(e * 2, 0, g, f) * 0.5 + a } else { return Tween.bounceEaseOut(e * 2 - f, 0, g, f) * 0.5 + g * 0.5 + a } }; Tween.strongEaseInOut = function(e, a, g, f) { return g * (e /= f) * e * e * e * e + a }; Tween.regularEaseIn = function(e, a, g, f) { return g * (e /= f) * e + a }; Tween.regularEaseOut = function(e, a, g, f) { return -g * (e /= f) * (e - 2) + a }; Tween.regularEaseInOut = function(e, a, g, f) { if ((e /= f / 2) < 1) { return g / 2 * e * e + a } return -g / 2 * ((--e) * (e - 2) - 1) + a }; Tween.strongEaseIn = function(e, a, g, f) { return g * (e /= f) * e * e * e * e + a }; Tween.strongEaseOut = function(e, a, g, f) { return g * ((e = e / f - 1) * e * e * e * e + 1) + a }; Tween.strongEaseInOut = function(e, a, g, f) { if ((e /= f / 2) < 1) { return g / 2 * e * e * e * e * e + a } return g / 2 * ((e -= 2) * e * e * e * e + 2) + a }; var openHeaders = new Array(); var openDropDowns = new Array(); var overcount = 0; function DropDownOut(a, c, b) { if (overcount <= 0) { c.className = "normalheader"; b.style.display = "none" } } function overdropdown(a) { overcount++ } function outdropdown(a, c, b) { overcount--; if (overcount <= 0) { if (a.timer) { clearTimeout(a.timer) } a.timer = setTimeout(function() { DropDownOut(a, c, b) }, 2000) } } function attachDropDownHooks(b, a) { b.onmouseover = function() { overdropdown(this) }; b.onmouseout = function() { outdropdown(this, b, a) }; a.onmouseover = function() { overdropdown(this) }; a.onmouseout = function() { outdropdown(this, b, a) }; overcount = 1 } function closeDropDowns(a, c) { if (openHeaders.length > 0) { while (openHeaders.length > 0) { var d = openHeaders.pop(); if (d != a) { d.className = "normalheader" } } } if (openDropDowns.length > 0) { while (openDropDowns.length > 0) { var b = openDropDowns.pop(); if (b != c) { b.style.display = "none" } } } } var DoNotOpen = false; function OpenDropDown(c, d, b, a) { if (!DoNotOpen) { var f = $get(c); var e = $get(d); closeDropDowns(f, e); if (e.style.display == "none" || e.style.display == "") { f.className = "shadowheader"; e.style.display = "block"; b(); if (a) { attachDropDownHooks(f, e) } openHeaders.push(f); openDropDowns.push(e) } else { f.className = "normalheader"; e.style.display = "none" } } } function EditTextBoxOnFocus(a, c, b) { var e = $get(a); var d = $get(c); if (e.value == d.value) { e.value = ""; e.className = b } } function EditTextBoxOnBlur(a, c, b) { var e = $get(a); var d = $get(c); if (e.value == "") { e.value = d.value; e.className = b } } function CloseDropDownPopup() { var a = document.getElementsByName("dropDownPopupWrapper"); for (var b = 0; b < a.length; b++) { a[b].innerHTML = "" } } function processKitPromotion(a, g, k, b, f, d, c, j, e) { if (e == undefined) { e = -1 } Melaleuca.Web.AjaxManager.ProcessKitPromotion(a, g, k, j, e, processPromotionReturn); b.innerHTML = b.innerHTML.replace(f, d); b.className = "disabled"; var h = $get("removePromoButton" + a + "_btn"); if (h != null) { h.className = "disabled" } } function processPromotion(a, b, e, g, d, c, h, f) { if (f == undefined) { f = -1 } var l = 1; if (h !== undefined) { var k = $get(h); if (k != null) { l = k.options[k.selectedIndex].text } } Melaleuca.Web.AjaxManager.ProcessPromotion(a, l, f, processPromotionReturn); b.innerHTML = b.innerHTML.replace(g, d); b.className = "disabled"; var j = $get("removePromoButton" + a + "_btn"); if (j != null) { j.className = "disabled" } } function processPromotionReturn(arg) { if (arg.Javascript != null) { eval(arg.Javascript) } } function RemovePromotionIDs(a) { Melaleuca.Web.AjaxManager.RemovePromotions(a, null) } function removePromotion(a) { Melaleuca.Web.AjaxManager.RemovePromotion(a, removePromotionReturn) } function removePromotionReturn(arg) { if (arg.Javascript != null) { eval(arg.Javascript) } } if (!Array.prototype.find) { Array.prototype.find = function(a) { var b = false; for (i = 0; i < this.length; i++) { if (typeof (a) == "function") { if (a.test(this[i])) { if (!b) { b = [] } b.push(i) } } else { if (this[i] === a) { if (!b) { b = [] } b.push(i) } } } return b } } if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(b) { var a = this.length; var c = Number(arguments[1]) || 0; c = (c < 0) ? Math.ceil(c) : Math.floor(c); if (c < 0) { c += a } for (; c < a; c++) { if (c in this && this[c] === b) { return c } } return -1 } };