$(document).ready(function(){var comHighlightRemove;$(".compare-products-wrapper .top-item-grid-body").removeClass("comHighlight");$(".back_comparethis").each(function(index){if($(this).val()=="checked"){$(this).prev('.comparethis').prop("checked",true);}else{$(this).prev('.comparethis').prop("checked",false);}});$(document).on('click','.comparethis',function(e){var selectedCheckbox=$(this);var count=ACC.common.getCompareCountBadge();if($(this).is(':checked')==true){$('.action_section a').addClass('back_Item');$('.back_comparethis').addClass('selected');$(this).next('.back_comparethis').val('checked');if(count>=5){$(this).attr('checked',false);$('.customwarning').html("<div class='warning'><h5><i class='fas fa-exclamation-triangle'></i> Only five (5) products may be compared at a time.</h5></div>");$('#compareAll').show();if($(".compare").hasClass("open")){$('.compare .compare-products-wrapper').on('hide.bs.dropdown',function(){$('.compare [data-toggle="dropdown"]').dropdown('toggle');});}else{$('.compare [data-toggle="dropdown"]').dropdown('toggle');}
e.stopPropagation();return;}
var checkboxelement=$(this).attr("value");var code=$(this).attr("compareCode");var urlr=ACC.config.contextPath+'/productcomparison/addToCompare?code='+$(this).attr("compareCode");var url='${addTocompareURL}'+code;ACC.common.setCompareCountBadge(count);$.ajax({url:urlr,type:'POST',cache:false,success:function(data){var dataLength=$(data).find('div#totalCounts').text();if(parseInt(dataLength)>'0'){$("#countchk").css("display","inline-block");}
if(parseInt(dataLength)==parseInt(count)){$('#containers :input[value="'+checkboxelement+'"]').removeAttr("checked");}
else{if(parseInt(dataLength)>=1){$('.comparebtn').show();if(parseInt(dataLength)<=5){$('#compareAll').show();$('#removeAll').show();selectedCheckbox.addClass("selected");$('.compare [data-toggle="dropdown"]').dropdown('toggle');ACC.common.setCompareCountBadge(dataLength);}}
else{$('.comparebtn').hide();}
if(ACC.common.getCompareCountBadge()>0){if(parseInt(dataLength)>4){$('.selected').removeAttr("disabled");}
else{$('.compare-item-control').removeAttr("disabled");}}}
var value=code;value.replace(".","");code=value.replace(".","");$('div.cart-table.cartTable div.top-item-grid').replaceWith($(data).find('div.top-item-grid'));$(".compare-products-wrapper .top-item-grid-body").removeClass("comHighlight");$(".compare-products-wrapper #item-compare-"+code).addClass("comHighlight");clearTimeout(comHighlightRemove);comHighlightRemove=setTimeout(function(){$(".compare-products-wrapper .top-item-grid-body").removeClass("comHighlight");},2000);},});}
else{$(this).next('.back_comparethis').val('');url='${removeCompareURL}'+$(this).attr("compareCode");ACC.common.setCompareCountBadge(count);var compProduct=$(this).attr("compareCode");var urlr=ACC.config.contextPath+'/productcomparison/removeCompareProduct?code='+compProduct;$.ajax({url:urlr,type:'POST',success:function(data){$('.compare [data-toggle="dropdown"]').dropdown('toggle');ACC.common.doProductCompareRemove(data,compProduct);selectedCheckbox.removeClass("selected");}});}});});$(document).ready(function(){$(document).on('keypress','.comparethis',function(e){if(e.keyCode==13){$(this).prop('checked',true);$('.compare [data-toggle="dropdown"]').dropdown('toggle');var count=0;var selectedCheckbox=$(this);if($('span#countchk.badge').text().length>0){count=$('span#countchk.badge').text();}
if($(this).is(':checked')==true){if(count>=5){$(this).attr('checked',false);if(!$('.customwarning').hasClass("<div class='warning'><h5><i class='fas fa-exclamation-triangle'></i> Only five (5) products may be compared at a time.</h5></div>")){$('.customwarning').html("<div class='warning'><h5><i class='fas fa-exclamation-triangle'></i> Only five (5) products may be compared at a time.</h5></div>");}
return;}
var checkboxelement=$(this).attr("value");var code=$(this).attr("compareCode");var urlr=ACC.config.contextPath+'/productcomparison/addToCompare?code='+$(this).attr("compareCode");var url='${addTocompareURL}'+code;ACC.common.setCompareCountBadge(count);$.ajax({url:urlr,type:'POST',success:function(data){$("#countchk").css("display","inline-block");var dataLength=$(data).find('div#totalCounts').text();if(parseInt(dataLength)==parseInt(count)){$('.comparebtn').show();$('#containers :input[value="'+checkboxelement+'"]').removeAttr("checked");}
else{if(parseInt(dataLength)>=1){$('.comparebtn').show();if(parseInt(dataLength)<=5){$('#compareAll').show();$('#removeAll').show();selectedCheckbox.addClass("selected");$('.compare [data-toggle="dropdown"]').dropdown('toggle');ACC.common.setCompareCountBadge(dataLength)}}
else{$('.comparebtn').hide();}
if($('span#countchk.badge').text().length>0){if(parseInt(dataLength)>4){$('.selected').removeAttr("disabled");}
else{$('.compare-item-control').removeAttr("disabled");}}}
$('div.cart-table.cartTable div.top-item-grid').replaceWith($(data).find('div.top-item-grid'));},});}}});});