function passiveListeners(){$.event.special.touchstart={setup:function(_,ns,handle){this.addEventListener('touchstart',handle,{passive:!ns.includes('noPreventDefault')})}};$.event.special.touchmove={setup:function(_,ns,handle){this.addEventListener('touchmove',handle,{passive:!ns.includes('noPreventDefault')})}}} function doAction(page,action,extra){var split=extra.split('|');extra=split[0];var qty=split[1];if(!qty)qty=1;if(page.indexOf('/')<0){page=page.replace(/ /g,'/');if(page.charAt(0)!='/')page='/'+page;extra=extra.replace(/ /g,'/');if((extra.charAt(extra.length-1)!='/')&&(extra.indexOf('?')<0)&&(extra.indexOf('#')<0))extra+='/';if(action!='page')var actionurl=page+'/action/'+action+'/'+extra;else var actionurl=page+'/page/'+extra+'/';actionurl=actionurl.replace(/\/\//g,'/')}else{actionurl=page+extra} if((action=='add')||(action=='mod')){doBasket(actionurl,'addajax='+qty)}else if(action=='view'){doBasket(actionurl,'addajax=v')}else if((action=='notify')||(action=='friend')){if(actionurl.match(/\?/))pageDialog(actionurl+'&quickview=1');else pageDialog(actionurl+'?quickview=1')}else{if(qty>1)actionurl+='?quantity='+qty;window.location.href=actionurl}} function doBasket(actionurl,data){if(actionurl.indexOf('/checkout')==0)$('#personal_submit').prop('disabled',!0);$.post(actionurl,data,function(response){if(response.substr(0,4)!='http'){response=$.parseJSON(response);if((response.dialog1)&&(response.dialog2)&&(actionurl.indexOf('silent=1')<0)){$('#dialog_basket').html(response.dialog1);eval(response.dialog2)}else if($('#dialog_basket').hasClass('active')){basketClose()} if($('.block_added').length||$('.block_basket').length||$('.block_summary').length){$('.block_added').html(response.block_added);if(response.block_added){$('.block_added').removeClass('hideblock').show();setTimeout(function(){carousel('.block_added')},200)}else{$('.block_added').addClass('hideblock').hide()} $('.block_basket').html(response.block_basket);if(response.block_basket){$('.block_basket').removeClass('hideblock').show();setTimeout(function(){carousel('.block_basket')},200)}else{$('.block_basket').addClass('hideblock').hide()} $('.block_summary').html(response.block_summary);if(response.block_summary)$('.block_summary').removeClass('hideblock').show();else $('.block_summary').addClass('hideblock').hide()} $('.basket_totalitems').html(response.basket_totalitems);$('.basket_viewitems').html(response.basket_viewitems);$('.basket_items').html(response.basket_items);var iclass=$('.basket_icon span[class^="bp-icon-"]').first().attr('class');if(iclass)iclass=iclass.replace(/\-b$/,'');var iclassb=iclass+'-b';if(response.basket_items!='0'){if(iclass)$('.basket_icon span[class^="bp-icon-"]').removeClass(iclass).addClass(iclassb);$('.icon_items').html(response.basket_items);$('.basket_count').show();if(response.added_pid){$('.basket_count').addClass('pulse');setTimeout(function(){$('.basket_count').removeClass('pulse')},1000);if(data.indexOf('quickview=1')>=0){$('.basket_count',window.parent.document).removeClass('pulse').addClass('pulse');setTimeout(function(){$('.basket_count',window.parent.document).removeClass('pulse')},1000)}}}else{if(iclass)$('.basket_icon span[class^="bp-icon-"]').removeClass(iclassb).addClass(iclass);$('.icon_items').html('');$('.basket_count').hide()} $('.basket_total').html(response.basket_total);$('.basket_totalex').html(response.basket_totalex);$('.basket_subtotal').html(response.basket_subtotal);$('.basket_subtotalex').html(response.basket_subtotalex);if(typeof hookBasket=='function')hookBasket();if(response.basket_page){var content='body.type_basket #cb_id_CONTENT';$(content).html(response.basket_page);$('.lightbox, a[rel^=lightbox]',content).each(function(){lightbox(this)})} if(response.basket_message)alertDialog(response.basket_message);if(response.wishlist_items!='0'){$('.wishlist_icon span[class^="bp-icon-"]').removeClass('pulse').removeClass('bp-icon-heart').addClass('bp-icon-heart-b');if(response.wishlist_pid){$('.wishlist_icon span[class^="bp-icon-"]').addClass('pulse');setTimeout(function(){$('.wishlist_icon span[class^="bp-icon-"]').removeClass('pulse')},1000);if(data.indexOf('quickview=1')>=0){$('.wishlist_icon span[class^="bp-icon-"]',window.parent.document).removeClass('pulse').removeClass('bp-icon-heart').addClass('bp-icon-heart-b').addClass('pulse');setTimeout(function(){$('.wishlist_icon span[class^="bp-icon-"]',window.parent.document).removeClass('pulse')},1000)}}}else{$('.wishlist_icon span[class^="bp-icon-"]').removeClass('pulse').removeClass('bp-icon-heart-b').addClass('bp-icon-heart')} if(response.wishlist_pid)$('.product_icon.product_'+response.wishlist_pid+' span[class^="bp-icon-"]').removeClass('pulse').removeClass('bp-icon-heart').addClass('bp-icon-heart-b pulse');if(response.delivery)$('#delivery').replaceWith(response.delivery);if($('#delivery_date').length){if(response.delivery_date){$('#delivery_date').html(response.delivery_date);$('.s_date').show();eval(response.delivery_pick)}else{$('#delivery_date').html('');$('.s_date').hide()}} if(response.delivery_message)alertDialog(response.delivery_message);if(response.delivery_comments=='1'){$('.s_message').show();if(response.delivery_info)$('.s_message_i').show();else $('.s_message_i').hide();$('.s_message_i .subtext').html(''+response.delivery_info+'');maxlength=parseInt(response.delivery_charlimit);var messagetext=$('.s_message textarea').val();if((maxlength)&&(messagetext.length>maxlength))$('.s_message textarea').val(messagetext.substring(0,maxlength));$('#message_disabled').val(0)}else{$('.s_message, .s_message_i').hide();$('#message_disabled').val(1)} if(response.s_duties){$('.s_duties').show();$('#s_duties').html(response.s_duties);$('#s_duties_c').html(response.s_duties_c);if(response.s_duties_r=='1'){$('#duties_now').prop('checked',!0);$('.duties_later').hide()}else{$('.duties_later').show()}}else{$('.s_duties').hide()} if((response.added_google=='1')&&(response.added_sku)&&(typeof gtag!='undefined')){gtag('event','add_to_cart',{'items':[{'id':response.added_sku,'name':response.added_title,'variant':response.added_variant,'brand':response.added_brand,'quantity':response.added_quantity,'price':response.added_price}]})} if((response.added_facebook=='1')&&(response.added_sku)&&(typeof fbq!='undefined')){fbq('track','AddToCart',{'value':response.added_price,'currency':response.added_currency,'content_name':response.added_title,'content_type':'product','contents':[{'id':response.added_sku,'quantity':response.added_quantity}]})} if((response.added_pinterest=='1')&&(response.added_sku)&&(typeof pintrk!='undefined')){pintrk('track','addtocart',{'value':response.added_price,'order_quantity':response.added_quantity,'currency':response.added_currency,'line_items':[{'product_id':response.added_sku,'product_name':response.added_title,'product_quantity':response.added_quantity,'product_price':response.added_price}]})} if((response.added_klaviyo=='1')&&(response.added_sku)&&(typeof _learnq!='undefined')){klaviyo.push(['track','Added to Cart',{'$value':response.added_price*response.added_quantity,'AddedItemPrice':response.added_price,'AddedItemQuantity':response.added_quantity,'AddedItemProductName':response.added_title,'AddedItemSKU':response.added_sku,'AddedItemImageURL':response.added_image,'Items':[{'SKU':response.added_sku,'ProductName':response.added_title,'Quantity':response.added_quantity,'ItemPrice':response.added_price,'RowTotal':response.added_price*response.added_quantity,'ImageURL':response.added_image}]}])} if((response.address)&&(actionurl.indexOf('delivery=')<0)){$('.addressdef, .addresslist').remove();$('#pre_address').after(response.address);if(!$('#dialog_basket').hasClass('active')&&!response.address_shipping)selectDelivery();} if((response.address_shipping)&&(actionurl.indexOf('delivery=')<0)){$('.addressdef_shipping, .addresslist_shipping').remove();$('#pre_address_shipping').after(response.address_shipping);if(!$('#dialog_basket').hasClass('active'))selectDelivery();} if((data.indexOf('quickview=1')>=0)&&(!response.wishlist_pid)){window.parent.doBasket(window.parent.location.href,'addajax=v');window.parent.closeDialog()} if(typeof easyedit!='undefined'){if(easyedit==1)bindings();} if(actionurl.indexOf('/checkout')==0)$('#personal_submit').prop('disabled',!1);}else{if($('form[name=details]').length){var split1=response.split('/');var split2=$('form[name=details]').attr('action').split('/');if(split1[3]==split2[1]){if(response.indexOf('parent=1')>=0)$('form[name=details]').attr('target','_top');$('form[name=details]').attr('action',response).submit()}else{if(response.indexOf('parent=1')>=0)window.parent.location.href=response;else window.location.href=response}}else{if(response.indexOf('parent=1')>=0)window.parent.location.href=response;else window.location.href=response}}})} function doWish(actionurl,data){data=data.replace(/action=add/,'action=addwish');doBasket(actionurl,data)} var checkoutTrans=0;function doCheckout(actionurl,form){var data='chkajax=1';if(form){actionurl=$('form#'+form).attr('action');data=$('form#'+form).serialize()+'&chkajax=1'} if(actionurl){var timer=setTimeout(function(){waitDialog(0.4,1)},1000);$.post(actionurl,data,function(response){if(timer)clearTimeout(timer);closeWaitDialog();if(response.substr(0,6)!=''){response=$.parseJSON(response);$('.flatpickr-calendar').remove();$('#checkout_bar').html(response.checkout_bar);checkoutTrans=0;doSection('checkout_personal',response.checkout_personal);doSection('checkout_additional',response.checkout_additional);doSection('checkout_payment',response.checkout_payment);if(checkoutTrans>0)checkoutTrans+=50;if($('.block_summary').length){$('.block_summary').html(response.block_summary);if(response.block_summary)$('.block_summary').removeClass('hideblock').show();else $('.block_summary').addClass('hideblock').hide()} if(response.checkout_message)setTimeout(function(){alertDialog(response.checkout_message,0)},checkoutTrans);if(response.checkout_script)$(response.checkout_script).appendTo('body');var active='';if(response.checkout_personal&&response.checkout_personal.includes('checkout_active'))active='personal';else if(response.checkout_additional&&response.checkout_additional.includes('checkout_active'))active='additional';else if(response.checkout_payment&&response.checkout_payment.includes('checkout_active'))active='payment';if(active)setTimeout(function(){goSection(active)},checkoutTrans)}else{var body=response.match(/]*>([\s\S]*)<\/body>/)[1];$('#checkout_payment').html($('#checkout_payment .checkout_heading').first()[0].outerHTML+body);var onload=response.match(/function OnLoadEvent\(\) \{ (.*) \}/)[1];if(onload){if(onload=="document.form.submit();")setTimeout(function(){$('#checkout_payment form').first().submit()},50);else eval(onload)}}})}} function doSection(id,content){var section=$('#'+id);if($(section).length){var slideTrans=parseInt(getComputedStyle(section[0]).getPropertyValue('--checkout-slide-trans'));var fadeTrans=parseInt(getComputedStyle(section[0]).getPropertyValue('--checkout-fade-trans'));if((slideTrans>0)||(fadeTrans>0)){var oldCount=$(section).html().split('=(fraction*2.5))))goTo('#checkout_'+section,fraction);} function autocomplete(field,del,min){$(field).wrap('
').after('
');var suggestions=$(field).next('.suggestions');$(field).keyup(delay(function(e){if((e.keyCode!=13)&&(e.keyCode!=27)&&(e.keyCode!=38)&&(e.keyCode!=40)){if($(this).val().length>=min){$.ajax({url:'/includes/autocomplete.php',dataType:'json',data:{term:$(field).val(),langid:2,currid:0,userid:0,v:2},beforeSend:function(){$(field).addClass('autoloading')},success:function(data){if(data.length>0){$(field).removeClass('autoloading');$(suggestions).html('').show();$.each(data,function(index,item){var offset=item.label.lastIndexOf('-1){offset=item.label.indexOf('>',offset)+1;var offset2=item.label.lastIndexOf('');if(offset2>-1){var s=$(field).val().replace(/"/g,'').replace(/\s+$/,'');var re=new RegExp(s,'i');var t=item.label.substr(offset,offset2-offset);var tt=t.replace(re,'~~');var rep=t.substr(tt.indexOf('~~'),s.length);item.label=item.label.substr(0,offset)+tt.replace(/~~/,''+rep+'')+item.label.substr(offset2)}} $(suggestions).append(''+item.label+'')})}else{$(field).removeClass('autoloading');$(suggestions).html('').hide()}},error:function(e){$(field).removeClass('autoloading');$(suggestions).html('').hide()}})}else{$(field).removeClass('autoloading');$(suggestions).html('').hide()}}},del));$(field).focus(function(){$('.suggestions').each(function(){if(this!=suggestions)$(this).hide();});$(field).removeClass('autoloading');if($(suggestions).html().length>0)$(suggestions).show();});$(document).click(function(){$(field).removeClass('autoloading');$(suggestions).hide()});$(field).add(suggestions).click(function(e){e.stopPropagation()});$(field).keydown(function(e){if((e.keyCode==13)||(e.keyCode==38)||(e.keyCode==40)){var count=0;var focused=-1;$(suggestions).children().each(function(){if($(this).hasClass('focused'))focused=count;count++});$(suggestions).children().each(function(){$(this).removeClass('focused')});if(e.keyCode==13){if(focused>=0){e.preventDefault();window.location.href=$(suggestions).children().eq(focused).attr('href')}}else{e.preventDefault();if(e.keyCode==38){if(focused>0)$(suggestions).children().eq(focused-1).addClass('focused');else if(focused<0)$(suggestions).children().last().addClass('focused');}else{if((focused+1)<$(suggestions).children().length)$(suggestions).children().eq(focused+1).addClass('focused');}}}else if(e.keyCode==27){$(field).blur();$(field).removeClass('autoloading');$(suggestions).hide()}});$(suggestions).hover(function(){$(suggestions).children().each(function(){$(this).removeClass('focused')})})} function delay(callback,ms){var timer=0;return function(){var context=this,args=arguments;clearTimeout(timer);timer=setTimeout(function(){callback.apply(context,args)},ms||0)}} var hover=window.matchMedia('(hover: hover) and (pointer: fine)').matches;function bodyFix(){var top=document.documentElement.scrollTop;$('body').css({'position':'fixed','top':(0-top)+'px'})} function bodyUnfix(){if($('body').css('position')=='fixed'){var sb=$('html').css('scroll-behavior');if(sb=='smooth')$('html').css('scroll-behavior','auto');var top=Math.abs($('body').css('top').replace(/px/,''));if(isNaN(top))top=0;$('body').css({'position':'static','top':'auto'});document.documentElement.scrollTop=top;if(sb=='smooth')$('html').css('scroll-behavior','smooth');}} function hamburger(){$('#nav').removeClass('sticky');if($('#navigation').hasClass('active')===!1){$('#navigation').addClass('active');bodyFix()}else{$('#navigation, #darker').removeClass('active');bodyUnfix()}} function hamburgerNav(){$('#nav .dropdown > a').each(function(){$(this).on('click',function(e){if(parseInt($('#nav').css('z-index'))>150){if($(this).parent('.dropdown').hasClass('active')===!1){e.preventDefault();hamburgerLevel1(this)}else{if(!$('#nav .section1').length){e.preventDefault();hamburgerClose1(this)}}}});if(($(this).hasClass('active'))&&($(this).parent().find('.dropdown_column a.active').length)){hamburgerLevel1(this)}});$('#nav .dropdown_row:not(.dropdown_empty) > a').each(function(){$(this).on('click',function(e){if(parseInt($('#nav').css('z-index'))>150){if($(this).parent('.dropdown_row').hasClass('active')===!1){e.preventDefault();hamburgerLevel2(this)}else{if(!$('#nav .section2').length){e.preventDefault();hamburgerClose2(this)}}}});if(($(this).hasClass('active'))&&($(this).parent().find('li > a.active').length)){hamburgerLevel2(this)}});$('#navigation #darkside').on('click',function(){$('#navigation, #darker').removeClass('active');bodyUnfix()})} function hamburgerLevel1(link){var active='';if($(link).hasClass('active'))active=' class="active"';$(link).parent('.dropdown').before('');$(link).parent('.dropdown').prepend($(link).parent('.dropdown').prevAll('li.navigation_heading').last().children('a').clone().removeClass('active').addClass('section1').on('click',function(e){e.preventDefault();hamburgerClose1(link)}));$(link).parent('.dropdown').addClass('active');$('#nav .navigation_bar').addClass('level1')} function hamburgerLevel2(link){var active='';if($(link).hasClass('active'))active=' active';$(link).parent('.dropdown_row').before('');$(link).parent('.dropdown_row').prepend($(link).parent('.dropdown_row').parent('.dropdown_column').closest('.dropdown_menu').prev('a').clone().removeClass('active').addClass('section2').on('click',function(e){e.preventDefault();hamburgerClose2(link)}));$(link).parent('.dropdown_row').addClass('active');$('#nav .navigation_bar').addClass('level2')} function hamburgerClose1(link){var trans=parseInt(getComputedStyle(document.body).getPropertyValue('--navigation-trans'));$('#nav .navigation_bar').removeClass('level1');setTimeout(function(){$(link).parent('.dropdown').removeClass('active');$('#nav .link1, #nav .section1').remove()},trans)} function hamburgerClose2(link){var trans=parseInt(getComputedStyle(document.body).getPropertyValue('--navigation-trans'));$('#nav .navigation_bar').removeClass('level2');setTimeout(function(){$(link).parent('.dropdown_row').removeClass('active');$('#nav .link2, #nav .section2').remove()},trans)} function darkerNav(){$('#nav .dropdown').hover(function(){if(!$('#darker').hasClass('active'))$('#darker').addClass('active');},function(){if($('#darker').hasClass('active'))$('#darker').removeClass('active');})} function stickyNav(){var nav=document.getElementById('nav');if(nav){var sticky=nav.getBoundingClientRect().top+document.documentElement.scrollTop;window.onscroll=function(){if(sticky>0){if(window.pageYOffset>=sticky){nav.classList.add('sticky');document.getElementById('stuck').style.display='block';document.getElementById('ghost').style.display='block'}else{nav.classList.remove('sticky');document.getElementById('stuck').style.display='none';document.getElementById('ghost').style.display='none'}}else if(window.pageYOffset==0){sticky=nav.getBoundingClientRect().top+document.documentElement.scrollTop}}}} var warningGiven=0;if(mobile()||tablet())warningGiven=1;function capsLock(e){if(!e)e=window.event;if(!e)return;if(warningGiven==1)return;var theKey=0;if(e.which){theKey=e.which}else if(e.keyCode){theKey=e.keyCode}else if(e.charCode){theKey=e.charCode} var theShift=!1;if(e.shiftKey){theShift=e.shiftKey}else if(e.modifiers){if(e.modifiers&4){theShift=!0}} if((theKey>64&&theKey<91&&!theShift)||(theKey>96&&theKey<123&&theShift)){alert('Caps Lock is on, passwords are case-sensitive');warningGiven=1}} var carousels=0;var carouselAuto=new Array();function carousel(context=null,go=0){$('.carousel_items',context).each(function(){if(!$(this).attr('class').match(/carousel_\d+/)){carousels++;$(this).addClass('carousel_'+carousels)} $(this).children().first().addClass('visible');if($(this).is('[class*="columns_"]'))carouselReset(this,1);if($(this).hasClass('loop'))carouselLoop(this,1);if(!$(this).hasClass('loop')){if(go<=1)carouselSet(this);carouselLimit(this)} if(!hover){if(!$(this).hasClass('fade'))$(this).on('scroll',function(){carouselTimeout(this)});$(this).parent().on('touchstart',function(e){e.stopPropagation();var carousel=$(this).children('.carousel_items').first();carouselTouchStart(carousel,e);carouselLoad(carousel)});$(this).parent()[0].addEventListener('touchmove',function(e){e.stopPropagation();var carousel=$(this).children('.carousel_items').first();carouselTouchMove(carousel,e)},{passive:!1});$(this).parent().on('touchend touchcancel',function(e){e.stopPropagation();var carousel=$(this).children('.carousel_items').first();carouselTouchEnd(carousel,e)})} if($(this).hasClass('auto')||$(this).is('[class*="auto_"]')){var container=$(this).closest('.carousel');if($(container).length){if(!$(this).hasClass('nopause'))$(container).hover(function(){$(this).addClass('pause')},function(){$(this).removeClass('pause')});var carousel=this;var interval=carouselInt(carousel,'auto');if(!interval)interval=4000;var index=carouselInt(carousel,'carousel');carouselAuto[index]=setInterval(function(){if(!$(container).hasClass('pause'))carouselGo(carousel,'n');},interval)}} if(go>1){$(this).addClass('free');carouselLoad(this);$(this).children().removeClass('visible');$(this).children().eq(go-1).addClass('visible');carouselReset(this);if($(this).hasClass('loop'))carouselLoop(this,go);var container=$(this).closest('.carousel');$(container).removeClass('invisible');var count=$(this).children().length;setTimeout(function(){carouselVisible(container,0,count,go)},200);$(this).removeClass('free')}});if(go<=1){$('.carousel_dots',context).each(function(){$(this).children().first().addClass('active')})}} var carouselGoing=new Array();function carouselGo(button,go){if($(button).hasClass('inactive'))return;var container=$(button).closest('.carousel');if($(container).length){var carousel=$(container).find('.carousel_items').first();if($(carousel).length){var visible=$(carousel).children('.visible').first();if($(visible).length){var count=$(carousel).children().length;var number=$(visible).index()+1;var current=number;if(go=='n')number++;else if(go=='p')number--;else number=parseInt(go);if($(carousel).hasClass('loop')){if(number<1)number=count;else if(number>count)number=1} var target=$(carousel).children().eq(number-1);if(($(target).length)&&(number>0)&&(number!=current)&&(number<=count)){carouselLoad(carousel,number);var index=carouselInt(carousel,'carousel');if(carouselGoing[index])return;if($(carousel).hasClass('fade')){$(carousel).children().removeClass('visible');$(target).addClass('visible animating');var trans=parseInt(getComputedStyle(carousel[0]).getPropertyValue('--fade-trans'));carouselGoing[index]=setTimeout(function(){carouselVisible(carousel,0,count,number,target);carouselGoing[index]=null},trans);carouselLinks(container,number)}else{$(target).addClass('animating');if(hover){$(carousel).addClass('smooth');setTimeout(function(){$(carousel).css('transform','translateX('+carouselOffset(carousel,target)+'px)')},50);var trans=parseInt(getComputedStyle(carousel[0]).getPropertyValue('--slide-trans'));carouselGoing[index]=setTimeout(function(){carouselVisible(carousel,0,count,number,target,1);carouselGoing[index]=null},trans+100);carouselLinks(container,number)}else{setTimeout(function(){$(carousel)[0].scrollTo({left:$(carousel)[0].scrollLeft+carouselOffset(carousel,target),behavior:'smooth'})},50)}} if(carouselAuto[index]){clearInterval(carouselAuto[index]);var interval=carouselInt(carousel,'auto');if(!interval)interval=4000;carouselAuto[index]=setInterval(function(){if(!$(container).hasClass('pause'))carouselGo(carousel,'n');},interval)}}}}}} function carouselInt(carousel,text){var int=0;$(carousel).attr('class').split(/\s+/).forEach(function(name){var split=name.split('_');if((split[0]==text)&&(!isNaN(split[1]))&&(!int))int=parseInt(split[1]);});return int} function carouselLimit(carousel){var container=$(carousel).closest('.carousel');if($(container).length){var buttons=$(container).children('.carousel_button');if($(buttons).length){var minColumns=0;var children=0;$(carousel).attr('class').split(/\s+/).forEach(function(name){var split=name.split('_');if((split[0]=='columns')&&(!isNaN(split[1]))){var thisColumns=parseInt(split[1]);if((thisColumns)&&((!minColumns)||(thisColumns1)&&(loop<100)){carouselWait(carousel);$(carousel)[0].scrollTo({left:$(carousel)[0].scrollLeft+offset,behavior:'instant'});offset=carouselOffset(carousel,target);loop++}} $(carousel).children().css('transition','')}}else{$(carousel).removeClass('loop')}} function carouselOffset(carousel,target){var targetPosition=$(target).position().left;if($(carousel).is('[class*="columns_"]')){if(hover)return 0-targetPosition;else return targetPosition}else{var carouselWidth=$(carousel).width();var targetWidth=$(target)[0].getBoundingClientRect().width;if(hover){if(targetPosition>=0)return 0-(Math.abs(targetPosition)+(targetWidth/2)-(carouselWidth/2));else return Math.abs(targetPosition)-(targetWidth/2)+(carouselWidth/2)}else{if(targetPosition>=0)return Math.abs(targetPosition)+(targetWidth/2)-(carouselWidth/2);else return 0-(Math.abs(targetPosition)-(targetWidth/2)+(carouselWidth/2))}}} function carouselReset(carousel,initial=0){if($(carousel).is('[class*="columns_"]')){if(initial)$(carousel).removeClass('fade');columnsUpdate(carousel)} if(!initial&&!$(carousel).hasClass('fade')){var visible=$(carousel).children('.visible').first();if($(visible).length){if(hover){$(carousel).css('transform','translateX('+carouselOffset(carousel,visible)+'px)')}else{carouselWait(carousel);$(carousel)[0].scrollTo({left:$(carousel)[0].scrollLeft+carouselOffset(carousel,visible),behavior:'instant'})}}} if(!initial&&!$(carousel).hasClass('loop'))carouselLimit(carousel);} function carouselSet(carousel){var container=$(carousel).closest('.carousel');if($(container).length){var buttons=$(container).children('.carousel_button');if($(buttons).length){$(buttons).removeClass('inactive');$(buttons).first().addClass('inactive')}}} var carouselInterval=new Array();function carouselTimeout(carousel){var index=carouselInt(carousel,'carousel');if(carouselInterval[index]){clearTimeout(carouselInterval[index]);carouselInterval[index]=null} carouselVisible(carousel,1);if(!carouselBusy[index]&&!carouselMoving[index])carouselInterval[index]=setTimeout(function(){carouselVisible(carousel);carouselInterval[index]=null},200)} var initialX=new Array();var latestX=new Array();var sensitivityX=20;var carouselMoving=new Array();function carouselTouchStart(carousel,e){if(!$(carousel).hasClass('fade'))carouselVisible(carousel);var index=carouselInt(carousel,'carousel');initialX[index]=e.touches[0].clientX;latestX[index]=0} function carouselTouchMove(carousel,e){var index=carouselInt(carousel,'carousel');latestX[index]=e.touches[0].clientX;if($(carousel).hasClass('fade')){if((latestX[index]>(initialX[index]+sensitivityX))||(latestX[index]<(initialX[index]-sensitivityX)))carouselMoving[index]=1;if(carouselMoving[index])e.preventDefault();}else{carouselMoving[index]=1}} function carouselTouchEnd(carousel,e){var index=carouselInt(carousel,'carousel');carouselMoving[index]=0;if($(carousel).hasClass('fade')&&latestX[index]){if(latestX[index]>(initialX[index]+sensitivityX))carouselGo(carousel,'p');else if(latestX[index]<(initialX[index]-sensitivityX))carouselGo(carousel,'n');}} function carouselTransform(carousel){var style=getComputedStyle(carousel[0]);var matrix=new WebKitCSSMatrix(style.transform);return 0-matrix.m41} function carouselVisible(carousel,fast=0,count=0,number=0,visible=null,smooth=0){if(!number){var offset=0;var lowest=0;var current=0;if(hover)current=carouselTransform(carousel);$(carousel).children().each(function(){count++;if(hover)offset=Math.abs($(this).position().left-current);else offset=Math.abs($(this).position().left);if((!number)||(offset<=lowest)){number=count;visible=this;lowest=offset}})}else if(smooth){$(carousel).removeClass('smooth')} if(number){if(!fast){$(carousel).children().removeClass('visible');$(visible).addClass('visible');if($(visible).hasClass('animating')){$(visible).removeClass('animating').find('.animation').each(function(){animate(this,'animation')})}} var container=$(carousel).closest('.carousel');if($(container).length){if(!fast){if(!$(carousel).hasClass('loop')){var buttons=$(container).children('.carousel_button');if($(buttons).length){if($(carousel).is('[class*="columns_"]')){var difference=Math.abs(($(carousel)[0].scrollWidth-$(visible).position().left)-$(carousel).width());if(difference<10)count=number} $(buttons).removeClass('inactive');if(number==1)$(buttons).closest('.carousel_prev').addClass('inactive');else if(number==count)$(buttons).closest('.carousel_next').addClass('inactive');}}else{carouselLoop(carousel,number)}} carouselLinks(container,number);var index=carouselInt(carousel,'carousel');if(carouselAuto[index]){clearInterval(carouselAuto[index]);var interval=carouselInt(carousel,'auto');if(!interval)interval=4000;carouselAuto[index]=setInterval(function(){if(!$(container).hasClass('pause'))carouselGo(carousel,'n');},interval)}}}} var carouselBusy=new Array();var carouselWaiting=new Array();function carouselWait(carousel){var index=carouselInt(carousel,'carousel');carouselBusy[index]=1;if(carouselInterval[index]){clearTimeout(carouselInterval[index]);carouselInterval[index]=null} if(carouselWaiting[index]){clearTimeout(carouselWaiting[index]);carouselWaiting[index]=null} carouselWaiting[index]=setTimeout(function(){carouselBusy[index]=0;carouselWaiting[index]=null},100)} function columnsUpdate(grid){if($(grid).length&&$(grid).is('[class*="columns_"]')){var maxColumns=0;var oldColumns=new Array();$(grid).attr('class').split(/\s+/).forEach(function(name){var split=name.split('_');if((split[0]=='columns')&&(!isNaN(split[1]))){if(!maxColumns)maxColumns=parseInt(split[1]);else oldColumns.push(parseInt(split[1]))}});if(maxColumns){var gridWidth=$(grid).width();var minWidth=parseInt(getComputedStyle(grid).getPropertyValue('--column-width'));if(gridWidth&&minWidth){var columnGap=parseInt($(grid).css('column-gap'));if(isNaN(columnGap))columnGap=0;var newColumns=0;for(let i=maxColumns;i>1;i--){var minReq=(minWidth*i)+(columnGap*(i-1));if(minReq>gridWidth)newColumns=i-1;else i=0} if(newColumns)$(grid).addClass('columns_'+newColumns);else if(minWidth>gridWidth)$(grid).addClass('columns_1');oldColumns.forEach(function(num){if(num!=newColumns)$(grid).removeClass('columns_'+num);})}}}} function darken(opacity,fade=0,fix=1){if(opacity>0){if(fade)$('#darken').addClass('fade');$('#darken').css('opacity',opacity).addClass('active');if(fix)bodyFix();}else if(!$('.dialog').length){$('#darken').removeClass().css('opacity','').off('click');if(fix)bodyUnfix();}} function actionDialog(link,tall=0){darken(0.8);var close='';if(tall){$('#dialog_action').addClass('tall');close='
'} $('#dialog_action').html(close+'').addClass('active');if(tall){$('#closedialog').on('click',function(){$('#dialog_action').html('').removeClass('active tall');darken(0)})}} function alertDialog(text,fix=1){text=String(text).replace(/\n/g,'
');darken(0.4,0,fix);var div=$('
'+text+'
').appendTo('body');$(div).find('button').focus().on('click',function(){$(div).remove();darken(0,0,fix)})} function confirmDialog(text,link){text=String(text).replace(/\n/g,'
');darken(0.6);var div=$('
'+text+'
').appendTo('body');$(div).find('button.ok').focus().on('click',function(){$(div).remove();darken(0);if(typeof link.href!='undefined')window.location.href=link.href;else window.location.href=link});$(div).find('button.cancel').on('click',function(){$(div).remove();darken(0)});return!1} function contentDialog(link){darken(0.8);$('#dialog_content').html('').addClass('active')} function mediaDialog(container,object=null){var media='';var alt='';var dots='';var ratio=0;var width=0;var height=0;var aspect=0;var selected=0;var count=0;if($(container).prop('tagName').toLowerCase()=='a'){var href=$(container).attr('href');if((href.indexOf('youtube')!=-1)||(href.indexOf('vimeo')!=-1)){media='').addClass('active');$('#darken, #closedialog').addClass('closable').on('click',function(){$('#dialog_content').html('').removeClass('active');darken(0)})} function popupDialog(obj,width,height,padding,bg,fg,close,opacity){var popup=$('#dialog_popup_'+obj);if($(popup).length){if(opacity!='')darken(opacity);else darken(0.8);if((width!='')&&(!isNaN(width)))width+='px';$(popup).css('max-width',width);if((height!='')&&(!isNaN(height)))height+='px';if(height=='auto')$(popup).css('height',height);else $(popup).css('max-height',height);if(bg)$(popup).css('background-color',bg);if(fg)$(popup).css('color',fg);if((padding!='')&&(!isNaN(padding)))padding+='px';$(popup).css('padding',padding).addClass('active');if(close){if(!$(popup).children('#closedialog').length)$(popup).prepend('
');$('#darken, #closedialog').addClass('closable').on('click',function(){$(popup).removeClass('active');$(popup).children('#closedialog').removeClass('closable').off('click');darken(0)})}}} function waitDialog(opacity=0.8,fade=0){darken(opacity,fade);$('
').appendTo('body')} function closeWaitDialog(){$('.dialog.wait').remove();darken(0)} function closeDialog(){$('#dialog_content').html('').removeClass('active');darken(0)} function basketDialog(delay){$('#dialog_basket').addClass('active');if(!hover&&$('#dialog_basket').hasClass('dialog_left'))bodyFix();if(delay>0){basketTimeout(delay);$('#dialog_basket').on('click mouseover',function(){basketTimeout(delay)})}} var basketInterval=null;function basketTimeout(delay){if(basketInterval){clearTimeout(basketInterval);basketInterval=null} basketInterval=setTimeout(function(){basketClose()},delay*1000)} function basketClose(){$('#dialog_basket').removeClass('active');if(!hover&&$('#dialog_basket').hasClass('dialog_left'))bodyUnfix();} function scrollCheck(){$('#dialog_basket .dialog_text.tabular').scroll(function(){scrollTimeout()})} var scrollInterval=null;function scrollTimeout(){if(scrollInterval){clearTimeout(scrollInterval);scrollInterval=null} scrollInterval=setTimeout(function(){$.post('/includes/position.php',{scrolli:$('#dialog_basket .dialog_text.tabular').scrollTop()})},500)} function scrollSet(top){$('#dialog_basket .dialog_text.tabular').scrollTop(top)} function changeField(obj){if($(obj).hasClass('errorfield')||$(obj).hasClass('upload_text')){$(obj).removeClass('errorfield');if($(obj).closest('form').find('.errorfield').length==0){$(obj).closest('form').find('.error').removeClass('error')}}} function checkLength(obj,max,e,message){var modKey=0;var theKey=0;if(!e)e=window.event;if(e){if(e.ctrlKey||e.metaKey)modKey=1;if(e.which){theKey=e.which}else if(e.keyCode){theKey=e.keyCode}else if(e.charCode){theKey=e.charCode}} if((max)&&($(obj).val().replace(/\r\n/g,' ').replace(/\n/g,' ').length>=max)&&(!modKey)&&(theKey!=8)&&(theKey!=16)&&(theKey!=17)&&(theKey!=18)&&(theKey!=20)&&(theKey!=37)&&(theKey!=38)&&(theKey!=39)&&(theKey!=40)&&(theKey!=46)&&(theKey!=224))alert(message);} function showRow(obj){document.getElementById(obj).style.display=""} function hideRow(obj){document.getElementById(obj).style.display="none"} function toggleRows(){if(document.getElementById('alternate_address').checked){$('.altrow, .address_close').show();$('.addressship').hide();if(document.getElementById('afind')){if(document.getElementById('afind').checked){hideRow('aukrow1');hideRow('aukrow2');hideRow('apcrow')}else{hideRow('aparow1');hideRow('aparow2');hideRow('aparow3')}}}else{$('.altrow, .address_close').hide();$('.addressshipsame').show()}} function filesize(val){if(val<1048576)return comma(Math.round(val/1024))+' KB';else return comma(Math.round(val/1048576))+' MB'} function refineResults(){if($('#product_refine').length){if($('#refine').hasClass('active')===!1){$('#refine').html('
');$('#viewall, #closerefine span').on('click',function(){refineResults()});$('#product_refine').appendTo('#showrefine');$('#refine, #refining').addClass('active');bodyFix();rangeUpdate()}else{var trans=parseInt(getComputedStyle(document.body).getPropertyValue('--dialog-slide-trans'));$('#refine, #refining').removeClass('active');setTimeout(function(){$('#product_refine').appendTo('#block_refine');$('#refine').html('')},trans);bodyUnfix();rangeUpdate()}}} function refiningResults(){$('#refining').on('click',function(){refineResults()})} function minMax(box){$.post('/blocks/refinefields.php',{name:'minmax_'+box,value:$('#group_'+box).css('display'),version:2});if($('#group_'+box).css('display')=='none'){if(box=='p'){$('#title_p').attr('title',minimise);$('#minmax_p > span').removeClass('bp-icon-arrow-down').addClass('bp-icon-arrow-up').attr('title',minimise);$('#group_p').slideDown('fast')}else{$('#title_'+box).attr('title',minimise);$('#minmax_'+box+' > span').removeClass('bp-icon-arrow-down').addClass('bp-icon-arrow-up').attr('title',minimise);$('#group_'+box).slideDown('fast');if($('#space_'+box).css('display')!='none')$('#hr_'+box).show();}}else{if(box=='p'){$('#title_p').attr('title',maximise);$('#minmax_p > span').removeClass('bp-icon-arrow-up').addClass('bp-icon-arrow-down').attr('title',maximise);$('#group_p').slideUp('fast')}else{$('#title_'+box).attr('title',maximise);$('#minmax_'+box+' > span').removeClass('bp-icon-arrow-up').addClass('bp-icon-arrow-down').attr('title',maximise);$('#group_'+box).slideUp('fast',function(){$('#hr_'+box).hide()})}}} function scrollable(val,pos,box){$('.scrollable').each(function(){var grp=$(this).attr('id').split('_');$(this).css('max-height','none');if($(this).innerHeight()>val){$(this).css('max-height',val+'px');$('#space_'+grp[1]).show();if($(this).css('display')!='none')$('#hr_'+grp[1]).show();if((pos)&&($(this).attr('id')==box))$(this).scrollTop(pos);}})} function refineFields(name,value,column,brandlabel,inbrand,inprice,checkboxes,iscrollable,iname,iminprice,imaxprice,message){if((typeof scrollpos!='undefined')&&(value!='clear')&&(value!='range')){if($('#sp_'+iname).css('display')!='none'){scrollpos=document.getElementById('group_'+iname).scrollTop;scrollbox='group_'+iname}} $('#product_refine input, #product_refine label').removeAttr('onclick');$('#product_list_outer').prepend('
<\/div>').find('a').click(function(){return!1});$('#product_list_inner .prla').each(function(){$(this).replaceWith($(this).find('img'))});$('#product_list_inner').fadeTo(100,0.25);$.post('/blocks/refinefields.php',{name:name,value:value,column:column,brandlabel:brandlabel,inbrand:inbrand,inprice:inprice,checkboxes:checkboxes,scrollable:iscrollable,version:2},function(response){response=$.parseJSON(response);$('#product_list_inner').html(' ').css('opacity',1);if(response[0]){$('#product_list').html(response[0]);if($('#product_refine').length)$('.refine_results').on('click',function(){refineResults()});else $('.refine_results').remove();setTimeout(function(){carousel('#product_list')},200);comparison('#product_list')}else{window.location.href=window.location.href;return} $('#product_refine').html(response[1]);if(typeof easyedit!='undefined'){if(easyedit==1)bindings();} if(typeof scrollpos!='undefined'){scrollable(iscrollable,scrollpos,scrollbox)} if(typeof pricereset!='undefined'){priceRange()} if((value=='range')&&(response[2]=='NONE')){pricereset=1;var slider=document.getElementById('slider_p');if(slider){document.getElementById('min_p').value=iminprice;document.getElementById('max_p').value=imaxprice;rangeUpdate()} pricereset=0;alertDialog(message)}})} function refineSort(order,filter,brandlabel){if(!order)$('#product_filter a, #product_filter span').removeAttr('onclick');$('#product_list_outer').prepend('
<\/div>').find('a').click(function(){return!1});$('#product_list_inner').fadeTo(100,0.25);$.post('/blocks/refinefields.php',{order:order,filter:filter,brandlabel:brandlabel,version:2},function(response){response=$.parseJSON(response);$('#product_list_inner').html(' ').css('opacity',1);if(response[0]){$('#product_list').html(response[0]);if($('#product_refine').length)$('.refine_results').on('click',function(){refineResults()});else $('.refine_results').remove();setTimeout(function(){carousel('#product_list')},200);comparison('#product_list')}else{window.location.href=window.location.href;return} if(filter)$('#product_filter').html(response[1]);if(typeof easyedit!='undefined'){if(easyedit==1)bindings();}})} function loadMore(page,brandlabel){$('#product_more').html('
<\/div>');$.post('/blocks/refinefields.php',{page:page,brandlabel:brandlabel,more:1,version:2},function(response){response=$.parseJSON(response);if(response[0]){var object=$('
').append($.parseHTML(response[0]));var products=$('.products > div',object);$(products).each(function(){$(this).appendTo($('#product_list .products'))});var nav=$('#product_nav',object);$('#product_nav').replaceWith(nav);var nav_b=$('#product_nav_b',object);$('#product_nav_b').replaceWith(nav_b);var more=$('#product_more',object);$('#product_more').replaceWith(more);if($('#product_refine').length)$('.refine_results').on('click',function(){refineResults()});else $('.refine_results').remove();if($('.carousel_items',products).length)setTimeout(function(){carousel(products)},200);if($('input[id^="compare_"]',products).length)comparison(products);var ar=$('#product_list .products').css('--aspect-ratio');if(ar){var parts=ar.split('/');var ratio=parseInt(parts[1].trim())/parseInt(parts[0].trim());if(ratio<$('#ratio',object).val())$('#product_list .products').css('--aspect-ratio',$('#ratio_x',object).val()+' / '+$('#ratio_y',object).val());}}else{window.location.href=window.location.href;return} if(typeof easyedit!='undefined'){if(easyedit==1)bindings();}})} function priceRange(){var slider=document.getElementById('slider_p');if(slider){var min=document.getElementById('min_p');var max=document.getElementById('max_p');var rangemin=parseInt(min.getAttribute('min'));var rangemax=parseInt(max.getAttribute('max'));var valuemin=parseInt(min.getAttribute('value'));var valuemax=parseInt(max.getAttribute('value'));var avgvalue=Math.floor((rangemin+rangemax)/2);if((valuemin!=rangemin)||(valuemax!=rangemax))avgvalue=Math.floor((valuemin+valuemax)/2);min.setAttribute('data-value',valuemin);max.setAttribute('data-value',valuemax);slider.setAttribute('data-rangemin',rangemin);slider.setAttribute('data-rangemax',rangemax);rangeDraw(slider,avgvalue);window.addEventListener('resize',function(){rangeUpdate()});min.addEventListener('input',function(){rangeUpdate()});max.addEventListener('input',function(){rangeUpdate()});min.addEventListener('change',function(){priceUpdate(min,max);priceChange(min,max)});max.addEventListener('change',function(){priceUpdate(min,max);priceChange(min,max)});min.addEventListener('touchend',function(){priceUpdate(min,max);priceChange(min,max)});max.addEventListener('touchend',function(){priceUpdate(min,max);priceChange(min,max)})}} function rangeDraw(slider,avgvalue){var thumbsize=parseInt(getComputedStyle(slider).getPropertyValue('--slider-button-size'));var min=document.getElementById('min_p');var max=document.getElementById('max_p');var rangemin=parseInt(slider.getAttribute('data-rangemin'));var rangemax=parseInt(slider.getAttribute('data-rangemax'));var rangewidth=slider.offsetWidth;min.setAttribute('max',avgvalue);max.setAttribute('min',avgvalue);var maxwidth=parseInt(thumbsize+((rangemax-avgvalue)/(rangemax-rangemin))*(rangewidth-(2*thumbsize)));var minwidth=rangewidth-maxwidth;min.style.width=minwidth+'px';max.style.width=maxwidth+'px';min.style.left='0px';max.style.left=min.style.width;if(max.value>(rangemax-1))max.setAttribute('data-value',rangemax);max.value=max.getAttribute('data-value');min.value=min.getAttribute('data-value');priceUpdate(min,max)} function rangeUpdate(){var slider=document.getElementById('slider_p');if(slider){var min=document.getElementById('min_p');var max=document.getElementById('max_p');var minvalue=Math.floor(min.value);var maxvalue=Math.floor(max.value);min.setAttribute('data-value',minvalue);max.setAttribute('data-value',maxvalue);var avgvalue=Math.floor((minvalue+maxvalue)/2);rangeDraw(slider,avgvalue)}} function swatch(icon,name,value,id,car){$(icon).parent().children().removeClass('selected');$(icon).addClass('selected');$.post('/includes/swatch.php',{name:name,value:value,id:id,carousel:car},function(response){response=$.parseJSON(response);if(response.image){var image=$('#'+id);if(car){var iclass=$(image).attr('class').replace(/ loaded/,'');$(image).replaceWith('
'+response.image+'
')}else{$(image).replaceWith('
'+response.image+'
')} image=$('#'+id);var inner_image=$(image).closest('.inner_image');var a=$(inner_image).find('a').first();var href=$(a).attr('href').split('?')[0];$(a).attr('href',href+response.link);a=$(inner_image).parent().find('.inner_title a').first();href=$(a).attr('href').split('?')[0];$(a).attr('href',href+response.link);if(car){if(response.dots)$('#'+id.replace(/image_/,'dots_')).html(response.dots);setTimeout(function(){carousel($(image).closest('.carousel'))},200)}}})} function goTop(){$(document).scroll(function(){var y=$(this).scrollTop();if(y>400)$('.gotop').addClass('active');else $('.gotop').removeClass('active')})} function comparison(context=null){$('input[id^="compare_"]',context).click(function(){var checked=0;$('input[id^="compare_"]').each(function(){if($(this).is(':checked'))checked++});if(checked>0)$('.compare').addClass('active');else $('.compare').removeClass('active')})} function comma(val){return String(val).split('').reverse().join('').replace(/(.{3}\B)/g,'$1,').split('').reverse().join('')} function lightbox(container){if($(container).prop('tagName').toLowerCase()=='a'){$(container).on('click',function(){mediaDialog(container);return!1})}else{$(container).find('img, video, .video_wrap').each(function(){$(this).on('click',function(){if($(this).hasClass('video_wrap'))mediaDialog(container,$(this).children().first()[0]);else mediaDialog(container,this);if($(container).hasClass('magnify'))magnify($('#dialog_media'));return!1})})}} function magnify(container){$(container).find('.magnify').first().on('click',function(e){magnifyClick(this,e)}).on('mousemove',function(e){magnifyMove(e,1)}).on('touchmove',function(e){magnifyMove(e,2)}).on('mouseleave',function(){magnifyOff(this)})} function magnifyClick(container,e){if(!$(container).children('#magnify').length)magnifyOn(container,e);else magnifyOff(container)} function magnifyOn(container,e){var image=$(container).find('img.visible').first();var src=$(image).attr('src');if(src){$('#zoomimage > span').removeClass('bp-icon-zoom-in').addClass('bp-icon-zoom-out');var scale=$(image).prop('naturalWidth')/$(image).width();if(scale<1.2)scale=1.2;$(container).append('
');setTimeout(function(){$('#magnify').css('transform','scale('+scale+')')},50);if(e)magnifyMove(e);}} function magnifyMove(e,source=0){if(((source==1)&&(!hover))||((source==2)&&(hover)))return;var magnify=$('#magnify');if($(magnify).length){var thisX=e.pageX;var thisY=e.pageY;if(isNaN(thisX)||isNaN(thisY)){thisX=e.touches[0].pageX;thisY=e.touches[0].pageY} var x=((thisX-$(magnify).parent().offset().left)/$(magnify).parent().width())*100;if(x<0)x=0;else if(x>100)x=100;var y=((thisY-$(magnify).parent().offset().top)/$(magnify).parent().height())*100;if(y<0)y=0;else if(y>100)y=100;$(magnify).css({'transform-origin':x+'% '+y+'%'})}} function magnifyOff(container){$('#zoomimage > span').removeClass('bp-icon-zoom-out').addClass('bp-icon-zoom-in');$('#magnify').fadeOut(200,function(){$(this).remove()})} function optionChange(pid,oid){var selected=0;if($('.selectfield_'+pid+'_'+pid+'.sequence').length>1){selectFields(pid,pid,oid,1,0);selected=1} optionPost(selected)} function bundleChange(num,rid){selectFields(num,rid,0,0,2);optionPost(1)} function optionPost(selected){$.post(window.location.href,$('form[name=details]').serialize()+'&optajax=1',function(response){response=$.parseJSON(response);var cnum='';var cdiv=$('#image').find('.carousel_items').first();if($(cdiv).length)cnum=$(cdiv).attr('class').match(/carousel_\d+/);$('#image').replaceWith(response.product_image);if(cnum)$('#image').find('.carousel_items').first().addClass(cnum);$('#alternate').replaceWith(response.product_alternate);if($('#image').hasClass('lightbox'))lightbox($('#image'));else $('.lightbox',$('#image')).each(function(){lightbox(this)});if($(cdiv).length)setTimeout(function(){carousel($('#image'))},200);var changed=0;var price=$('#price_selling').html();if((price)&&(price.replace(/[^0-9\.,]/g,'')!=response.product_selling.replace(/[^0-9\.,]/g,'')))changed=1;$('#price_selling').replaceWith(response.product_selling);$('#price_list').replaceWith(response.product_list);$('#price_list_label').replaceWith(response.product_list_label);$('#price_saving').replaceWith(response.product_saving);$('#price_saving_label').replaceWith(response.product_saving_label);$('#inex').replaceWith(response.product_vat);$('#incexc').replaceWith(response.product_incexc_value);$('#incexc_list').replaceWith(response.product_incexc_list_value);$('#points').replaceWith(response.product_points_number);$('#points_value').replaceWith(response.product_points_value);if(!selected)$('#options').replaceWith(response.product_options);$('#availability').replaceWith(response.product_availability);$('#notify').replaceWith(response.product_notify);var quantity=$('#pquantity').val();$('#action').replaceWith(response.product_action);$('#quantity').replaceWith(response.product_quantity);$('#add').replaceWith(response.product_add);$('#pquantity').val(quantity);$('#wishlist').replaceWith(response.product_wishlist_icon);if(changed==1)$('#paypal_message').replaceWith(response.product_paypal);$('#discount').replaceWith(response.product_discount);$('#sku').replaceWith(response.product_sku);$('#bar_code').replaceWith(response.product_barcode);$('#part_number').replaceWith(response.product_partnumber);$('#weight').replaceWith(response.product_weight);$('#variant_str').val(response.variant_str);$('#pprice').val(response.pprice);$('#plprice').val(response.plprice);$('#vatrate').val(response.vatrate);$('#vatcalc').val(response.vatcalc);$('#pointvalue').val(response.pointvalue);$('#pointbonus').val(response.pointbonus);$('#pointcalc').val(response.pointcalc);additionPrices()})} function additionPrices(){var pprice=parseFloat($('#pprice').val());if(isNaN(pprice))return;var plprice=0;var aprice=0;var alprice=0;var aprices=[];$('input[id^="aprices_"]').each(function(){var key=$(this).attr('id');aprices[key]=parseFloat($(this).val())});var alprices=[];$('input[id^="alprices_"]').each(function(){var key=$(this).attr('id');alprices[key]=parseFloat($(this).val())});$('select[name^="additionv["], input[name^="additionv["]').each(function(){var akey1=this.name.replace(/[^\d\.]/g,'');var akey2=this.value;var ischecked=!0;if(this.type=='radio')ischecked=$(this).is(':checked');if(akey1&&akey2&&ischecked){try{if(aprices['aprices_'+akey1+'_'+akey2])aprice+=aprices['aprices_'+akey1+'_'+akey2]}catch(err){}}});$('textarea[name^="additions["], input[name^="additions["]').each(function(){var akey=this.name.replace(/[^\d\.]/g,'');var ischecked=!0;if(this.type=='checkbox')ischecked=$(this).is(':checked');if(akey&&this.value&&ischecked){try{if(aprices['aprices_'+akey])aprice+=aprices['aprices_'+akey]}catch(err){}}});$('#price_selling').html(function(index,html){return html.replace(/(\d+,?)?\d+\.\d{2}/,(pprice+aprice).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,","))});if($('#plprice').length){plprice=parseFloat($('#plprice').val());$('select[name^="additionv["], input[name^="additionv["]').each(function(){var akey1=this.name.replace(/[^\d\.]/g,'');var akey2=this.value;var ischecked=!0;if(this.type=='radio')ischecked=$(this).is(':checked');if(akey1&&akey2&&ischecked){try{if(alprices['alprices_'+akey1+'_'+akey2])alprice+=alprices['alprices_'+akey1+'_'+akey2]}catch(err){}}});$('textarea[name^="additions["], input[name^="additions["]').each(function(){var akey=this.name.replace(/[^\d\.]/g,'');var ischecked=!0;if(this.type=='checkbox')ischecked=$(this).is(':checked');if(akey&&this.value&&ischecked){try{if(alprices['alprices_'+akey])alprice+=alprices['alprices_'+akey]}catch(err){}}});$('#price_list').html(function(index,html){return html.replace(/(\d+,?)?\d+\.\d{2}/,(plprice+alprice).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,","))});$('#price_saving').html(function(index,html){return html.replace(/(\d+,?)?\d+\.\d{2}/,((plprice+alprice)-(pprice+aprice)).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,","))});$('#price_saving').html(function(index,html){return html.replace(/(\d+,?)?\d+%/,Math.round(parseFloat((1-((pprice+aprice)/(plprice+alprice))).toFixed(3))*100).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")+'%')})} if($('#vatrate').length&&$('#vatcalc').length){var vatrate=parseFloat($('#vatrate').val());if((document.getElementById('inex'))&&($('#inex').html().match(/\d+/)==null))vatrate=0;var vatcalc=parseInt($('#vatcalc').val());$('#incexc').html(function(index,html){var incexc=0;if(vatcalc==1)incexc=(pprice+aprice)/((vatrate/100)+1);else incexc=(pprice+aprice)*((vatrate/100)+1);return html.replace(/(\d+,?)?\d+\.\d{2}/,incexc.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,","))})} if($('#pointvalue').length&&$('#pointbonus').length){var pointvalue=parseFloat($('#pointvalue').val());var pointbonus=parseFloat($('#pointbonus').val());var pointcalc=parseInt($('#pointcalc').val());var withbonus=0;$('#points').html(function(index,html){if(pointcalc==1)withbonus=Math.round(Math.floor(pprice+aprice)*pointbonus);else withbonus=Math.round(Math.floor(pprice+aprice)+pointbonus);return html.replace(/(\d+,?)?\d+/,withbonus.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","))});$('#points_value').html(function(index,html){if(pointcalc==1)withbonus=Math.floor(pprice+aprice)*pointbonus;else withbonus=Math.floor(pprice+aprice)+pointbonus;return html.replace(/(\d+,?)?\d+\.\d{2}/,(withbonus*pointvalue).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,","))})}} function selectFields(item,product,oid,sequence,strict){$.post('/includes/selectfields.php',$('.selectfield_'+item+'_'+product).serialize()+'&item='+item+'&product='+product+'&oid='+oid+'&sequence='+sequence+'&strict='+strict+'&version=2',function(response){if(sequence){response=$.parseJSON(response);$.each(response.options,function(k,v){$('#N'+k+'_').html(v)});$.each(response.optionicons,function(k,v){$('div.option.opt_'+k+' > div.option_icons').html(v)})}else{if(response=='0'){alertDialog('This item is unavailable for purchase');$('.selectfield_'+item+'_'+product).each(function(){$(this).val($('input[name='+$(this).attr('name')+'_old]').val())})}else{if(strict==2){$('.selectfield_'+item+'_'+product).each(function(){$('input[name='+$(this).attr('name')+'_old]').val($(this).val())});if(response!='1'){if(response)$('#selectprice_'+item+'_'+product).html('+ '+response+'');else $('#selectprice_'+item+'_'+product).html('')}}else if(strict==1){submitFields(item,product)}else{wishlist.submit()}}}})} function submitFields(item,product){var url='bid='+item+'&pid='+product+'&'+$('.selectfield_'+item+'_'+product).serialize();doAction('/index/action/basket/','mod','?'+url+'&silent=1')} function submitAdditions(item,addition){var url='bid='+item+'&aid='+addition+'&'+$('input[name^=addition], textarea[name^=addition], select[name^=addition]').serialize();doAction('/index/action/basket/','mod','?'+url+'&silent=1')} function selectAlt(alt){$(alt).parent().parent().children().removeClass('selected');$(alt).parent().addClass('selected')} function selectIcon(icon,name,value,label){$('#'+name).val(value).change();if(label)$('#'+label).html($(icon).attr('rel'));$(icon).parent().children().removeClass('selected');$(icon).addClass('selected')} function getDelivery(){var url='delivery='+$('#delivery').val()+'&country='+$('#country').val()+'&county='+$('#county').val()+'&postcode='+$('#postcode').val();if($('#postcode_pa').length)url+='&postcode_pa='+$('#postcode_pa').val();if($('#alternate_address').length){url+='&alt_country='+$('#alt_country').val()+'&alt_county='+$('#alt_county').val()+'&alt_postcode='+$('#alt_postcode').val();if($('#alt_postcode_pa').length)url+='&alt_postcode_pa='+$('#alt_postcode_pa').val();if(($('#alternate_address').is(':checked'))||($('#alternate_address').attr('type')=='hidden'))url+='&alternate=1';else url+='&alternate=0'} if($('#shipping_date').length)url+='&shipping_date='+$('#shipping_date').val();return url} function selectDelivery(){if($('#delivery').length){var url=getDelivery();doAction('/checkout','mod','?'+url+'&silent=1')}} function selectAddress(url){doAction('/checkout','mod','?'+url+'&silent=1')} function selectDuties(url){if($('#delivery').length)url+='&'+getDelivery();doAction('/checkout','mod','?'+url+'&silent=1')} function selectTab(tab){var tabs=$(tab).closest('.tabs');var dir=$(tabs).css('flex-direction');var number=Math.ceil(($(tab).index()+1)/2);if(!$(tabs).children('.tab_heading').eq(number-1).hasClass('active')){$(tabs).children('.tab_heading, .tab_content').removeClass('active');$(tabs).children('.tab_heading').eq(number-1).addClass('active');$(tabs).children('.tab_content').eq(number-1).addClass('active')}else if((dir=='column')&&(!$(tabs).children('.tab_heading').eq(number-1).hasClass('initial'))){$(tabs).children('.tab_heading, .tab_content').removeClass('active')} $(tabs).children('.tab_heading, .tab_content').removeClass('initial');setTimeout(function(){if(document.documentElement.scrollTop>$(tab).offset().top)goTo(tab,40);},50)} function showTab(container,number){var tabs=$(container);if($(tabs).length){var tab=$(tabs).children('.tab_heading').eq(number-1);if($(tab).length)selectTab(tab);}} function animate(object,name){object.classList.remove(name);void object.offsetWidth;object.classList.add(name)} function goTo(id,padding=0){var y=0;if(id)y=$(id).offset().top;if(isNaN(y))y=0;y-=padding;if(parseInt($('#nav').css('z-index'))<=150)y-=parseInt(getComputedStyle(document.body).getPropertyValue('--navigation-sticky'));if(y<0)y=0;window.scroll({top:y,behavior:'smooth'})} function mobile(){if(navigator.userAgent.match(/mobile/i)&&!navigator.userAgent.match(/ipad/i))return!0;else return!1} function tablet(){if((navigator.userAgent.match(/ipad/i))||((navigator.userAgent.match(/touch/i)||navigator.userAgent.match(/android/i))&&(!mobile()))){return!0}else if(navigator.userAgent.match(/safari/i)&&!navigator.userAgent.match(/chrome/i)){if('ontouchstart' in window)return!0;else return!1}else{return!1}} $(document).ready(function(){passiveListeners();$('input[name=for]').each(function(){autocomplete(this,200,2)});$('#hamburger, #closeburger span').on('click',function(){hamburger()});hamburgerNav();darkerNav();stickyNav();setTimeout(function(){carousel()},200);var ch=$('.categories.headings').first()[0];columnsUpdate(ch);var ww=$(window).width();var hh=$(window).height();$(window).resize(function(){if((ww!=$(window).width())||(hh!=$(window).height())){ww=$(window).width();hh=$(window).height();$('.carousel_items').each(function(){carouselReset(this);var element=this;if(!hover&&$(element).closest('#image_dialog').length)setTimeout(function(){var html=$(element).html();$(element).removeClass('loaded').html('').html(html);setTimeout(function(){carouselReset(element);carouselLoad(element)},50)},50)});columnsUpdate(ch)}});if($('#product_refine').length)$('.refine_results').on('click',function(){refineResults()});else $('.refine_results').remove();refiningResults();$('.lightbox, a[rel^=lightbox]').each(function(){lightbox(this)});if($('body').hasClass('type_product')){var pid=$('#pid').val();if($('.selectfield_'+pid+'_'+pid+'.sequence').length>1)selectFields(pid,pid,0,1,0);additionPrices()} $('.tab_heading').each(function(){$(this).on('click',function(){selectTab(this)})})})