Your World of Wellness 
Ascend4Life  offers you the nutritional solutions you need to 
 
' ;
		html+=  '
';
        PreviewHtmlInNewWindowImage(html,'height=600,width=450,resizable=no,scrollbars=yes');
        return false;*/
    }
    function PreviewHtmlInNewWindowImage(bodyText, params) {
        var w = window.open('', '_blank', params, true);
        var res, pattern;
        pattern = /__quote__/g;
        res = bodyText.replace(pattern, "'");
        pattern = /__dblquote__/g;
        res = res.replace(pattern, "\"");
        w.document.write(res);
        if (br_ie) {
            status = "";
            //remove_loading();
        }
        return false;
    }
    var zoomImage;// = 'http://localhost/ImageZoomer/ImageZoomr_files/_5699981-large.jpg';
    var bolOddEven = false;
    var zoom = 5;
    var pos;
    function findPos(obj) {
        var curleft = curtop = 0;
        if (obj.offsetParent) {
            do {
                curleft += obj.offsetLeft;
                curtop += obj.offsetTop;
            } while (obj = obj.offsetParent);
            return [curleft, curtop];
        }
    }
    function fnProductFinance(skuID) {
        //alert("called");
        var url = document.getElementById("ctl00_CPH_ctl11_BM_hidUrl").value;
        url = url.replace(/SKUID/, skuID);
        //alert(url);
        var oWnd = window.radopen(url, 'winProductImage');
        oWnd.SetUrl(oWnd.GetUrl());
        oWnd.Center();
    }
    var uiDialogChecker = false;
    // Added By Divya to view Associated SKUs
    //Updated By Divya on 17th May, 2011 for task# 2547 - Added PurchaseArea parameter 
    //function OpenDialogToViewAssociatedSKUByUser(SKUId,ViewType,ModuleType,UserId)
    function OpenDialogToViewAssociatedSKUByUser(SKUId, ViewType, ModuleType, UserId, PurchaseArea) {
        try {
			//var redirectto = document.getElementById("ctl00_CPH_ctl11_BM_hdnAssociatedSKUPath").value + "?SKUId="+SKUId+"&ViewType="+ViewType+"&ModuleType="+ModuleType+"&UserId="+UserId;
			//var redirectto = document.getElementById("ctl00_CPH_ctl11_BM_hdnAssociatedSKUPath").value + "?SKUId=" + SKUId + "&ViewType=" + ViewType + "&ModuleType=" + ModuleType + "&UserId=" + UserId + "&PurchaseArea=" + PurchaseArea;
            var redirectto = document.getElementById("ctl00_CPH_ctl11_BM_hdnAssociatedSKUPath").value;
            if (redirectto.indexOf('?') > 0) {
                redirectto += "&";
            } else {
                redirectto += "?";
            }
            redirectto += "SKUId=" + SKUId + "&ViewType=" + ViewType + "&ModuleType=" + ModuleType + "&UserId=" + UserId + "&PurchaseArea=" + PurchaseArea;
            /*added by Jam for switching from radopen to jQuery ui but disabled as I need to know if this will not break any additional function*/
            jQuery('#associate-autoship-url-wrapper').html('
').dialog({
                modal: true,
                maxWidth: '90%',
                width: 600,
                height: 450,
                draggable: false,
                dialogClass: "no-close",
                title: 'Mandatory Associated Recurring Product',
                create: function (event, ui) {
                    jQuery(this).parent('.ui-dialog').css("maxWidth", "90%");
                },
                open: function () {
                    uiDialogChecker = true;
                    jQuery('#associate-autoship-url-wrapper iframe').on('load', function () {
                        jQuery(this).contents().find('html').addClass('ui-dialog');
                    });
                },
				/*buttons: [{
					text: "Close",
					click: function () {
						jQuery(this).dialog("close");
					}
				}]*/
            });
            /*end added by Jam*/
            /*var oWnd = window.radopen(redirectto, "radProductImage");
            oWnd.SetUrl(oWnd.GetUrl());
            oWnd.SetWidth(800); //Added By Divya on 24th July, 2014 for Task# 10528
            oWnd.Center(); Commented out by Jam to replace the radopen script with jQuery ui*/
            return false;
        }
        catch (exception) { }
    }
    //Updated By Divya on 17th May, 2011 for task# 2547 - Added PurchaseArea parameter 
    //function OpenDialogToViewAssociatedSKU(SKUId,ViewType,ModuleType)
    function OpenDialogToViewAssociatedSKU(SKUId, ViewType, ModuleType, PurchaseArea) {
        try {
        //var redirectto = document.getElementById("ctl00_CPH_ctl11_BM_hdnAssociatedSKUPath").value + "?SKUId="+SKUId+"&ViewType="+ViewType+"&ModuleType="+ModuleType;
        //var redirectto = document.getElementById("ctl00_CPH_ctl11_BM_hdnAssociatedSKUPath").value + "?SKUId=" + SKUId + "&ViewType=" + ViewType + "&ModuleType=" + ModuleType + "&PurchaseArea=" + PurchaseArea;
            //End Updated - 
            var redirectto = document.getElementById("ctl00_CPH_ctl11_BM_hdnAssociatedSKUPath").value;
            if (redirectto.indexOf('?') > 0) {
                redirectto += "&";
            } else {
                redirectto += "?";
            }
            redirectto += "SKUId=" + SKUId + "&ViewType=" + ViewType + "&ModuleType=" + ModuleType + "&PurchaseArea=" + PurchaseArea;
            /*added by Jam for switching from radopen to jQuery ui but disabled as I need to know if this will not break any additional function*/
            jQuery('#associate-autoship-url-wrapper').html('
').dialog({
                modal: true,
                maxWidth: '90%',
                width: 600,
                height: 450,
                draggable: false,
                dialogClass: "no-close",
                title: 'Mandatory Associated Recurring Product',
                create: function (event, ui) {
                    jQuery(this).parent('.ui-dialog').css("maxWidth", "90%");
                },
                open: function () {
                    uiDialogChecker = true;
                    jQuery('#associate-autoship-url-wrapper iframe').on('load', function () {
                        jQuery(this).contents().find('html').addClass('ui-dialog');
                    });
                },
				/*buttons: [{
					text: "Close",
					click: function () {
						jQuery(this).dialog("close");
					}
				}]*/
            });
            /*end added by Jam*/
            /*var oWnd = window.radopen(redirectto, "radProductImage");
            oWnd.SetUrl(oWnd.GetUrl());
            oWnd.SetWidth(650);//Added By Divya on 24th July, 2014 for Task# 10528
            oWnd.Center(); Commented out by Jam to replace the radopen script with jQuery ui*/
            return false;
        }
        catch (exception) { }
    }
    function ChangeImage(url, j) {
        var myimage = document.getElementById('ctl00_CPH_ctl11_BM_myimage');
        myimage.src = url;
        myimage.removeAttribute('data-zoomsrc');
        myimage.setAttribute('data-zoomsrc', zoomImageUrls[j]);
        //zoomSrc=zoomImageUrls[j];
        //var myZoomImage=getElementsByClassName('mojozoom_img');
        //    if(myZoomImage.length > 0)
        //    {
        //        zoomSrc=zoomImageUrls[j];
        //        setTimeout(function() 
        //		{ 
        //			myZoomImage[0].removeAttribute('src');
        //            myZoomImage[0].src=zoomImageUrls[j];
        //		}, 1);
        //    }
        imageIndex = j;
        i = j;  //added by john 03/19/2014 task#8409 note:var i is used in zoom image 
        MojoZoom.init(myimage, zoomImageUrls[j]);
    }
    function getElementsByClassName(classname, node) {
        if (!node) node = document.getElementsByTagName("body")[0];
        var a = [];
        var re = new RegExp('\\b' + classname + '\\b');
        var els = node.getElementsByTagName("*");
        for (var i = 0, j = els.length; i  -1 || urlToCheck.indexOf('1934d231-af6e-4b19-be41-fc734936cd8c') > -1) {
                addToCartButtons = jQuery('.ProductCardButtons a[id*="btnAddToCart"]');
                viewAssociatedSKUs = jQuery('.ProductCardButtons a[id*="btnViewAssociatedSKU"]');
                viewAssociatedSKUsText = jQuery('.ProductCardButtons a[id*="btnViewAssociatedSKU"] .tdBottomButtonMiddle');
                itemQuantities = jQuery('.ProductCardButtons input[id*="numQuantity"]');
                itemPlusMinusQuantities = jQuery('.ProductCardButtons input[id*="numPlusMinusQuantity"]');  // Added by Kevin on 9th Sept, 2015 for Task# 18711 - Add to cart quantity format
                priceTexts = jQuery('.grid tr:has(span[id*="lblYourPrice"])');
                jQuery.each(addToCartButtons, function (index, addToCartButton) {
                    viewAssociatedSKUsText[index].innerHTML = addToCartButton.text;
                });
                addToCartButtons.css('cssText', 'display: none !important');
                itemQuantities.css('cssText', 'display: none !important');
                itemPlusMinusQuantities.css('cssText', 'display: none !important');  // Added by Kevin on 9th Sept, 2015 for Task# 18711 - Add to cart quantity format
                priceTexts.css('cssText', 'display: none !important');
            }
        }
    }
    function AutoAddToCart(skuId) {
        jQuery.each(viewAssociatedSKUs, function (index, viewAssociatedSKU) {
            if (viewAssociatedSKU.getAttributeNode('onclick').nodeValue.indexOf(skuId) > -1) {
                addToCartButtons[index].click();
            }
        });
    }
    AutoAddToCartEndRequestHandler();
    //end add Richard Chico for task #11612: VineIT Shopping Page Modification
    //Added by Kevin on 9th Sept, 2015 for Task# 18711 - Add to cart quantity format
    function QuantityPlusMinus(_this, evt) {
        //        console.log(jQuery(_this).parent().parent().find("input[id$='tb']"));
        var Quantity = parseInt(jQuery(_this).parent().parent().find("input[id$='tb']").val());
        console.log('1');
        if (evt == 'Plus') {
            if (!(_this.attributes["disabled"] != null && _this.attributes["disabled"].value == "disabled") && Quantity >= 1) {
                Quantity = Quantity + 1;
                jQuery(_this).parent().parent().find("input[id$='tb']").val(Quantity);
            }
            else
                jQuery(_this).parent().parent().find("input[id$='tb']").val(1);
        }
        else if (evt == 'Minus') {
            if (!(_this.attributes["disabled"] != null && _this.attributes["disabled"].value == "disabled") && '1'  1)
                    jQuery(_this).parent().parent().find("input[id$='tb']").val(Quantity - 1);
            }
        }
        return false;
    }
    function isNumberKey(evt) {
        evt = (evt) ? evt : window.event;
        var charCode = (evt.which) ? evt.which : evt.keyCode;
        if (charCode > 31 && (charCode  57)) {
            return false;
        }
        return true;
    }
    function comparePrices(num1, num2) {
        if (parseFloat(num1.replace(/[^0-9\.]/g, ''), 10) === parseFloat(num2.replace(/[^0-9\.]/g, ''), 10)) {
            return true;
        } else {
            return false;
        }
    }
    function moveBackToCatalog() {
        if (jQuery('[id$="tblSimpleSearch"] .search-button').length > 0) {
            var targetElement = jQuery('[id$="tblSimpleSearch"] .search-button').parent();
            jQuery('.divCategoryCrumb + .ProductCardBackToCatalog .catalog-button').detach().prependTo(targetElement);
        }
    }
    //End Added by Kevin on 9th Sept, 2015 for Task# 18711 - Add to cart quantity format
    /*Added by Jam to change the dropdown design*/
    function dropKickInit() {
        jQuery('.autoship-information-wrapper .select-arrow-wrapper select, .product-card-custom-attributes .gridCustomAttribute select,.dropkick-select').dropkick();
    }
    /*New Product DropDown*/
    var changeFromDropKickToQuantity = false,
        changeFromDropKickToShipping = false,
        requestFromBottomSkuList = false,
        requestFromTopSkuList = false;
    function updateNewDropDownBottom() {
        if (jQuery('[id$="divSKUContentBottom"]').length > 0) {
            if (jQuery('#product-card .product-item-buttons').length == 1) {
                jQuery('#product-card').addClass('sku-1');
            }
            jQuery('#product-card').addClass('varSKUasQuantity');
            var prsSelectedIndex = 0;
            jQuery('#product-card').addClass('new-dropdown-enabled');
            jQuery('[id$="divSKUContentBottom"] .grid [id$="_lblSKUName"]').each(function (index) {
                var skuText = jQuery(this).text(),
                    //skuId = jQuery(this).attr('id').replace('_lblSKUCode','');
                    skuId = jQuery(this).attr('id').replace('_lblSKUName', '');
                skuButton = skuId + '_btnAddToCart';
                buttonHref = jQuery('#' + skuButton).attr('href');
                jQuery('#sku-list-bottom').append('
' + skuText + ' ');
                if (index == 0) {
                    jQuery('[id*="' + skuId + '"]').each(function () {
                        //jQuery(this).parents('[class*="product-"]').show();
                        //jQuery(this).parents('.quantity-wrapper').show();
                        if (jQuery(this).parents('.quantity-wrapper').length != 1) {
                            jQuery(this).parents('[class*="product-"]').show();
                        }
                    });
                    jQuery('#add-to-cart-selected-sku-bottom').attr('href', buttonHref);
                }
            });
            jQuery('[id$="divSKUContentBottom"] .autoship-information-wrapper [id$="_autoshipInformation"]').each(function () {
                var baseId = jQuery(this).attr('id').replace('_autoshipInformation', ''),
                    targetId = baseId + '_dropkick-wrapper',
                    targetButtonId = baseId + '_pushbutton-wrapper';
                jQuery(this).parent().find('.target-new-dropdown-location').attr('id', targetId);
                jQuery(this).parent().find('.target-new-pushbutton-location').attr('id', targetButtonId);
            });
            /*For moving the new dropdown*/
            var selectedOption = jQuery('#sku-list-bottom').prop('selectedIndex'),
                dataId = jQuery("#sku-list-bottom option").eq(selectedOption).attr('data-attributes-id');
            /*End for moving new dropdown*/
            jQuery('[id$="divSKUContentBottom"] .autoship-information-wrapper .select-arrow-wrapper select, [id$="divSKUContentBottom"] .product-card-custom-attributes .gridCustomAttribute select').on('change', function (index) {
                prsSelectedIndex = jQuery(this).prop('selectedIndex');
            }).dropkick('select', 0);
            jQuery('#sku-list-bottom').on('change', function () {
                var skuButton = jQuery('option:selected', this).attr('data-button-id'),
                    skuID = jQuery('option:selected', this).attr('data-attributes-id'),
                    buttonHref = jQuery('#' + skuButton).attr('href'),
                    selectedOption = jQuery('#sku-list-bottom').prop('selectedIndex'),
                    dataId = jQuery("#sku-list-bottom option").eq(selectedOption).attr('data-attributes-id');
                jQuery('#add-to-cart-selected-sku-bottom').attr('href', buttonHref).removeClass('button-disabled');
                /*Script to move the new dropdown and button to their new location*/
                jQuery('[id$="sku-list-bottom"]').detach().appendTo('#' + dataId + '_dropkick-wrapper');
                jQuery('#add-to-cart-selected-sku-bottom').detach().appendTo('#' + dataId + '_pushbutton-wrapper');
                /*End Script to move the new dropdown and button to their new location*/
                jQuery('[id$="divSKUContentBottom"] .product-card-item-name,[id$="divSKUContentBottom"] .product-card-item-price,[id$="divSKUContentBottom"] .product-card-custom-attributes,[id$="divSKUContentBottom"] .product-item-buttons,[id$="divSKUContentBottom"] .quantity-wrapper,[id$="divSKUContentBottom"] .autoship-information-wrapper,[id$="divSKUContentBottom"] .product-card-item-separator').hide();
                requestFromBottomSkuList = true;
                jQuery('#' + skuID + '_ddrAutoshipFrequency').dropkick('select', prsSelectedIndex);
                /*For changing the sku-list-top*/
                if (jQuery('#sku-list-top option').length > 0 && changeFromDropKickToQuantity == false) {
                    changeFromDropKickToQuantity = true;
                    jQuery('#sku-list-top').dropkick('select', selectedOption);
                }
                /*End for changing the sku-list-top*/
                jQuery('[id*="' + skuID + '"]').each(function () {
                    //jQuery(this).parents('[class*="product-"]').show();
                    //jQuery(this).parents('.quantity-wrapper').show();
                    if (jQuery(this).parents('.quantity-wrapper').length != 1) {
                        jQuery(this).parents('[class*="product-"]').show();
                    }
                });
                if (buttonHref == undefined) {
                    jQuery('#add-to-cart-selected-sku-bottom').removeAttr('href').addClass('button-disabled');
                }
                changeFromDropKickToQuantity = false;
            }).dropkick();
            /*Script to move the new dropdown and button to their new location*/
            jQuery('[id$="sku-list-bottom"]').detach().appendTo('#' + dataId + '_dropkick-wrapper');
            jQuery('#add-to-cart-selected-sku-bottom').detach().appendTo('#' + dataId + '_pushbutton-wrapper');
            /*End Script to move the new dropdown and button to their new location*/
            jQuery('.target-new-pushbutton-location,.target-new-dropdown-wrapper').show();
        }
    }
    function updateNewDropDownTop() {
        if (jQuery('[id$="divSKUContentTop"]').length > 0) {
            jQuery('#product-card').addClass('varSKUasQuantity');
            var prsSelectedIndex = 0;
            jQuery('#product-card').addClass('new-dropdown-enabled');
            jQuery('[id$="divSKUContentTop"] .grid [id$="_lblSKUName"]').each(function (index) {
                var skuText = jQuery(this).text(),
                    //skuId = jQuery(this).attr('id').replace('_lblSKUCode','');
                    skuId = jQuery(this).attr('id').replace('_lblSKUName', '');
                skuButton = skuId + '_btnAddToCart';
                buttonHref = jQuery('#' + skuButton).attr('href');
                jQuery('#sku-list-top').append('
' + skuText + ' ');
                if (index == 0) {
                    jQuery('[id*="' + skuId + '"]').each(function () {
                        //jQuery(this).parents('[class*="product-"]').show();
                        //jQuery(this).parents('.quantity-wrapper').show();
                        if (jQuery(this).parents('.quantity-wrapper').length != 1) {
                            jQuery(this).parents('[class*="product-"]').show();
                        }
                    });
                    jQuery('#add-to-cart-selected-sku-top').attr('href', buttonHref);
                }
            });
            jQuery('[id$="divSKUContentTop"] .autoship-information-wrapper [id$="_autoshipInformation"]').each(function () {
                var baseId = jQuery(this).attr('id').replace('_autoshipInformation', ''),
                    targetId = baseId + '_dropkick-wrapper',
                    targetButtonId = baseId + '_pushbutton-wrapper';
                jQuery(this).parent().find('.target-new-dropdown-location').attr('id', targetId);
                jQuery(this).parent().find('.target-new-pushbutton-location').attr('id', targetButtonId);
            });
            /*For moving the new dropdown*/
            var selectedOption = jQuery('#sku-list-top').prop('selectedIndex'),
                dataId = jQuery("#sku-list-top option").eq(selectedOption).attr('data-attributes-id');
            /*End for moving new dropdown*/
            jQuery('[id$="divSKUContentTop"] .autoship-information-wrapper .select-arrow-wrapper select, [id$="divSKUContentTop"] .product-card-custom-attributes .gridCustomAttribute select').on('change', function (index) {
                prsSelectedIndex = jQuery(this).prop('selectedIndex');
            }).dropkick('select', 0);
            jQuery('#sku-list-top').on('change', function () {
                var skuButton = jQuery('option:selected', this).attr('data-button-id'),
                    skuID = jQuery('option:selected', this).attr('data-attributes-id'),
                    buttonHref = jQuery('#' + skuButton).attr('href'),
                    selectedOption = jQuery('#sku-list-top').prop('selectedIndex'),
                    dataId = jQuery("#sku-list-top option").eq(selectedOption).attr('data-attributes-id');
                jQuery('#add-to-cart-selected-sku-top').attr('href', buttonHref).removeClass('button-disabled');
                /*Script to move the new dropdown and button to their new location*/
                jQuery('[id$="sku-list-top"]').detach().appendTo('#' + dataId + '_dropkick-wrapper');
                jQuery('#add-to-cart-selected-sku-top').detach().appendTo('#' + dataId + '_pushbutton-wrapper');
                /*End Script to move the new dropdown and button to their new location*/
                jQuery('[id$="divSKUContentTop"] .product-card-item-name,[id$="divSKUContentTop"] .product-card-item-price,[id$="divSKUContentTop"] .product-card-custom-attributes,[id$="divSKUContentTop"] .product-item-buttons,[id$="divSKUContentTop"] .quantity-wrapper,[id$="divSKUContentTop"] .autoship-information-wrapper,[id$="divSKUContentTop"] .product-card-item-separator').hide();
                requestFromTopSkuList = true;
                jQuery('#' + skuID + '_ddrAutoshipFrequency').dropkick('select', prsSelectedIndex);
                /*For changing the sku-list-bottom*/
                if (jQuery('#sku-list-bottom option').length > 0 && changeFromDropKickToQuantity == false) {
                    changeFromDropKickToQuantity = true;
                    jQuery('#sku-list-bottom').dropkick('select', selectedOption);
                }
                /*End for changing the sku-list-bottom*/
                jQuery('[id*="' + skuID + '"]').each(function () {
                    //jQuery(this).parents('[class*="product-"]').show();
                    //jQuery(this).parents('.quantity-wrapper').show();
                    if (jQuery(this).parents('.quantity-wrapper').length != 1) {
                        jQuery(this).parents('[class*="product-"]').show();
                    }
                });
                if (buttonHref == undefined) {
                    jQuery('#add-to-cart-selected-sku-top').removeAttr('href').addClass('button-disabled');
                }
                changeFromDropKickToQuantity = false;
            }).dropkick();
            /*Script to move the new dropdown and button to their new location*/
            jQuery('[id$="sku-list-top"]').detach().appendTo('#' + dataId + '_dropkick-wrapper');
            jQuery('#add-to-cart-selected-sku-top').detach().appendTo('#' + dataId + '_pushbutton-wrapper');
            /*End Script to move the new dropdown and button to their new location*/
            jQuery('.target-new-pushbutton-location,.target-new-dropdown-wrapper').show();
        }
    }
    function showOldDropDownUI() {
        jQuery('#product-card .product-card-item-name,#product-card .product-card-item-price,#product-card .product-card-custom-attributes,#product-card .product-item-buttons,#product-card .quantity-wrapper,#product-card .autoship-information-wrapper,#product-card .product-card-item-separator').show();
    }
    function copyAutoShipFrequencyDate() {
        if (jQuery('[id$="divSKUContentTop"] [id$="lblSKUName"]').length > 0 && jQuery('[id$="divSKUContentBottom"] [id$="lblSKUName"]').length > 0) {
            jQuery('[id$="divSKUContentTop"] select[id$="ddrAutoshipFrequency"]').on('change', function () {
                if (requestFromBottomSkuList != true) {
                    var elementId = jQuery(this).attr('id'),
                        targetElementId = elementId.split('dgSKUTop')[0] + 'dgSKU' + elementId.split('dgSKUTop')[1],
                        selectedOption = jQuery('#' + elementId).prop('selectedIndex');
                    if (changeFromDropKickToShipping == false) {
                        changeFromDropKickToShipping = true;
                        jQuery('[id$="autoshipInformation"] select#' + targetElementId).dropkick('select', selectedOption);
                    }
                    changeFromDropKickToShipping = false;
                }
                requestFromBottomSkuList = false;
            });
            jQuery('[id$="divSKUContentBottom"] select[id$="ddrAutoshipFrequency"]').on('change', function () {
                if (requestFromTopSkuList != true) {
                    var elementId = jQuery(this).attr('id'),
                        targetElementId = elementId.split('dgSKU')[0] + 'dgSKUTop' + elementId.split('dgSKU')[1],
                        selectedOption = jQuery('#' + elementId).prop('selectedIndex');
                    if (changeFromDropKickToShipping == false) {
                        changeFromDropKickToShipping = true;
                        jQuery('[id$="autoshipInformation"] select#' + targetElementId).dropkick('select', selectedOption);
                    }
                    changeFromDropKickToShipping = false;
                }
                requestFromTopSkuList = false;
            });
            jQuery('[id*="divSKUContentTop"] .quantity-wrapper select[id$="ddrQuantity"]').on('change', function () {
                var selectedOption = jQuery(this).prop('selectedIndex'),
                    targetId = jQuery(this).attr('id').split('dgSKUTop'),
                    targetElement = targetId[0] + 'dgSKU' + targetId[1];
                if (jQuery('#' + targetElement).length > 0 && changeFromDropKickToQuantity == false) {
                    changeFromDropKickToQuantity = true;
                    jQuery('#' + targetElement).dropkick('select', selectedOption);
                }
                changeFromDropKickToQuantity = false;
            });
            jQuery('[id*="divSKUContentBottom"] .quantity-wrapper select[id$="ddrQuantity"]').on('change', function () {
                var selectedOption = jQuery(this).prop('selectedIndex'),
                    targetId = jQuery(this).attr('id').split('dgSKU'),
                    targetElement = targetId[0] + 'dgSKUTop' + targetId[1];
                if (jQuery('#' + targetElement).length > 0 && changeFromDropKickToQuantity == false) {
                    changeFromDropKickToQuantity = true;
                    jQuery('#' + targetElement).dropkick('select', selectedOption);
                }
                changeFromDropKickToQuantity = false;
            });
        }
    }
    function dateSelected(sender, eventArgs) {
        var pickerID = sender.get_id();
        if (pickerID.includes('dgSKUTop')) {
            pickerID = pickerID.replace("dgSKUTop", "dgSKU");
        }
        else {
            pickerID = pickerID.replace("dgSKU", "dgSKUTop");
        }
        var picker = $find(pickerID);
        if (picker && picker.get_dateInput().get_value() != eventArgs.get_newValue()) {
            picker.set_selectedDate(eventArgs.get_newDate());
        }
        UpdateAutoshipLabel(sender.get_id());
    }
    function initNewDropDownUI() {
        if (typeof (varSKUasQuantity) != "undefined" && varSKUasQuantity.toLowerCase() == 'true') {
            if (jQuery('[id$="divSKUContentTop"] .grid [id$="_lblSKUName"]').length > 0 || jQuery('[id$="divSKUContentBottom"] .grid [id$="_lblSKUName"]').length > 0) {
                updateNewDropDownTop();
                updateNewDropDownBottom();
                copyAutoShipFrequencyDate();
            } else {
                showOldDropDownUI();
            }
        } else {
            showOldDropDownUI();
        }
    }
    function applyElevateZoomNew() {
        var bigimage = jQuery('.fancybox.shown').attr('href');
        jQuery('#product-card .myimage').elevateZoom({
            zoomType: zoom_type,
            cursor: zoom_cursor_type,
            zoomWindowFadeIn: zoom_fade_in,
            zoomWindowFadeOut: zoom_fade_out,
            scrollZoom: zoom_scroll,
            easing: zoom_easing,
            lensOpacity: zoom_lens_opacity,
            lensShape: zoom_lens_shape,
            lensSize: zoom_lens_size,
            zoomImage: bigimage,
            zoomWindowWidth: zoom_win_width,
            zoomWindowHeight: zoom_win_height,
            borderSize: zoom_win_border,
        });
    }
    function restartElevateZoomNew() {
        jQuery(".zoomContainer").remove();
        applyElevateZoomNew();
    }
    function newcustomElevateZoom() {
        jQuery('#product-card #views_block li a').off();
        jQuery('#product-card #views_block li a').mouseenter(function () {
            var largeImgSrc = '';
            jQuery('#ctl00_CPH_ctl11_BM_spViewLargeImage').hide();
            jQuery('#ctl00_CPH_ctl11_BM_spPlayVideo').hide();
            if (jQuery(this).attr('isvideo') == "1") {
                largeImgSrc = jQuery(this).attr('imageurl');
                jQuery('#product-card #image-block #view_full_size').addClass('video-thumbnail');
                jQuery('#ctl00_CPH_ctl11_BM_myimage').removeClass('myimage');
                jQuery('#ctl00_CPH_ctl11_BM_spPlayVideo').show();
            }
            else {
                largeImgSrc = jQuery(this).attr('href');
                jQuery('#product-card #image-block #view_full_size').removeClass('video-thumbnail');
                jQuery('#ctl00_CPH_ctl11_BM_myimage').addClass('myimage');
                jQuery('#ctl00_CPH_ctl11_BM_spViewLargeImage').show();
            }
            jQuery('#product-card #image-block img').attr('src', largeImgSrc);
            jQuery('#product-card #views_block li a').removeClass('shown');
            jQuery(this).addClass('shown');
            restartElevateZoomNew();
        });
        jQuery("#product-card #views_block li a").first().trigger("mouseover");
        jQuery('#product-card .primary_block').fadeIn();
        limitThumbnailImage();
    }
    function limitThumbnailImage() {
        if (jQuery('#product-card[productthumbnailview="leftvertical"]').length > 0) {
            var thumbListHeight = (jQuery('#thumbs_list li').outerHeight() * 3) + 20;
            console.log(thumbListHeight);
            jQuery('#thumbs_list').height(thumbListHeight + 'px');
        }
    }
    /*End added by Jam*/
    jQuery(document).ready(function () {
        initNewDropDownUI();
        dropKickInit();
        loadColorThief();
        moveBackToCatalog();
        var salesPrice = jQuery('.grid td[id$="tdSalesPrice"] .label').text(), yourPrice = jQuery('.grid td[id$="tdYourPrice"] .label').text();
        var isEqual = comparePrices(salesPrice, yourPrice);
        console.log(isEqual);
        if (isEqual == true) {
            jQuery('.grid td[id$="tdYourPrice"]').hide();
        }
        InitAutoshipPopover();
        initFlavorPickupPopup();  // Added by Kevin for Task#46330
        BindPopoverCart();
    });
    jQuery(window).on('load', function () {
        newcustomElevateZoom();
        try {
            var color = sessionStorage.getItem('colorThiefRgb');
            jQuery('head').append('');
            jQuery('head').append('');
        } catch (colorThiefError) { }
    });
    function autoshipDropdownListChange(autoshipddlClientId, autoshipDateSelectorClientId, tdYousaveClientId, tdSalesPriceClientId, tdYousave_AutoshipClientId, tdAutoshipPriceClientId) {
        var autoshipddl = jQuery('#' + autoshipddlClientId);
        var autoshipdateselector = jQuery('#' + autoshipDateSelectorClientId);
        var tdYousaveElement = jQuery('#' + tdYousaveClientId);
        var tdSalesPriceElement = jQuery('#' + tdSalesPriceClientId);
        var tdYousave_AutoshipElement = jQuery('#' + tdYousave_AutoshipClientId);
        var tdAutoshipPriceElement = jQuery('#' + tdAutoshipPriceClientId);
        var AddtoCartTop = jQuery('#add-to-cart-selected-sku-top');
        var AddtoCartBottom = jQuery('#add-to-cart-selected-sku-bottom');
        if (autoshipddl != null) {
            if (autoshipddl.val() == "-1") {
                AddtoCartTop.text()
                autoshipdateselector.hide();
                AddtoCartTop.html('Add to Cart');
                AddtoCartBottom.html('Add to Cart');
                if (tdYousaveElement.length > 0) {
                    tdYousaveElement.show();
                }
                if (tdSalesPriceElement.length > 0) {
                    tdSalesPriceElement.find('span.label').removeClass('linethrough')
                }
                if (tdYousave_AutoshipElement.length > 0) {
                    tdYousave_AutoshipElement.hide();
                }
                if (tdAutoshipPriceElement != null) {
                    tdAutoshipPriceElement.find('span.label').addClass('linethrough')
                }
            }
            else {
                autoshipdateselector.show();
                AddtoCartTop.html('
 Add Preferred Membership');
                AddtoCartBottom.html('
 Add Preferred Membership');
                if (tdYousaveElement.length > 0 && tdYousave_AutoshipElement.length > 0) {
                    tdYousaveElement.hide();
                }
                if (tdSalesPriceElement.length > 0 && tdAutoshipPriceElement.length > 0) {
                    tdSalesPriceElement.find('span.label').addClass('linethrough')
                }
                if (tdYousave_AutoshipElement.length > 0) {
                    tdYousave_AutoshipElement.show();
                }
                if (tdAutoshipPriceElement.length > 0) {
                    tdAutoshipPriceElement.find('span.label').removeClass('linethrough')
                }
            }
        }
    }
    function autoshipRadioButtonListChange(autoshipddlClientId, autoshipDateSelectorClientId, tdYousaveClientId, tdSalesPriceClientId, tdYousave_AutoshipClientId, tdAutoshipPriceClientId, defaultDate) {
        var autoshipddl = jQuery('#' + autoshipddlClientId);
        var autoshipdateselector = jQuery('#' + autoshipDateSelectorClientId);
        var tdYousaveElement = jQuery('#' + tdYousaveClientId);
        var tdSalesPriceElement = jQuery('#' + tdSalesPriceClientId);
        var tdYousave_AutoshipElement = jQuery('#' + tdYousave_AutoshipClientId);
        var tdAutoshipPriceElement = jQuery('#' + tdAutoshipPriceClientId);
        var AddtoCartTop = jQuery('#add-to-cart-selected-sku-top');
        var AddtoCartBottom = jQuery('#add-to-cart-selected-sku-bottom');
        jQuery('#' + autoshipddlClientId).find('td').css({ "background-color": "#fff" });
        jQuery('#' + autoshipddlClientId + ' input:checked').parent('td').css({ "background-color": "#f3f3f3" });
        var calStartDateId = autoshipDateSelectorClientId.replace('dvStartDate', 'calStartDate_dateInput');
        jQuery('#' + autoshipddlClientId).find('.autoshiplabel').empty();
        var addtoCartButton = autoshipddlClientId.replace('rblAutoshipFrequency', 'btnAddToCart');
        if (autoshipddl != null) {
            if (jQuery('#' + autoshipddlClientId + ' input:checked').val() == "-1") {
                AddtoCartTop.text()
                autoshipdateselector.hide();
                jQuery('#' + addtoCartButton).html('Add to Cart');
                if (tdYousaveElement.length > 0) {
                    tdYousaveElement.show();
                }
                if (tdSalesPriceElement.length > 0) {
                    tdSalesPriceElement.find('span.label').removeClass('linethrough')
                }
                if (tdYousave_AutoshipElement.length > 0) {
                    tdYousave_AutoshipElement.hide();
                }
                if (tdAutoshipPriceElement != null) {
                    tdAutoshipPriceElement.find('span.label').addClass('linethrough')
                }
            }
            else {
                autoshipdateselector.show();
                jQuery('#' + addtoCartButton).html('
 Add Preferred Membership');
                if (tdYousaveElement.length > 0 && tdYousave_AutoshipElement.length > 0) {
                    tdYousaveElement.hide();
                }
                if (tdSalesPriceElement.length > 0 && tdAutoshipPriceElement.length > 0) {
                    tdSalesPriceElement.find('span.label').addClass('linethrough')
                }
                if (tdYousave_AutoshipElement.length > 0) {
                    tdYousave_AutoshipElement.show();
                }
                if (tdAutoshipPriceElement.length > 0) {
                    tdAutoshipPriceElement.find('span.label').removeClass('linethrough')
                }
                var autoshipStartDate = defaultDate;
                if (jQuery('#' + calStartDateId).length > 0) {
                    autoshipStartDate = jQuery('#' + calStartDateId).val();
                }
                var label = '
 ' + 'Subscription: ' + jQuery('#' + autoshipddlClientId + ' input:checked + label').text() + ' ' + 'starting' + ' ' + autoshipStartDate + ' ';
                jQuery('#' + autoshipddlClientId + ' input:checked').parent('td').append(label);
            }
        }
    }
    function UpdateAutoshipLabel(calStartDateId) {
        var radioAutoship = calStartDateId.replace('calStartDate', 'rblAutoshipFrequency');
        var calStartDateInputId = calStartDateId.replace('calStartDate', 'calStartDate_dateInput');
        jQuery('#' + radioAutoship).find('.autoshiplabel').empty();
        var autoshipStartDate = autoshipStartDate = jQuery('#' + calStartDateInputId).val();
        var label = '
 ' + 'Subscription: ' + jQuery('#' + radioAutoship + ' input:checked + label').text() + ' ' + 'starting' + ' ' + autoshipStartDate + ' ';
        jQuery('#' + radioAutoship + ' input:checked').parent('td').append(label);
    }
    function InitAutoshipPopover() {
        try {
            jQuery(".autoship-popover").each(function () {
                jQuery(this).popover({
                    html: true,
                    placement: 'bottom',
                    trigger: 'hover',
                    container: jQuery(this),
                    delay: { "show": 100, "hide": 0 },
                    content: function () {
                        return jQuery('#ctl00_CPH_ctl11_BM_autoshippopovercontent').html();
                    }
                });
            });
            jQuery(".autoship-popover").on('shown.bs.popover', function () {
                var currentTop = parseInt(jQuery('.popover').css('top'));
                var currentLeft = parseInt(jQuery('.popover').css('left'));
                jQuery('.popover').css({
                    top: (currentTop + 5) + 'px',
                    left: (currentLeft + 65) + 'px'
                });
            });
        }
        catch (exception) { }
    }
    // Added by Kevin for Task#46330
    function initFlavorPickupPopup() {
        jQuery('[data-hook="hasflavors"]').bind('click', function (e) {
            e.preventDefault();
            var mainskuqty = 1;
            if ('1' == 1) {
                mainskuqty = jQuery(this).parent().find('input[id*="numPlusMinusQuantity"]').val();
            }
            else if ('1' == 2) {
                mainskuqty = jQuery(this).parent().find('select[id$="ddrQuantity"]').val();
            }
            else if ('1' == 3 || '1' == 4) {
                mainskuqty = jQuery(this).parent().find('input[id*="numQuantity"]').val()
            }
            var skuId = jQuery(this).attr("skuid").toString();
            var hrefValue = jQuery(this).attr("href");
            fnBindSKUFlavors(skuId, 'dvSKUFlavorPickupDialog', hrefValue, mainskuqty, 'Shop');
        });
    }
    // End Added by Kevin for Task#46330
                        {{if IsAutoshipItem == false}}
                           ${RetailPriceFormatted} 
                        {{else}}
                           ${AutoshipPriceFormatted} 
                        {{/if}}
                    
${SelectedAutoshipItemText}