'); var dialogId = '#' + dialogPurpose + 'dialog'; var displayContainerId = '#js_' + dialogPurpose + 'Container'; displayDialogId = '#' + dialogPurpose + 'displayDialog'; dialogTitleId = '#' + dialogPurpose + 'dialogBoxTitle'; titleText = jQuery(dialogTitleId).val(); var url = ""; if (params) { url = '/eCommercePlpQuickLook;jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1?'+params; } else { url = '/eCommercePlpQuickLook;jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1'; } jQuery.get(url, function(data) { jQuery(elm).find('#loadingDiv').remove(); jQuery(elm).append(oldhtml); jQuery(displayContainerId).replaceWith(data); showDialog(dialogId, displayDialogId, titleText); }); } function displayProductScrollActionDialogBox(dialogPurpose,elm) { var params = jQuery(elm).siblings('input.param').serialize(); var dialogId = '#' + dialogPurpose + 'dialog'; var displayContainerId = '#' + dialogPurpose + 'Container'; displayDialogId = '#' + dialogPurpose + 'displayDialog'; dialogTitleId = '#' + dialogPurpose + 'dialogBoxTitle'; titleText = jQuery(dialogTitleId).val(); jQuery(displayContainerId).html('
'); getActionDialog(displayContainerId,params); } function getActionDialog (displayContainerId,params) { var url = ""; if (params) { url = 'eCommercePlpQuickLook?'+params; } else { url = 'eCommercePlpQuickLook'; } jQuery.get(url, function(data) { jQuery(displayContainerId).replaceWith(data); //jQuery(myDialog).dialog( "option", "position", 'center' ); }); } var isWhole_re = /^\s*\d+\s*$/; function isWhole (s) { return String(s).search (isWhole_re) != -1 } function onImgError(elem,type) { var imgUrl = "/osafe_theme/images/user_content/images/"; var imgName= "NotFoundImage.jpg"; switch (type) { case "PLP-Thumb": imgName="NotFoundImagePLPThumb.jpg"; break; case "PLP-Swatch": imgName="NotFoundImagePLPSwatch.jpg"; break; case "PDP-Large": imgName="NotFoundImagePDPLarge.jpg"; break; case "PDP-Alt": imgName="NotFoundImagePDPAlt.jpg"; break; case "PDP-Detail": imgName="NotFoundImagePDPDetail.jpg"; break; case "PDP-Swatch": imgName="NotFoundImagePDPSwatch.jpg"; break; case "CLP-Thumb": imgName="NotFoundImageCLPThumb.jpg"; break; case "MANU-Image": imgName="NotFoundImage.jpg"; break; } elem.src = imgUrl + imgName; elem.onerror = ""; return true; } function getExpDate(days, hours, minutes) { var expDate = new Date(); if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") { expDate.setDate(expDate.getDate() + parseInt(days)); expDate.setHours(expDate.getHours() + parseInt(hours)); expDate.setMinutes(expDate.getMinutes() + parseInt(minutes)); return expDate.toGMTString(); } } function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) { endstr = document.cookie.length; } return unescape(document.cookie.substring(offset, endstr)); } function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { return getCookieVal(j); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function setCookie(name, value, expires, path, domain, secure) { document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } function deleteCookie(name,path,domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } jQuery(document).ready(function () { jQuery('.showNavWidget').click(function() { jQuery('.showNavWidget').hide(); jQuery('.hideNavWidget').show(); jQuery('#eCommerceNavBarMenu').show(); }); jQuery('.hideNavWidget').click(function() { jQuery('.hideNavWidget').hide(); jQuery('.showNavWidget').show(); jQuery('#eCommerceNavBarMenu').hide(); }); jQuery('.dateEntry').each(function(){datePicker(this);}); jQuery('.showLightBoxCart').hover( function(e) { }, function() { } ); jQuery('#eCommerceNavBar').mouseover(function(e) { var id = e.target.id; if((id != "lightCart_displayDialog") && (id != "js_lightBoxCartTitleBar")) { jQuery('.js_lightBoxCartContainer').delay(0).slideUp(850, function() { jQuery('.js_lightBoxCartContainer').remove(); }); } }); jQuery('#eCommercePageBody').mouseover(function(e) { var id = e.target.id; if((id != "lightCart_displayDialog") && (id != "js_lightBoxCartTitleBar")) { jQuery('.js_lightBoxCartContainer').delay(0).slideUp(850, function() { jQuery('.js_lightBoxCartContainer').remove(); }); } }); jQuery('#eCommerceHeader').mouseover(function(e) { var id = e.target.id; if((id != "siteShoppingCartSize") && (id != "lightCart_displayDialog")) { jQuery('.js_lightBoxCartContainer').delay(0).slideUp(850, function() { jQuery('.js_lightBoxCartContainer').remove(); }); } }); jQuery(window).scroll(function() { var heightBody = jQuery('#eCommercePageBody').height(); var y = jQuery(window).scrollTop(); if( y > (heightBody*.10) ) { jQuery(".js_scrollToTop").fadeIn("slow"); } else { jQuery('.js_scrollToTop').fadeOut('slow'); } }); function __highlight(s, t) { var matcher = new RegExp("("+jQuery.ui.autocomplete.escapeRegex(t)+")", "ig" ); return s.replace(matcher, "$1"); } jQuery('.checkDelivery').click(function(e) { displayActionDialogBox('pincodeChecker_',this); }); jQuery('.pincodeChecker_Form').submit(function(event) { event.preventDefault(); jQuery.get(jQuery(this).attr('action')+'?'+jQuery(this).serialize(), function(data) { jQuery('#js_pincodeCheckContainer').replaceWith(data); }); }); jQuery('.js_cancelPinCodeChecker').click(function(event) { event.preventDefault(); jQuery(displayDialogId).dialog('close'); }); }); function displayLightDialogBox(dialogPurpose) { var dialogId = '#' + dialogPurpose + 'dialog'; displayDialogId = '#' + dialogPurpose + 'displayDialog'; dialogTitleId = '#' + dialogPurpose + 'dialogBoxTitle'; titleText = jQuery(dialogTitleId).val(); showLightBoxDialog(dialogId, displayDialogId, titleText); } function showLightBoxDialog(dialog, displayDialog, titleText) { myDialog = jQuery(displayDialog).dialog({ modal: false, draggable: true, resizable: true, width: 'auto', autoResize:true, position: 'center', title: titleText }); var dialogClass = displayDialog; dialogClass = dialogClass.replace(/^#+/, ""); jQuery(myDialog).parent().addClass(dialogClass); jQuery(myDialog).siblings('.ui-dialog-titlebar').width(jQuery(myDialog).width()); } function datePicker(triger) { jQuery(triger).datepicker({ showOn: 'button', buttonImage: '/images/cal.gif', buttonImageOnly: false, dateFormat: 'mm/dd/y' }); } function addMultiOrderItems() { var addItemsToCart = "true"; var itemSelected = false; var count = 0; jQuery('.js_add_multi_product_quantity').each(function () { reOrderQtyIdArr = jQuery(this).attr("id").split("_"); variantIsChecked = jQuery('#js_add_multi_product_id_'+reOrderQtyIdArr[5]).is(":checked"); if(variantIsChecked) { itemSelected = true; var quantity = jQuery(this).val(); var add_productId = jQuery('#js_add_multi_product_id_'+reOrderQtyIdArr[5]).val(); var productName = jQuery('#js_productName_'+count).val(); if(quantity != "") { if(isQtyWhole(quantity,productName)) { if(!(isQtyZero(quantity,productName,add_productId))) { quantity = Number(quantity) + Number(getQtyInCart(add_productId)); if(!(validateQtyMinMax(add_productId,productName,quantity))) { addItemsToCart = "false"; } } else { addItemsToCart = "false"; } } else { addItemsToCart = "false"; } } else { alert("Please enter re-order quantity"); addItemsToCart = "false"; } } count = count + 1; }); if (!itemSelected) { alert("Please select items to order"); addItemsToCart = "false"; } if(addItemsToCart == "true") { document.reOrderItemForm.action="https://www.purityproducts.com/addMultiItemsToCart;jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1"; document.reOrderItemForm.submit(); } } function seqReOrderCheck(elm) { reOrderQtyIdArr = jQuery(elm).attr("id").split("_"); if(jQuery(elm).val()=="") { jQuery('#js_add_multi_product_id_'+reOrderQtyIdArr[5]).attr("checked", false); } else { jQuery('#js_add_multi_product_id_'+reOrderQtyIdArr[5]).attr("checked", true); } } function findOrderItems(elm) { document.reOrderItemSearchForm.action="https://www.purityproducts.com/eCommerceReOrderItems;jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1"; document.reOrderItemSearchForm.submit(); } function showTooltip(text, elm, elmType) { var tooltipBox = jQuery('.js_tooltip')[0]; if(text != "") { var obj2 = jQuery('.js_tooltipText')[0]; obj2.innerHTML = text; } tooltipBox.style.display = 'block'; var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft); var eCommerceContentLeftPos = 0; var WW = jQuery(window).width(); var WH = jQuery(window).height(); var EX = ""; var EY = ""; if(elmType == "icon") { //subtracting the sl and st from element left and top position because element left and top includes the scroll pixels. EX = jQuery(elm).children().offset().left - sl; EY = jQuery(elm).children().offset().top - st; } else if(elmType == "input") { //subtracting the sl and st from element left and top position because element left and top includes the scroll pixels. EX = jQuery(elm).offset().left - sl; EY = jQuery(elm).offset().top - st; } var TTW = jQuery(tooltipBox).width(); var TTH = jQuery(tooltipBox).height(); var LP = 0; var TP = 0; var EH = jQuery(elm).children().height(); var EW = jQuery(elm).children().width(); var EH = ""; var EW = ""; if(elmType == "icon") { EH = jQuery(elm).children().height(); EW = jQuery(elm).children().width(); } else if(elmType == "input") { EH = jQuery(elm).height(); EW = jQuery(elm).width(); } var TOP = eval(EY > TTH); var BOTTOM = eval(!(TOP)); var LEFT = eval((TTW + EX) > WW); var RIGHT = eval(!(LEFT)); if(BOTTOM && LEFT) { jQuery('.js_tooltipTop').removeClass("tooltipTopLeftArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomRightArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomLeftArrow"); jQuery('.js_tooltipTop').addClass("tooltipTopRightArrow"); } else if(BOTTOM && RIGHT) { jQuery('.js_tooltipTop').removeClass("tooltipTopRightArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomRightArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomLeftArrow"); jQuery('.js_tooltipTop').addClass("tooltipTopLeftArrow"); } else if(TOP && LEFT) { jQuery('.js_tooltipTop').removeClass("tooltipTopLeftArrow"); jQuery('.js_tooltipTop').removeClass("tooltipTopRightArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomLeftArrow"); jQuery('.js_tooltipBottom').addClass("tooltipBottomRightArrow"); } else if(TOP && RIGHT) { jQuery('.js_tooltipTop').removeClass("tooltipTopLeftArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomRightArrow"); jQuery('.js_tooltipTop').removeClass("tooltipTopRightArrow"); jQuery('.js_tooltipBottom').addClass("tooltipBottomLeftArrow"); } if(LEFT) { LP = EX - eCommerceContentLeftPos -TTW + sl + EW; } else { LP = EX - eCommerceContentLeftPos + sl; } if(BOTTOM) { TP = (EY + st + EH); } else { TP = (EY- TTH + st); } jQuery(tooltipBox).css({ top: TP+'px' }); jQuery(tooltipBox).css({ left: LP+'px' }); } function hideTooltip() { document.getElementById('tooltip').style.display = "none"; } function validateQtyMinMax(productId,productName,quantity) { var lowerLimit = Number(getMinQty(productId)); var upperLimit = Number(getMaxQty(productId)); if(quantity != 0) { if(quantity < lowerLimit) { var pdpMinQtyErrorText = "The Quantity for Product _PRODUCT_NAME_ is less than the minimum allowed. The minimum allowed is _PDP_QTY_MIN_. Please retry."; pdpMinQtyErrorText = pdpMinQtyErrorText.replace('_PRODUCT_NAME_',productName); pdpMinQtyErrorText = pdpMinQtyErrorText.replace('_PDP_QTY_MIN_',lowerLimit); alert(pdpMinQtyErrorText); return false; } else if(upperLimit!= 0 && quantity > upperLimit) { var pdpMaxQtyErrorText = "The Quantity for Product _PRODUCT_NAME_ is greater than the maximum allowed. The maximum allowed is _PDP_QTY_MAX_. Please retry."; pdpMaxQtyErrorText = pdpMaxQtyErrorText.replace('_PRODUCT_NAME_',productName); pdpMaxQtyErrorText = pdpMaxQtyErrorText.replace('_PDP_QTY_MAX_',upperLimit); alert(pdpMaxQtyErrorText); return false; } } return true; } function getMaxQty(productId) { var upperLimit = Number(201); if(jQuery('#js_pdpQtyMaxAttributeValue_'+productId).length) { upperLimit = Number(jQuery('#js_pdpQtyMaxAttributeValue_'+productId).val()); } return upperLimit; } function getMinQty(productId) { var lowerLimit = Number(1); if(jQuery('#js_pdpQtyMinAttributeValue_'+productId).length) { lowerLimit = Number(jQuery('#js_pdpQtyMinAttributeValue_'+productId).val()); } return lowerLimit; } function isQtyWhole(quantity,productName) { if(!isWhole(quantity)) { var pdpMaxQtyErrorText = "The Quantity entered for Product _PRODUCT_NAME_ must be a whole number, decimals are not allowed, please retry."; pdpMaxQtyErrorText = pdpMaxQtyErrorText.replace('_PRODUCT_NAME_',productName); alert(pdpMaxQtyErrorText); return false; } return true; } function isQtyZero(quantity,productName,productId) { var lowerLimit = Number(getMinQty(productId)); if(quantity == 0) { var pdpMinQtyErrorText = "The Quantity for Product _PRODUCT_NAME_ is less than the minimum allowed. The minimum allowed is _PDP_QTY_MIN_. Please retry."; pdpMinQtyErrorText = pdpMinQtyErrorText.replace('_PRODUCT_NAME_',productName); pdpMinQtyErrorText = pdpMinQtyErrorText.replace('_PDP_QTY_MIN_',lowerLimit); alert(pdpMinQtyErrorText); return true; } return false; } function getQtyInCart(productId) { var qtyInCart = Number(0); return qtyInCart; } function getTotalQtyFromScreen(inputName,rowNum) { var quantity = Number(0); var quantityInputClassAttr = jQuery('#'+inputName+rowNum).attr("class"); jQuery('.'+quantityInputClassAttr).each(function () { if (jQuery(this).val() != '') { quantity = quantity + Number(jQuery(this).val()); } }); return quantity; } function isItemSelectedPdp() { if (document.addform.add_product_id.value == 'NULL' || document.addform.add_product_id.value == '') { OPT = eval("getFormOption()"); for (i = 0; i < OPT.length; i++) { var optionName = OPT[i]; var indexSelected = document.forms["addform"].elements[optionName].selectedIndex; if(indexSelected <= 0) { var properName = OPT[i].substr(2); var parts = properName.split('_'); parts.each(function(element,index){ parts[index] = element.capitalize(); }); properName = parts.join(" "); alert("Please select a " + properName); break; } } return false; } return true; } function isItemSelectedPlp(selectFeatureDiv) { if (!jQuery('#'+selectFeatureDiv+'_add_product_id').length || jQuery('#'+selectFeatureDiv+'_add_product_id').val() == 'NULL' || jQuery('#'+selectFeatureDiv+'_add_product_id').val() == '') { OPT = eval("getFormOption" + selectFeatureDiv + "()"); for (i = 0; i < OPT.length; i++) { var optionName = OPT[i]; var indexSelected = jQuery('div#'+selectFeatureDiv+' select.'+optionName).prop("selectedIndex"); if(indexSelected <= 0 || !jQuery('#'+selectFeatureDiv+'_add_product_id').length) { var properName = OPT[i].substr(2); var properName = properName.replace("_"+selectFeatureDiv,""); var parts = properName.split('_'); parts.each(function(element,index){ parts[index] = element.capitalize(); }); properName = parts.join(" "); alert("Please select a " + properName); break; } } return false; } return true; } function validateCart() { var cartIsValid = true; var productId = ""; var productName = ""; var quantity = ""; return cartIsValid; } function submitMultiSearchForm(form) { var isValid = false; jQuery('form[name=productListForm] input[type="text"]').each(function() { if (jQuery.trim(jQuery(this).val()) != '') { isValid = true; } }); if (isValid == false) { displayDialogBox('search_'); return false; } else { form.submit(); } } function addRow(elm, index) { var addRowElm = elm; var lastDivElm = jQuery('#searchItemDiv'); var rowDiv = new Element('DIV'); rowDiv.setAttribute("class", "entry"); var innerText = " Find Item:<\/label>
<\/div>"; jQuery(rowDiv).html(innerText); jQuery(rowDiv).insertAfter('#searchItemDiv'); jQuery(lastDivElm).removeAttr("id"); jQuery(rowDiv).attr("id","searchItemDiv"); updateIndexPos(addRowElm, index); } function updateIndexPos(addRowElm, index) { index = index + 1; addRowElm.setAttribute("onClick", "javascript:addRow(this,"+index+");"); } //nextRowNumberInputId: the next row number will be stored in a hidden field with this ID //rowClass: all rows will have a common class //placeholderDivId: added Div will go before this DivId //getRowAction: this is the controller action to retrieve the screen that is added as the next row function addNewRow(nextRowNumberInputId, rowClass, placeholderDivId, getRowAction) { //set the next row number as a hidden input on the screen var rowNum = Number(0); if (jQuery('.'+rowClass).length) { rowNum = Number(jQuery("#"+nextRowNumberInputId).val()); } jQuery("#"+nextRowNumberInputId).val(Number(rowNum + 1)); jQuery.get('/'+ getRowAction +';jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1?addRowIndex='+rowNum+'&rnd='+String((new Date()).getTime()).replace(/\D/gi, "")+'', function(data) { jQuery(data).insertBefore("#" + placeholderDivId); }); } function deleteExistingRow(addRemoveIndex,rowClass,nextRowNumberInputId) { jQuery('.'+addRemoveIndex).remove(); if (jQuery('.'+rowClass).length) { //do nothing } else { //set the hidden input rowNumber to 0 jQuery("#"+nextRowNumberInputId).val("0"); } } function elmIsEmpty(elm) { return !jQuery.trim(elm.html()) }
'); var dialogId = '#' + dialogPurpose + 'dialog'; var displayContainerId = '#js_' + dialogPurpose + 'Container'; displayDialogId = '#' + dialogPurpose + 'displayDialog'; dialogTitleId = '#' + dialogPurpose + 'dialogBoxTitle'; titleText = jQuery(dialogTitleId).val(); var url = ""; if (params) { url = '/eCommercePlpQuickLook;jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1?'+params; } else { url = '/eCommercePlpQuickLook;jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1'; } jQuery.get(url, function(data) { jQuery(elm).find('#loadingDiv').remove(); jQuery(elm).append(oldhtml); jQuery(displayContainerId).replaceWith(data); showDialog(dialogId, displayDialogId, titleText); }); } function displayProductScrollActionDialogBox(dialogPurpose,elm) { var params = jQuery(elm).siblings('input.param').serialize(); var dialogId = '#' + dialogPurpose + 'dialog'; var displayContainerId = '#' + dialogPurpose + 'Container'; displayDialogId = '#' + dialogPurpose + 'displayDialog'; dialogTitleId = '#' + dialogPurpose + 'dialogBoxTitle'; titleText = jQuery(dialogTitleId).val(); jQuery(displayContainerId).html('
'); getActionDialog(displayContainerId,params); } function getActionDialog (displayContainerId,params) { var url = ""; if (params) { url = 'eCommercePlpQuickLook?'+params; } else { url = 'eCommercePlpQuickLook'; } jQuery.get(url, function(data) { jQuery(displayContainerId).replaceWith(data); //jQuery(myDialog).dialog( "option", "position", 'center' ); }); } var isWhole_re = /^\s*\d+\s*$/; function isWhole (s) { return String(s).search (isWhole_re) != -1 } function onImgError(elem,type) { var imgUrl = "/osafe_theme/images/user_content/images/"; var imgName= "NotFoundImage.jpg"; switch (type) { case "PLP-Thumb": imgName="NotFoundImagePLPThumb.jpg"; break; case "PLP-Swatch": imgName="NotFoundImagePLPSwatch.jpg"; break; case "PDP-Large": imgName="NotFoundImagePDPLarge.jpg"; break; case "PDP-Alt": imgName="NotFoundImagePDPAlt.jpg"; break; case "PDP-Detail": imgName="NotFoundImagePDPDetail.jpg"; break; case "PDP-Swatch": imgName="NotFoundImagePDPSwatch.jpg"; break; case "CLP-Thumb": imgName="NotFoundImageCLPThumb.jpg"; break; case "MANU-Image": imgName="NotFoundImage.jpg"; break; } elem.src = imgUrl + imgName; elem.onerror = ""; return true; } function getExpDate(days, hours, minutes) { var expDate = new Date(); if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") { expDate.setDate(expDate.getDate() + parseInt(days)); expDate.setHours(expDate.getHours() + parseInt(hours)); expDate.setMinutes(expDate.getMinutes() + parseInt(minutes)); return expDate.toGMTString(); } } function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) { endstr = document.cookie.length; } return unescape(document.cookie.substring(offset, endstr)); } function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { return getCookieVal(j); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function setCookie(name, value, expires, path, domain, secure) { document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } function deleteCookie(name,path,domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } jQuery(document).ready(function () { jQuery('.showNavWidget').click(function() { jQuery('.showNavWidget').hide(); jQuery('.hideNavWidget').show(); jQuery('#eCommerceNavBarMenu').show(); }); jQuery('.hideNavWidget').click(function() { jQuery('.hideNavWidget').hide(); jQuery('.showNavWidget').show(); jQuery('#eCommerceNavBarMenu').hide(); }); jQuery('.dateEntry').each(function(){datePicker(this);}); jQuery('.showLightBoxCart').hover( function(e) { }, function() { } ); jQuery('#eCommerceNavBar').mouseover(function(e) { var id = e.target.id; if((id != "lightCart_displayDialog") && (id != "js_lightBoxCartTitleBar")) { jQuery('.js_lightBoxCartContainer').delay(0).slideUp(850, function() { jQuery('.js_lightBoxCartContainer').remove(); }); } }); jQuery('#eCommercePageBody').mouseover(function(e) { var id = e.target.id; if((id != "lightCart_displayDialog") && (id != "js_lightBoxCartTitleBar")) { jQuery('.js_lightBoxCartContainer').delay(0).slideUp(850, function() { jQuery('.js_lightBoxCartContainer').remove(); }); } }); jQuery('#eCommerceHeader').mouseover(function(e) { var id = e.target.id; if((id != "siteShoppingCartSize") && (id != "lightCart_displayDialog")) { jQuery('.js_lightBoxCartContainer').delay(0).slideUp(850, function() { jQuery('.js_lightBoxCartContainer').remove(); }); } }); jQuery(window).scroll(function() { var heightBody = jQuery('#eCommercePageBody').height(); var y = jQuery(window).scrollTop(); if( y > (heightBody*.10) ) { jQuery(".js_scrollToTop").fadeIn("slow"); } else { jQuery('.js_scrollToTop').fadeOut('slow'); } }); function __highlight(s, t) { var matcher = new RegExp("("+jQuery.ui.autocomplete.escapeRegex(t)+")", "ig" ); return s.replace(matcher, "$1"); } jQuery('.checkDelivery').click(function(e) { displayActionDialogBox('pincodeChecker_',this); }); jQuery('.pincodeChecker_Form').submit(function(event) { event.preventDefault(); jQuery.get(jQuery(this).attr('action')+'?'+jQuery(this).serialize(), function(data) { jQuery('#js_pincodeCheckContainer').replaceWith(data); }); }); jQuery('.js_cancelPinCodeChecker').click(function(event) { event.preventDefault(); jQuery(displayDialogId).dialog('close'); }); }); function displayLightDialogBox(dialogPurpose) { var dialogId = '#' + dialogPurpose + 'dialog'; displayDialogId = '#' + dialogPurpose + 'displayDialog'; dialogTitleId = '#' + dialogPurpose + 'dialogBoxTitle'; titleText = jQuery(dialogTitleId).val(); showLightBoxDialog(dialogId, displayDialogId, titleText); } function showLightBoxDialog(dialog, displayDialog, titleText) { myDialog = jQuery(displayDialog).dialog({ modal: false, draggable: true, resizable: true, width: 'auto', autoResize:true, position: 'center', title: titleText }); var dialogClass = displayDialog; dialogClass = dialogClass.replace(/^#+/, ""); jQuery(myDialog).parent().addClass(dialogClass); jQuery(myDialog).siblings('.ui-dialog-titlebar').width(jQuery(myDialog).width()); } function datePicker(triger) { jQuery(triger).datepicker({ showOn: 'button', buttonImage: '/images/cal.gif', buttonImageOnly: false, dateFormat: 'mm/dd/y' }); } function addMultiOrderItems() { var addItemsToCart = "true"; var itemSelected = false; var count = 0; jQuery('.js_add_multi_product_quantity').each(function () { reOrderQtyIdArr = jQuery(this).attr("id").split("_"); variantIsChecked = jQuery('#js_add_multi_product_id_'+reOrderQtyIdArr[5]).is(":checked"); if(variantIsChecked) { itemSelected = true; var quantity = jQuery(this).val(); var add_productId = jQuery('#js_add_multi_product_id_'+reOrderQtyIdArr[5]).val(); var productName = jQuery('#js_productName_'+count).val(); if(quantity != "") { if(isQtyWhole(quantity,productName)) { if(!(isQtyZero(quantity,productName,add_productId))) { quantity = Number(quantity) + Number(getQtyInCart(add_productId)); if(!(validateQtyMinMax(add_productId,productName,quantity))) { addItemsToCart = "false"; } } else { addItemsToCart = "false"; } } else { addItemsToCart = "false"; } } else { alert("Please enter re-order quantity"); addItemsToCart = "false"; } } count = count + 1; }); if (!itemSelected) { alert("Please select items to order"); addItemsToCart = "false"; } if(addItemsToCart == "true") { document.reOrderItemForm.action="https://www.purityproducts.com/addMultiItemsToCart;jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1"; document.reOrderItemForm.submit(); } } function seqReOrderCheck(elm) { reOrderQtyIdArr = jQuery(elm).attr("id").split("_"); if(jQuery(elm).val()=="") { jQuery('#js_add_multi_product_id_'+reOrderQtyIdArr[5]).attr("checked", false); } else { jQuery('#js_add_multi_product_id_'+reOrderQtyIdArr[5]).attr("checked", true); } } function findOrderItems(elm) { document.reOrderItemSearchForm.action="https://www.purityproducts.com/eCommerceReOrderItems;jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1"; document.reOrderItemSearchForm.submit(); } function showTooltip(text, elm, elmType) { var tooltipBox = jQuery('.js_tooltip')[0]; if(text != "") { var obj2 = jQuery('.js_tooltipText')[0]; obj2.innerHTML = text; } tooltipBox.style.display = 'block'; var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
 var eCommerceContentLeftPos = 0; var WW = jQuery(window).width(); var WH = jQuery(window).height(); var EX = ""; var EY = ""; if(elmType == "icon") { //subtracting the sl and st from element left and top position because element left and top includes the scroll pixels. EX = jQuery(elm).children().offset().left - sl; EY = jQuery(elm).children().offset().top - st; } else if(elmType == "input") { //subtracting the sl and st from element left and top position because element left and top includes the scroll pixels. EX = jQuery(elm).offset().left - sl; EY = jQuery(elm).offset().top - st; } var TTW = jQuery(tooltipBox).width(); var TTH = jQuery(tooltipBox).height(); var LP = 0; var TP = 0; var EH = jQuery(elm).children().height(); var EW = jQuery(elm).children().width(); var EH = ""; var EW = ""; if(elmType == "icon") { EH = jQuery(elm).children().height(); EW = jQuery(elm).children().width(); } else if(elmType == "input") { EH = jQuery(elm).height(); EW = jQuery(elm).width(); } var TOP = eval(EY > TTH); var BOTTOM = eval(!(TOP)); var LEFT = eval((TTW + EX) > WW); var RIGHT = eval(!(LEFT)); if(BOTTOM && LEFT) { jQuery('.js_tooltipTop').removeClass("tooltipTopLeftArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomRightArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomLeftArrow"); jQuery('.js_tooltipTop').addClass("tooltipTopRightArrow"); } else if(BOTTOM && RIGHT) { jQuery('.js_tooltipTop').removeClass("tooltipTopRightArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomRightArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomLeftArrow"); jQuery('.js_tooltipTop').addClass("tooltipTopLeftArrow"); } else if(TOP && LEFT) { jQuery('.js_tooltipTop').removeClass("tooltipTopLeftArrow"); jQuery('.js_tooltipTop').removeClass("tooltipTopRightArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomLeftArrow"); jQuery('.js_tooltipBottom').addClass("tooltipBottomRightArrow"); } else if(TOP && RIGHT) { jQuery('.js_tooltipTop').removeClass("tooltipTopLeftArrow"); jQuery('.js_tooltipBottom').removeClass("tooltipBottomRightArrow"); jQuery('.js_tooltipTop').removeClass("tooltipTopRightArrow"); jQuery('.js_tooltipBottom').addClass("tooltipBottomLeftArrow"); } if(LEFT) { LP = EX - eCommerceContentLeftPos -TTW + sl + EW; } else { LP = EX - eCommerceContentLeftPos + sl; } if(BOTTOM) { TP = (EY + st + EH); } else { TP = (EY- TTH + st); } jQuery(tooltipBox).css({ top: TP+'px' }); jQuery(tooltipBox).css({ left: LP+'px' }); } function hideTooltip() { document.getElementById('tooltip').style.display = "none"; } function validateQtyMinMax(productId,productName,quantity) { var lowerLimit = Number(getMinQty(productId)); var upperLimit = Number(getMaxQty(productId)); if(quantity != 0) { if(quantity < lowerLimit) { var pdpMinQtyErrorText = "The Quantity for Product _PRODUCT_NAME_ is less than the minimum allowed. The minimum allowed is _PDP_QTY_MIN_. Please retry."; pdpMinQtyErrorText = pdpMinQtyErrorText.replace('_PRODUCT_NAME_',productName); pdpMinQtyErrorText = pdpMinQtyErrorText.replace('_PDP_QTY_MIN_',lowerLimit); alert(pdpMinQtyErrorText); return false; } else if(upperLimit!= 0 && quantity > upperLimit) { var pdpMaxQtyErrorText = "The Quantity for Product _PRODUCT_NAME_ is greater than the maximum allowed. The maximum allowed is _PDP_QTY_MAX_. Please retry."; pdpMaxQtyErrorText = pdpMaxQtyErrorText.replace('_PRODUCT_NAME_',productName); pdpMaxQtyErrorText = pdpMaxQtyErrorText.replace('_PDP_QTY_MAX_',upperLimit); alert(pdpMaxQtyErrorText); return false; } } return true; } function getMaxQty(productId) { var upperLimit = Number(201); if(jQuery('#js_pdpQtyMaxAttributeValue_'+productId).length) { upperLimit = Number(jQuery('#js_pdpQtyMaxAttributeValue_'+productId).val()); } return upperLimit; } function getMinQty(productId) { var lowerLimit = Number(1); if(jQuery('#js_pdpQtyMinAttributeValue_'+productId).length) { lowerLimit = Number(jQuery('#js_pdpQtyMinAttributeValue_'+productId).val()); } return lowerLimit; } function isQtyWhole(quantity,productName) { if(!isWhole(quantity)) { var pdpMaxQtyErrorText = "The Quantity entered for Product _PRODUCT_NAME_ must be a whole number, decimals are not allowed, please retry."; pdpMaxQtyErrorText = pdpMaxQtyErrorText.replace('_PRODUCT_NAME_',productName); alert(pdpMaxQtyErrorText); return false; } return true; } function isQtyZero(quantity,productName,productId) { var lowerLimit = Number(getMinQty(productId)); if(quantity == 0) { var pdpMinQtyErrorText = "The Quantity for Product _PRODUCT_NAME_ is less than the minimum allowed. The minimum allowed is _PDP_QTY_MIN_. Please retry."; pdpMinQtyErrorText = pdpMinQtyErrorText.replace('_PRODUCT_NAME_',productName); pdpMinQtyErrorText = pdpMinQtyErrorText.replace('_PDP_QTY_MIN_',lowerLimit); alert(pdpMinQtyErrorText); return true; } return false; } function getQtyInCart(productId) { var qtyInCart = Number(0); return qtyInCart; } function getTotalQtyFromScreen(inputName,rowNum) { var quantity = Number(0); var quantityInputClassAttr = jQuery('#'+inputName+rowNum).attr("class"); jQuery('.'+quantityInputClassAttr).each(function () { if (jQuery(this).val() != '') { quantity = quantity + Number(jQuery(this).val()); } }); return quantity; } function isItemSelectedPdp() { if (document.addform.add_product_id.value == 'NULL' || document.addform.add_product_id.value == '') { OPT = eval("getFormOption()"); for (i = 0; i < OPT.length; i++) { var optionName = OPT[i]; var indexSelected = document.forms["addform"].elements[optionName].selectedIndex; if(indexSelected <= 0) { var properName = OPT[i].substr(2); var parts = properName.split('_'); parts.each(function(element,index){ parts[index] = element.capitalize(); }); properName = parts.join(" "); alert("Please select a " + properName); break; } } return false; } return true; } function isItemSelectedPlp(selectFeatureDiv) { if (!jQuery('#'+selectFeatureDiv+'_add_product_id').length || jQuery('#'+selectFeatureDiv+'_add_product_id').val() == 'NULL' || jQuery('#'+selectFeatureDiv+'_add_product_id').val() == '') { OPT = eval("getFormOption" + selectFeatureDiv + "()"); for (i = 0; i < OPT.length; i++) { var optionName = OPT[i]; var indexSelected = jQuery('div#'+selectFeatureDiv+' select.'+optionName).prop("selectedIndex"); if(indexSelected <= 0 || !jQuery('#'+selectFeatureDiv+'_add_product_id').length) { var properName = OPT[i].substr(2); var properName = properName.replace("_"+selectFeatureDiv,""); var parts = properName.split('_'); parts.each(function(element,index){ parts[index] = element.capitalize(); }); properName = parts.join(" "); alert("Please select a " + properName); break; } } return false; } return true; } function validateCart() { var cartIsValid = true; var productId = ""; var productName = ""; var quantity = ""; return cartIsValid; } function submitMultiSearchForm(form) { var isValid = false; jQuery('form[name=productListForm] input[type="text"]').each(function() { if (jQuery.trim(jQuery(this).val()) != '') { isValid = true; } }); if (isValid == false) { displayDialogBox('search_'); return false; } else { form.submit(); } } function addRow(elm, index) { var addRowElm = elm; var lastDivElm = jQuery('#searchItemDiv'); var rowDiv = new Element('DIV'); rowDiv.setAttribute("class", "entry"); var innerText = " Find Item:<\/label>
<\/div>"; jQuery(rowDiv).html(innerText); jQuery(rowDiv).insertAfter('#searchItemDiv'); jQuery(lastDivElm).removeAttr("id"); jQuery(rowDiv).attr("id","searchItemDiv"); updateIndexPos(addRowElm, index); } function updateIndexPos(addRowElm, index) { index = index + 1; addRowElm.setAttribute("onClick", "javascript:addRow(this,"+index+");"); } //nextRowNumberInputId: the next row number will be stored in a hidden field with this ID //rowClass: all rows will have a common class //placeholderDivId: added Div will go before this DivId //getRowAction: this is the controller action to retrieve the screen that is added as the next row function addNewRow(nextRowNumberInputId, rowClass, placeholderDivId, getRowAction) { //set the next row number as a hidden input on the screen var rowNum = Number(0); if (jQuery('.'+rowClass).length) { rowNum = Number(jQuery("#"+nextRowNumberInputId).val()); } jQuery("#"+nextRowNumberInputId).val(Number(rowNum + 1)); jQuery.get('/'+ getRowAction +';jsessionid=D1DFB7588C259C6EBB58617FD0374DD2.jvm1?addRowIndex='+rowNum+'&rnd='+String((new Date()).getTime()).replace(/\D/gi, "")+'', function(data) { jQuery(data).insertBefore("#" + placeholderDivId); }); } function deleteExistingRow(addRemoveIndex,rowClass,nextRowNumberInputId) { jQuery('.'+addRemoveIndex).remove(); if (jQuery('.'+rowClass).length) { //do nothing } else { //set the hidden input rowNumber to 0 jQuery("#"+nextRowNumberInputId).val("0"); } } function elmIsEmpty(elm) { return !jQuery.trim(elm.html()) }