var loc=location.href,href;href=loc.split("/");href=href[0]+"//"+href[2]+"/";function fixInputBox(a,b){a.value=Math.abs(1*a.value);a.value=(1*a.value).toFixed(b);if("NaN"==a.value)a.value="0";return a}var promo_cto=void 0,promo_code_request,already_showed_message={}; function checkPromoCode(a){promo_code_request&&promo_code_request.cancel();promo_cto&&clearTimeout(promo_cto);promo_cto=setTimeout(function(){var b=escape(a.value);if(a!=$("shopping_cart_promo_code"))try{$("shopping_cart_promo_code").value=b}catch(c){}promo_code_request=(new Request({url:href+"p_include/ajax_func.html",method:"post",onComplete:function(a){promo_cto&&clearTimeout(promo_cto);try{var c=JSON.decode(a);c.message&&!already_showed_message[b]&&(showPopUp(c.message),already_showed_message[b]= !0);if(c.gwp_refresh_page)alert("Coupon Code Accepted! Your free gift will now be added to your cart"),location.href=location.href;c.success&&evaluateGiftCertificatePromotionCodePopUp()}catch(f){}updateShoppingCartValues("",!0)}})).send("func=checkPromoCode&promoCode="+escape(b))},500)}var clear_timeout=void 0; function adjustQuantity(a,b,c,d,e,f){void 0==f&&(f=0);""!=b.value&&fixInputBox(b,0);var g;g=e||0==e?e:b.value;if(b!=$("shopping_cart_product_qty_"+c+"_"+d))try{250<=1*$("shopping_cart_credit_card_total").innerHTML?$("billMeLater_promotion_checkbox").disabled=!1:($("billMeLater_promotion_checkbox").disabled=!0,$("billMeLater_promotion_checkbox").checked=!1)}catch(k){}try{$("shopping_cart_product_qty_"+c+"_"+d).value=g}catch(l){}try{for(var h=JSON.decode($("shopping_cart_bundle_products").value),a= 0;a<h.length;a++)for(e=0;e<h[a].length;e++)if(d==h[a][e].bundle_id)$("product_bundle_qty_"+h[a][e].product_id+"_"+h[a][e].bundle_id).innerHTML=1*h[a][e].qty*1*g}catch(j){}if(0==g)try{$("shopping_cart_product_"+c+"_"+d).addClass("absentProduct")}catch(i){}else try{$("shopping_cart_product_"+c+"_"+d).removeClass("absentProduct"),$("product_warnings_"+c+"_"+d).set("html","")}catch(m){}clear_timeout&&clearTimeout(clear_timeout);clear_timeout=setTimeout(function(){(new Request({url:href+"p_include/ajax_func.html", method:"post",onComplete:function(a){a=JSON.decode(a);if(1==a.changedQty)a.message&&alert(a.message),adjustQuantity(null,b,c,d,a.qty,f);else{try{$("shopping_cart_prodTotal_"+c+"_"+d).innerHTML=a.productSubTotal,updateBingCashBack()}catch(g){}updateShoppingCartValues();clear_timeout&&clearTimeout(clear_timeout)}}})).send("func=adjustQuantity&product_id="+c+"&qty="+g+"&bundle_id="+d+"&distributor_id="+f)},250)} function removeProduct(a,b){try{var c=$("shopping_cart_product_"+a+"_"+b).rowIndex;$("shopping_cart_product_table").deleteRow(c);removeProductFromStoredArray(a);resetGiftCartIfPurchasingGiftCard();validateGiftCertPaymentAmount();figureOutCreditCardPaymentAmount()}catch(d){}(new Request({url:href+"p_include/ajax_func.html",method:"post",evalScripts:!0,onComplete:function(a){$("shopping_cart_promo_code")&&checkPromoCode($("shopping_cart_promo_code"));if("0"==a&&-1!=window.location.toString().indexOf("checkout.html"))window.location= "checkout.html"}})).send("func=removeProduct&product_id="+a+"&bundle_id="+b)} function addProduct(a,b,c,d){void 0==d&&(d=0);c||(c=1);c=Math.abs(c);!b||null==b||void 0==b?b=0:0!=b&&(a="");allowCartToClose=!1;(new Request({url:href+"p_include/ajax_func.html",method:"post",evalScripts:!0,onComplete:function(c){var c=JSON.decode(c),d;d=document.createElement("span");d.id="span_mini_cart_product_"+a+"_"+b;d.innerHTML=c.html;if(!productAlreadyInCart){var g=$("miniCartProducts").firstChild;$("miniCartProducts").insertBefore(d,g)}$("shopping_cart_promo_code")&&checkPromoCode($("shopping_cart_promo_code")); allowCartToClose=!0;c.message?showPopUp(c.message):eval(c.omniture)}})).send("func=addProduct&product_id="+a+"&bundle_id="+b+"&qty="+c+"&distributor_id="+d)} function addProductNew(a,b,c,d,e){void 0==d&&(d=0);c||(c=1);c=Math.abs(c);void 0==e&&(e=!0);!b||null==b||void 0==b?b=0:0!=b&&(a="");(new Request({url:href+"p_include/ajax_func.html",method:"post",evalScripts:!0,onComplete:function(a){a=JSON.decode(a);$("shopping_cart_promo_code")&&checkPromoCode($("shopping_cart_promo_code"));if(a.message&&a.remainOnPage)showPopUp(a.message);else if(a.message&&!a.remainOnPage)showPopUp(a.message,void 0,"location.href='/cart.html'; closePopUp");else{try{eval(a.omniture)}catch(b){}if(e)location.href= "/cart.html"}}})).send("func=addProduct&product_id="+a+"&bundle_id="+b+"&qty="+c+"&distributor_id="+d)}function addProductWithOptions(a,b){addProduct(a.value,0,b)} function addRecurringProduct(a,b){var c=$("recurringQty").value,d=$("frequency").value;if(0==d)showPopUp('This product cannot be added to your car as "automatic shipment" because you have not selected how often you would like to receive the product.\n\nPlease select a frequency to add your product to the cart.');else{if(!b||""==b)b=0;addProductNew(a,b,1,0,!1);(new Request({method:"post",url:href+"p_include/ajax_func.html",onComplete:function(){location.href="/cart.html"}})).send("func=addRecurringProduct&product_id="+ a+"&bundle_id="+b+"&qty="+c+"&frequency="+d)}}function addSubscriptionProduct(a,b){var c=$("subscriptionQty").value;addProduct(a,b,1);if(!b||""==b)b=0;(new Request({method:"post",url:href+"p_include/ajax_func.html",onComplete:function(){Subscriptions.close();adjustQuantity("",$("mini_cart_product_qty_"+a+"_"+b),a,b,c);$("mini_cart_subscribe_notice_"+a+"_"+b).set("html","SUBSCRIPTION")}})).send("func=addSubscriptionProduct&product_id="+a+"&bundle_id="+b+"&qty="+c)} function setPromotionCodeAndAddProduct(a,b,c){(new Request({method:"post",url:href+"p_include/checkout_ajax_func.html",onComplete:function(){$("mini_cart_promoCode").value=b;addProduct(a,0,c)}})).send("func=setPromotionCode&promotionCode="+b)}var shipping_cto=void 0;function updateShippingOptions(){shipping_cto&&clearTimeout(shipping_cto);shipping_cto=setTimeout(function(){updateShoppingCartValues();shipping_cto&&clearTimeout(shipping_cto)},400)} function updateShippingType(a){var b,c,d;"NULL"==a.value||"0"==a.value?(a=0,d=c=b=""):(d=a.value.split("|"),a=d[1],b=d[0],c=d[2],d=d[3]);(new Request({url:href+"p_include/ajax_func.html",method:"post",onComplete:function(){updateShoppingCartValues()}})).send("func=updateShippingType&price="+a+"&id="+b+"&name="+c+"&carrier="+d)}var update_values_request; function updateShoppingCartValues(a,b){update_values_request&&update_values_request.cancel();if(a&&1==a)$("zipCode_full").value="";var c,d;c=$("shopping_cart_shippingDropDown")?!0:!1;var e,f="";$("shopping_cart_shippingDropDown_full")?(d=!0,e=$("zipCode_full").value,f=$("countryDD_full").value):d=!1;update_values_request=(new Request({url:href+"p_include/ajax_func.html",method:"post",onComplete:function(a){a=JSON.decode(a);if(c||d){$("shopping_cart_subTotal").innerHTML=parseFloat(a.subTotal).toFixed(2); $("shopping_cart_grand_total").innerHTML=parseFloat(a.grandTotal).toFixed(2);try{var e=1==a.expedited?'<br /><span class="justRed">Orders placed after 10 a.m. MST ship the next business day. This excludes weekends and U.S. holidays.</span>':"";$(d?"shopping_cart_shippingDropDown_full":"shopping_cart_shippingDropDown").innerHTML=a.shippingDrowDown+e;250<=1*$("shopping_cart_credit_card_total").innerHTML?$("billMeLater_promotion_checkbox").disabled=!1:($("billMeLater_promotion_checkbox").disabled=!0, $("billMeLater_promotion_checkbox").checked=!1)}catch(f){}1==a.discountIsRecurring?($("shopping_cart_recurring_orders_discount").innerHTML=parseFloat(a.promoCodeDiscount).toFixed(2),$("shopping_cart_promo_discount").innerHTML=parseFloat("0.00").toFixed(2),$("biggerCouponThanRecurringMessage").innerHTML="",""!=$("shopping_cart_promo_code").value&&0==1*a.promotionCodeShippingDiscount&&0<a.promoCodeDiscount?$("biggerRecurringThanCouponMessage").innerHTML="<br>The automatic shipment discount has been applied because it is greater than your coupon code discount.": $("biggerRecurringThanCouponMessage").innerHTML=""):($("biggerRecurringThanCouponMessage").innerHTML="",$("shopping_cart_promo_discount").innerHTML=parseFloat(a.promoCodeDiscount).toFixed(2),$("shopping_cart_recurring_orders_discount").innerHTML=parseFloat("0.00").toFixed(2),1==a.recurringProductsInCart&&0<a.promoCodeDiscount?$("biggerCouponThanRecurringMessage").innerHTML="<br>Your coupon code gives you a greater discount than the automatic shipment discount.":$("biggerCouponThanRecurringMessage").innerHTML= "");try{$("shopping_cart_shippingAmount").innerHTML=parseFloat(a.shippingAmount).toFixed(2)}catch(h){}$("shopping_cart_tax_amount").innerHTML=parseFloat(a.tax).toFixed(2);0<1*a.promoCodeDiscount&&0==a.discountIsRecurring||0<1*a.promotionCodeShippingDiscount||a.coupon_gwp_eligible?$("shopping_cart_promo_image").src=href+"p_images/positivePromoCodeIndicatorGray.jpg":$("shopping_cart_promo_image").src=href+"p_images/pendingPromoCodeIndicator.gif";try{validateGiftCertPaymentAmount(0,1),figureOutCreditCardPaymentAmount(), $(countryDD).value=a.country}catch(j){}}e="";e=1<a.productQty||0==a.productQty?" ITEMS":" ITEM";$("headerNumProducts").innerHTML=a.productQty+e;$("headerGrandTotal").innerHTML=parseFloat(a.grandTotal).toFixed(2);for(var i in a.couponExemptionMessages)if($(i))$(i).innerHTML=a.couponExemptionMessages[i];b&&$("points_amount_used")&&validatePointsPaymentAmount()}})).send("func=updateShoppingCartValues&on_checkout_page="+c+"&zipCode="+e+"&country="+f)} function acceptTOS(a){a=a.checked;(new Request({url:"p_include/ajax_func.html",method:"post",onComplete:function(){}})).send("func=acceptTOS&accepted="+a)}function acceptSubscriptionTOS(a){a=a.checked;(new Request({url:"p_include/ajax_func.html",method:"post",onComplete:function(){}})).send("func=acceptSubscriptionTOS&accepted="+a)} function sendToFriendPopUp(a,b,c){(new Request({method:"post",url:"p_include/ajax_func.html",evalScripts:!0,onComplete:function(a){showPopUp(a)}})).send("func=tellAFriendPopUp&type="+a+"&product_id="+b+"&template_id="+c)}function forcePositiveInt(a){a.value=Math.floor(1*a.value);if(isNaN(a.value)||1>1*a.value)a.value=1} window.addEvent("domready",function(){$("reviewBreakDown")&&$("reviewBreakDown").set("tween",{onComplete:function(){$("reviewBreakDown").style.display="block"},duration:1}).tween("opacity",0)}); function displayReviewBreakDown(){var a=$("starsDiv").getLeft(),b=$("starsDiv").getTop();"trident"!=Browser.Engine.name?($("reviewBreakDown").style.top=b,$("reviewBreakDown").style.left=a):$("reviewBreakDown").setStyles({top:b,left:a-65});$("reviewBreakDown").style.backgroundColor="#FFFFFF";$("reviewBreakDown").set("tween",{duration:500}).tween("opacity",1)}function hideReviewBreakDown(){$("reviewBreakDown").set("tween",{duration:500}).tween("opacity",0)} function expressShopping(a){allowCartToClose=!1;for(var a=$("expressShopping_"+a).elements,b={},c="",d="",d="",e=0;e<a.length;e++)d=a[e].name,c=d.substring(d.indexOf("[")+1,d.indexOf("]")),d=d.substring(d.indexOf("[",d.indexOf("[")+1)+1,d.indexOf("]",d.indexOf("]")+1)),b[c]||(b[c]={}),b[c][d]=a[e].value;(new Request({url:href+"p_include/ajax_func.html",method:"post",onComplete:function(){location.href="/cart.html"}})).send("func=expressShoppingCart&product="+JSON.encode(b))};
