(function($){
"use strict";
jQuery(document).mouseup(function (e){
var container=jQuery('.header-search .product-categories');
if(!container.is(e.target)&&container.has(e.target).length===0&&!jQuery('.cate-toggler').is(e.target)){ 
if(jQuery('.header-search .product-categories').hasClass('open')){
jQuery('.header-search .product-categories').removeClass('open');
}}
container=jQuery('.categories-menu');
if(!container.is(e.target)&&container.has(e.target).length===0){
jQuery('#mega_main_menu').css('display', 'none');
jQuery('.morelesscate').css('display', 'none');
}
container=jQuery('.atc-notice-wrapper');
if(!container.is(e.target)&&container.has(e.target).length===0){
jQuery('.atc-notice-wrapper').fadeOut();
}
container=jQuery('#searchform');
if(!container.is(e.target)&&container.has(e.target).length===0){
jQuery("#ws").removeClass("show");
}});
var ajaxurl='https://www.macansys.co.uk/wp-admin/admin-ajax.php';
var james_brandscrollnumber=2 , james_brandpause=3000  , james_brandanimate=2000;
var james_brandscroll='false';james_brandscroll = !1;
var james_blogpause=3000 , james_bloganimate=2000;
var james_blogscroll='false'; james_blogscroll = !1;
var james_testiscroll='false';james_testiscroll = !1;
var james_testipause=3000, james_testianimate=2000;
var james_menu_number=9;
var james_sticky_header='false'; james_sticky_header = !0;
jQuery(document).ready(function(){
/*	$.get("https://i.imgur.com/aNwlgbI.gif", function(data){
$('head').append("<style>.stm-header__row_color_center:before,.stm_mobile__header{background-image: url('https://i.imgur.com/aNwlgbI.gif')}</style>");
$('.stm_mobile__logo img').attr('src', "https://www.macansys.co.uk/wp-content/uploads/2020/01/logo_inverse.png");
var images=[  "object223",
"object257" ];
var current=0;
var count=0;
var reset_count=0;
var timeout_white=4000;
let timeoutID_white=0;
let timeoutID_black=0;
white_logo();
black_logo();
function white_logo(){
clearInterval(timeoutID_black);
clearInterval(timeoutID_white);
if(current==0){
if(count>4){
timeout_white=5500; reset_count++;
$('.stm-header__row_color_center').removeClass('without-before-element');
if(reset_count>4){
reset_count=0;count=0;
timeout_white=4000;
}}
$('.stm-header__element.object223').hide();
$('.stm-header__element.object257').show();
if(document.documentElement.clientWidth >=500){
$('.stm_mobile__logo img').attr('src', "https://www.macansys.co.uk/wp-content/uploads/2020/01/logo_inverse.png");
}
current=(current < images.length - 1)? current + 1: 0;
}
timeoutID_white=setTimeout(black_logo, timeout_white);
}
function black_logo(){
clearInterval(timeoutID_white);
clearInterval(timeoutID_black);
if(current==1){
if(count>4){
$('.stm-header__row_color_center').addClass('without-before-element');
}
$('.stm-header__element.object257').hide();
$('.stm-header__element.object223').show();
if(document.documentElement.clientWidth >=500){
$('.stm_mobile__logo img').attr('src', "https://www.macansys.co.uk/wp-content/uploads/2020/01/logo_ebf5bc4d1f4efbb8c37690fa3a071d13.png");
}
current=(current < images.length - 1)? current + 1: 0;
}
count++;
timeoutID_black=setTimeout(white_logo,1300);
}})
.fail (function (){
});*/
jQuery('.macansys-content div.content-inner').replaceWith ('<div class="content-inner logo"> <img style="vertical-align: middle;margin-top: 38px;" width="280" alt="Macansys eBay Logo" src="https://www.macansys.co.uk/eBay_files/ebay_logo.png"> <img style="float: right;margin-right: 78px;" width="280" alt="Macansys eBay Logo" src="https://www.macansys.co.uk/eBay_files/logo_ebf5bc4d1f4efbb8c37690fa3a071d13.png"> </div>');
jQuery('#tab-description .macansys .macansys-content .logo img').css({'margin-top': '40px'});
var max_quantity=jQuery('.quantity input').attr('max');
if(max_quantity>1){
jQuery(".cart .quantity").addClass("show");
}
jQuery("#wsearchsubmit").on('click',function(){
if(jQuery("#ws").width()==0){
if(jQuery("#ws").hasClass("show")){
jQuery("#ws").removeClass("show");
}else{
jQuery("#ws").addClass("show");
return false;
}}
});
var cateToggler=jQuery('.cate-toggler');
jQuery('.header-search .product-categories').prepend('<li><a href="'+jQuery('#searchform').attr('action')+'">'+cateToggler.html()+'</a></li>');
cateToggler.on('click', function(){
jQuery('.header-search .product-categories').toggleClass('open');
});
var searchCat='';
var currentCat=RoadgetParameterByName('product_cat', jQuery('.header-search .product-categories .current-cat a').attr('href')); 
var currentCatName=jQuery('.current-cat a').html();
if(currentCatName!=''){
cateToggler.html(currentCatName);
jQuery('#wsearchsubmit').on('click', function(){
if(searchCat==''){
jQuery('#searchform').attr('action', jQuery('.header-search .product-categories .current-cat a').attr('href'));
}});
}
if(currentCat!=''){
if(!(jQuery('#product_cat').length > 0)){
jQuery('#searchform').append('<input type="hidden" id="product_cat" name="product_cat" value="'+currentCat+'" />');
}
jQuery('#product_cat').val(currentCat);
}
jQuery('.header-search .product-categories a').each(function(){
jQuery(this).on('click', function(event){
event.preventDefault();
jQuery('.header-search .product-categories a.active').removeClass('active');
jQuery(this).addClass('active');
jQuery('.header-search .product-categories').removeClass('open');
jQuery('#searchform').attr('action', jQuery(this).attr('href'));
cateToggler.html(jQuery(this).html());
searchCat=jQuery(this).attr('href');
if(!(jQuery('#product_cat').length > 0)&&(RoadgetParameterByName('product_cat', jQuery(this).attr('href'))!='') ){
jQuery('#searchform').append('<input type="hidden" id="product_cat" name="product_cat" value="" />');
}
jQuery('#product_cat').val(RoadgetParameterByName('product_cat', jQuery(this).attr('href')) );
});
});
var mobileMenuWrapper=jQuery('.mobile-menu-container');
mobileMenuWrapper.find('.menu-item-has-children').each(function(){
var linkItem=jQuery(this).find('a').first();
linkItem.after('<i class="fa fa-angle-right"></i>');
});
var totalMenuLevelFirst=jQuery('.mobile-menu-container .nav-menu > li').length;
var mobileMenuH=totalMenuLevelFirst*40 + 10;
jQuery('.mbmenu-toggler').on('click', function(){
if(mobileMenuWrapper.hasClass('open')){
mobileMenuWrapper.removeClass('open');
mobileMenuWrapper.animate({'height': 0}, 'fast');
}else{
mobileMenuWrapper.addClass('open');
mobileMenuWrapper.animate({'height': mobileMenuH}, 'fast');
}});
jQuery('.mobile-menu-container li.menu-item-has-children').each(function(){
jQuery(this).css({'height': 40, 'overflow': 'hidden'});
});
jQuery('.mobile-menu-container li.menu-item-has-children').each(function(){
var parentLi=jQuery(this);
var dropdownUl=parentLi.find('ul.sub-menu').first();
parentLi.find('.fa').first().on('click', function(){
parentLi.parents('li.menu-item-has-children').css('height', 'auto');
mobileMenuWrapper.css({'height': 'auto'});
var dropdownUlheight=dropdownUl.outerHeight() + 40;
if(parentLi.hasClass('opensubmenu')){
parentLi.removeClass('opensubmenu');
parentLi.animate({'height': 40}, 'fast', function(){
mobileMenuH=mobileMenuWrapper.outerHeight();
});
parentLi.find('.fa').first().removeClass('fa-angle-down');
parentLi.find('.fa').first().addClass(' fa-angle-right');
}else{
parentLi.addClass('opensubmenu');
parentLi.animate({'height': dropdownUlheight}, 'fast', function(){
mobileMenuH=mobileMenuWrapper.outerHeight();
});
parentLi.find('.fa').first().addClass('fa-angle-down');
parentLi.find('.fa').first().removeClass(' fa-angle-right');
}});
});
if(jQuery(window).width() > 1024){
jQuery('.widget_shopping_cart').on('mouseover', function(){
var mCartHeight=jQuery('.mini_cart_inner').outerHeight();
var cCartHeight=jQuery('.mini_cart_content').outerHeight();
if(cCartHeight < mCartHeight){
jQuery('.mini_cart_content').stop(true, false).animate({'height': mCartHeight});
}});
jQuery('.widget_shopping_cart').on('mouseleave', function(){
jQuery('.mini_cart_content').animate({'height':'0'});
});
}
jQuery('.widget_shopping_cart').on('click', function(event){
if(jQuery(window).width() < 1025){
var closed=false;
var mCartHeight=jQuery('.mini_cart_inner').outerHeight();
var mCartToggler=jQuery('.cart-toggler');
if(jQuery('.mini_cart_content').height()==0){
closed=true;
}
if(mCartToggler.is(event.target)||mCartToggler.has(event.target).length!=0||mCartToggler.is(event.target)){
event.preventDefault();
if(closed){
jQuery('.mini_cart_content').animate({'height': mCartHeight});
closed=false;
}else{
jQuery('.mini_cart_content').animate({'height':'0'}, function(){
closed=true;
});
}}
}});
jQuery('body').append('<div class="atc-notice-wrapper"><div class="atc-notice"></div><div class="close"><i class="fa fa-times-circle"></i></div></div>');
jQuery('.atc-notice-wrapper .close').on('click', function(){
jQuery('.atc-notice-wrapper').fadeOut();
jQuery('.atc-notice').html('');
});
var ajaxPId=0;
jQuery('body').on('adding_to_cart', function(event, button, data){
ajaxPId=button.attr('data-product_id');
});
/*jQuery('body').on('added_to_cart', function(event, fragments, cart_hash){
jQuery.post(ajaxurl,
{
'action': 'get_productinfo',
'data':   {'pid': ajaxPId}},
function(response){
}
);
});*/
jQuery('body').on('added_to_cart removed_from_cart', function(event, fragments, cart_hash){
refreshMyCartFragments();
var cart_qty_count;
$.each(fragments, function (name, value){
if(name==".cart__quantity-badge"){
cart_qty_count=String(value).replace(/[^0-9]/g,'');
}});
jQuery('.cart-contents-count').text(cart_qty_count);
});
jQuery('body').on('xoo_wsc_cart_updated xoo_wsc_before_loading_fragments', function(event, fragments, cart_hash){
var cart_qty_count;
$.each(fragments , function(key, value){
$(key).replaceWith(value);
});
$.each(fragments, function (name, value){
if(name=="fragments"){
fragments=value;
$.each(fragments, function (name, value){
if(name==".cart__quantity-badge"){
cart_qty_count=String(value).replace(/[^0-9]/g,'');
}});
}});
jQuery('.cart-contents-count').text(cart_qty_count);
});
jQuery('.single-images').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
dots: false,
fade: true,
asNavFor: '.single-thumbnails'
});
jQuery('.single-thumbnails').slick({
asNavFor: '.single-images',
slidesToShow: 4,
slidesToScroll: 1,
dots: true,
arrows: false,
centerMode: true,
focusOnSelect: true
});
/*		jQuery('a.yith_magnifier_thumbnail').live('click', function(){
jQuery('a.yith_magnifier_thumbnail').removeClass('active');
jQuery(this).addClass('active');
});*/
jQuery('a.yith_magnifier_thumbnail').on('click', function(){
jQuery('a.yith_magnifier_thumbnail').removeClass('active');
jQuery(this).addClass('active');
});
jQuery('.toolbar .orderby').chosen({disable_search: true, width: "auto"});
jQuery('.wcml_currency_switcher').chosen({disable_search: true, width: "auto"});
jQuery('.horizontal-menu .nav-menu > ul').superfish({
delay: 100,
speed: 'fast'
});
jQuery('.primary-menu-container ul.nav-menu').superfish({
delay: 100,
speed: 'fast'
});
jQuery('.brands-carousel').each(function(){
var james_brandcols=jQuery(this).attr('data-col');
jQuery(this).slick({
infinite: true,
slidesToShow: james_brandcols,
slidesToScroll: james_brandscrollnumber,
speed: james_brandanimate,
easing: 'linear',
dots: false,
arrows: true,
autoplay: james_brandscroll,
autoplaySpeed: james_brandpause,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 5,
slidesToScroll: 1
}},
{
breakpoint: 768,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}}
]
});
});
window.setTimeout(function(){
var tabCount=1;
var tabTotal=jQuery('.home-tabs.layout1 .wpb_content_element').length;
jQuery('.home-tabs.layout1').prepend('<div class="container"><ul class="home-tabs-title"></ul></div>');
var tabTitle=jQuery('.home-tabs.layout1 .home-tabs-title');
jQuery('.home-tabs.layout1 .wpb_content_element').each(function(){
var tabClass='';
var tabLinkClass='';
var tabWidget=jQuery(this).next('.woocommerce');
tabWidget.addClass('product-tabs');
var widgetTitle=jQuery(this).find('h3').html();
tabWidget.attr('id', 'wpb_content_element-'+tabCount);
if(tabCount==1){
tabClass='first';
tabLinkClass='active';
tabWidget.addClass('active');
roadtabCarousel('#wpb_content_element-'+tabCount+' .shop-products', 5, 3, 3, 2, 1);
}else{
tabWidget.addClass('heightzero');
}
if(tabCount==tabTotal){
tabClass='last';
}
tabTitle.append('<li class="'+tabClass+'"><a class="tab-link '+tabLinkClass+'" href="#" rel="wpb_content_element-'+tabCount+'">'+widgetTitle+'</a></li>');
tabCount++;
jQuery('.home-tabs.layout1 .tab-link').each(function(){
jQuery(this).on('click', function(event){
event.preventDefault();
var tabRel=jQuery(this).attr('rel');
jQuery('.home-tabs.layout1 .tab-link').removeClass('active');
jQuery(this).addClass('active');
jQuery('.home-tabs.layout1 .product-tabs.active').fadeOut(300, function(){
jQuery('.home-tabs.layout1 .product-tabs').addClass('heightzero');
jQuery('#'+tabRel).removeClass('heightzero');
jQuery(this).fadeIn(300);
});
jQuery('.home-tabs.layout1 .product-tabs').removeClass('active');
jQuery('#'+tabRel).addClass('active');
roadtabCarousel('#'+tabRel+' .shop-products', 5, 3, 3, 2, 1);
});
});
});
}, 1000);
jQuery('.products-carousel .shop-products').slick({
infinite: false,
arrows: false,
dots: false,
slidesToShow: 5,
slidesToScroll: 1,
speed: 1000,
easing: 'linear',
autoplaySpeed: 1000,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}},
{
breakpoint: 960,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}},
{
breakpoint: 760,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 600,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}}
]
});
jQuery('.products-carousel2 .shop-products').slick({
infinite: false,
slidesToShow: 4,
slidesToScroll: 1,
speed: 1000,
easing: 'linear',
autoplaySpeed: 1000,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}},
{
breakpoint: 992,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 767,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 479,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}}
]
});
jQuery('.posts-carousel').each(function(){
var james_postcols=jQuery(this).attr('data-col');
jQuery(this).slick({
infinite: true,
arrows: false,
dots: true,
slidesToShow: james_postcols,
slidesToScroll: 1,
speed: james_bloganimate,
easing: 'linear',
autoplay: james_blogscroll,
autoplaySpeed: james_blogpause,
swipeToSlide: true,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 960,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}}
]
});
});
jQuery('.testimonials-list').slick({
arrows: false,
dots: true,
infinite: true,
slidesToShow: 1,
slidesToScroll: 1,
speed: james_testianimate,
easing: 'linear',
autoplay: james_testiscroll,
swipeToSlide: true,
autoplaySpeed: james_testipause
});
jQuery('.cross-carousel .shop-products').slick({
arrows: false,
dots: true,
infinite: false,
slidesToShow: 2,
slidesToScroll: 1,
speed: 1000,
easing: 'linear',
autoplaySpeed: 3000,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 960,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}},
{
breakpoint: 760,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}}
]
});
jQuery('.zoom_in_marker').on('click', function(){
jQuery.fancybox({
href: jQuery('.woocommerce-main-image').attr('href'),
openEffect: 'elastic',
closeEffect: 'elastic'
});
});
jQuery('.upsells .shop-products').slick({
infinite: false,
slidesToShow: 4,
slidesToScroll: 1,
speed: 1000,
easing: 'linear',
autoplaySpeed: 3000,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}},
{
breakpoint: 960,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}},
{
breakpoint: 760,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}}
]
});
jQuery('.related .shop-products').slick({
infinite: false,
slidesToShow: 4,
slidesToScroll: 1,
speed: 1000,
easing: 'linear',
swipeToSlide: true,
autoplaySpeed: 3000,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}},
{
breakpoint: 960,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}},
{
breakpoint: 760,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}}
]
});
jQuery('.view-mode').each(function(){
jQuery(this).find('.grid').on('click', function(event){
event.preventDefault();
jQuery('.view-mode').find('.grid').addClass('active');
jQuery('.view-mode').find('.list').removeClass('active');
jQuery('#archive-product .shop-products').removeClass('list-view');
jQuery('#archive-product .shop-products').addClass('grid-view');
jQuery('#archive-product .list-col4').removeClass('col-xs-12 col-sm-4');
jQuery('#archive-product .list-col8').removeClass('col-xs-12 col-sm-8');
});
jQuery(this).find('.list').on('click', function(event){
event.preventDefault();
jQuery('.view-mode').find('.list').addClass('active');
jQuery('.view-mode').find('.grid').removeClass('active');
jQuery('#archive-product .shop-products').addClass('list-view');
jQuery('#archive-product .shop-products').removeClass('grid-view');
jQuery('#archive-product .list-col4').addClass('col-xs-12 col-sm-4');
jQuery('#archive-product .list-col8').addClass('col-xs-12 col-sm-8');
});
});
jQuery('.yith-wcwl-add-to-wishlist a').each(function(){
roadtip(jQuery(this), 'html');
});
var compareText=jQuery('.single-product-info .compare').html();
jQuery('.single-product-info .compare').html('<span class="comparetip">'+compareText+'</span>');
jQuery('.comparetip').each(function(){
roadtip(jQuery(this), 'html');
});
jQuery('.compare-button a').each(function(){
roadtip(jQuery(this), 'html');
});
jQuery('.add_to_cart_inline a').each(function(){
roadtip(jQuery(this), 'html');
});
jQuery('.quickviewbtn .quickview').each(function(){
roadtip(jQuery(this), 'html');
});
jQuery('.sharefriend a').each(function(){
roadtip(jQuery(this), 'html');
});
jQuery('.social-icons a').each(function(){
roadtip(jQuery(this), 'title');
});
jQuery('.product-wrapper').each(function(){
jQuery(this).on('mouseover click', function(){
jQuery(this).addClass('hover');
});
jQuery(this).on('mouseleave', function(){
jQuery(this).removeClass('hover');
});
});
jQuery('body').append('<div class="quickview-wrapper"><span class="qvbtn qvprev"><i class="fa fa-caret-left"></i></span><span class="qvbtn qvnext"><i class="fa fa-caret-right"></i></span><div class="quick-modal"><span class="qvloading"></span><span class="closeqv"><i class="fa fa-times"></i></span><div id="quickview-content"></div><div class="clearfix"></div></div></div>');
var arrIdx=0;
var quickviewArr=Array();
var nextArrID=0;
var prevArrID=0;
jQuery('.quickview').each(function(){
var quickviewLink=jQuery(this);
var productID=quickviewLink.attr('data-quick-id');
if(quickviewArr.indexOf(productID)==-1){
quickviewArr[arrIdx]=productID;
arrIdx++;
}
quickviewLink.on('click', function(event){
event.preventDefault();
prevArrID=quickviewArr[quickviewArr.indexOf(productID) - 1];
nextArrID=quickviewArr[quickviewArr.indexOf(productID) + 1];
jQuery('.qvprev').attr('data-quick-id', prevArrID);
jQuery('.qvnext').attr('data-quick-id', nextArrID);
showQuickView(productID, quickviewArr);
});
});
jQuery('.qvprev').on('click', function(){
showQuickView(jQuery(this).attr('data-quick-id'), quickviewArr);
});
jQuery('.qvnext').on('click', function(){
showQuickView(jQuery(this).attr('data-quick-id'), quickviewArr);
});
jQuery('.closeqv').on('click', function(){
hideQuickView();
});
jQuery(".fancybox").fancybox({
openEffect: 'elastic',
closeEffect: 'fade',
beforeShow: function (){
if(this.title){
this.title +='<div class="fancybox-social">';
this.title +='<a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="' + this.href + '">Tweet</a> ';
this.title +='<iframe src="//www.facebook.com/plugins/like.php?href=' + this.href + '&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:23px;" allowTransparency="true"></iframe></div>';
}},
afterShow: function(){
twttr.widgets.load();
},
helpers:  {
title:{
type:'inside'
},
overlay:{
showEarly:false
}}
});
jQuery(".prfancybox").fancybox({
openEffect: 'fade',
closeEffect: 'elastic',
nextEffect: 'fade',
prevEffect: 'fade',
helpers:  {
title:{
type:'inside'
},
overlay:{
showEarly:false
},
buttons:{},
thumbs:{
width:100,
height:100
}}
});
jQuery('#back-top').on('click', function(){
jQuery("html, body").animate({ scrollTop: 0 }, "slow");
});
jQuery('.collapse-menu .menu li.menu-item-has-children > a').each(function(){
jQuery(this).after('<i class="fa fa-angle-down"></i>');
});
jQuery('.collapse-menu .menu li.menu-item-has-children > .fa').each(function(){
jQuery(this).on('click', function(){
var element=jQuery(this).parent('li');
if(element.hasClass('open')){
element.removeClass('open');
element.find('li').removeClass('open');
element.find('ul').slideUp();
}else{
element.addClass('open');
element.children('ul').slideDown();
element.siblings('li').children('ul').slideUp();
element.siblings('li').removeClass('open');
element.siblings('li').find('li').removeClass('open');
element.siblings('li').find('ul').slideUp();
}});
});
if(james_sticky_header){
var headerSpaceH=jQuery('.header-sticky').height();
jQuery('.header-sticky').after('<div class="headerSpace" style="height: '+headerSpaceH+'px;"></div>');
}});
var currentP=0;
if(james_sticky_header){
var stickyOffset=0;
stickyOffset +=20;
}
jQuery(window).scroll(function(){
var headerH=jQuery('.header-container').height();
var scrollP=jQuery(window).scrollTop();
if(jQuery(window).width() > 1024){
if(scrollP!=currentP){
if(scrollP >=headerH){
jQuery('#back-top').addClass('show');
}else{
jQuery('#back-top').removeClass('show');
}
if(james_sticky_header){
if(scrollP >=stickyOffset){
jQuery('#back-top').addClass('show');
jQuery('.header-sticky').addClass('ontop');
jQuery('.headerSpace').addClass('show');
}else{
jQuery('#back-top').removeClass('show');
jQuery('.header-sticky').removeClass('ontop show');
jQuery('.headerSpace').removeClass('show');
}
if(scrollP >=(stickyOffset+20)){
jQuery('.header-sticky').addClass('show');
}}
currentP=jQuery(window).scrollTop();
}}
});
var oldCateMenuH, realMMH, realCateMenuH;
jQuery(document).ready(function(){
if(jQuery('.categories-menu-container').length > 0||jQuery('.categories-menu > ul').length > 0){
jQuery('.morelesscate').css('display', 'none');
jQuery('.morelesscate').addClass('alwayshide');
}
if(jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').length < james_menu_number){
jQuery('.morelesscate').css('display', 'none');
jQuery('.morelesscate').addClass('alwayshide');
}
oldCateMenuH=james_menu_number * jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').outerHeight() + jQuery('.catemenu-toggler').outerHeight();
realMMH=jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').length * jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').outerHeight();
realCateMenuH=jQuery('.catemenu-toggler').outerHeight() + realMMH + jQuery('.morelesscate').outerHeight();
if(jQuery('.morecate').css('display')!='none'){
jQuery('.categories-menu').css('height', oldCateMenuH);
}else{
jQuery('.categories-menu').css('height', realCateMenuH);
}
jQuery('.catemenu-toggler').on('click', function(){
if(jQuery('#mega_main_menu').css('display')=='none'){
jQuery('#mega_main_menu').css('opacity', 0);
jQuery('#mega_main_menu').css('display', 'block');
jQuery('#mega_main_menu').animate({'opacity': 1}, 100, function(){
if(!jQuery('.morelesscate').hasClass('alwayshide')){
jQuery('.morelesscate').fadeIn('fast');
}
oldCateMenuH=james_menu_number * jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').outerHeight() + jQuery('.catemenu-toggler').outerHeight();
realMMH=jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').length * jQuery('#mega_main_menu ul.mega_main_menu_ul > li').outerHeight();
realCateMenuH=jQuery('.catemenu-toggler').outerHeight() + realMMH + jQuery('.morelesscate').outerHeight();
if(jQuery('.morecate').css('display')=='none'){
jQuery('.categories-menu').css({'height': realCateMenuH});
}else{
jQuery('.categories-menu').css({'height': oldCateMenuH});
}});
}else{
jQuery('#mega_main_menu').animate({'opacity': 0}, 200, function(){
jQuery('#mega_main_menu').css('display', 'none');
jQuery('.morelesscate').css('display', 'none');
oldCateMenuH=james_menu_number * jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').outerHeight() + jQuery('.catemenu-toggler').outerHeight();
realMMH=jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').length * jQuery('#mega_main_menu ul.mega_main_menu_ul > li').outerHeight();
realCateMenuH=jQuery('.catemenu-toggler').outerHeight() + realMMH + jQuery('.morelesscate').outerHeight();
if(jQuery('.morecate').css('display')=='none'){
jQuery('.categories-menu').css({'height': realCateMenuH});
}else{
jQuery('.categories-menu').css({'height': oldCateMenuH});
}});
}
if(jQuery('.categories-menu > ul').css('display')=='none'){
jQuery('.categories-menu > ul').css('display', 'block');
}else{
jQuery('.categories-menu > ul').css('display', 'none');
}
if(jQuery('.categories-menu-container').css('display')=='none'){
jQuery('.categories-menu-container').css('display', 'block');
}else{
jQuery('.categories-menu-container').css('display', 'none');
}});
var catemidx=1;
jQuery('#mega_main_menu ul.mega_main_menu_ul > li').each(function(){
if(catemidx > james_menu_number&&jQuery('.morecate').css('display')!='none'){
jQuery(this).css('display', 'none');
jQuery(this).addClass('mhide');
}
catemidx++;
});
jQuery('.morelesscate').on('click', function(){
oldCateMenuH=james_menu_number * jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').outerHeight() + jQuery('.catemenu-toggler').outerHeight();
realMMH=jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').length * jQuery('#mega_main_menu ul.mega_main_menu_ul > li').outerHeight();
realCateMenuH=jQuery('.catemenu-toggler').outerHeight() + realMMH + jQuery('.morelesscate').outerHeight();
if(jQuery('.morecate').css('display')=='none'){ 
jQuery('.categories-menu').css('overflow', 'hidden');
jQuery('.categories-menu').animate({'height': oldCateMenuH}, function(){
jQuery('.morecate').css('display', 'block');
jQuery('.lesscate').css('display', 'none');
jQuery('.categories-menu').css('overflow', 'visible');
jQuery('.mhide').css('display', 'none');
});
}else{ 
jQuery('.categories-menu').css('overflow', 'hidden');
jQuery('.mhide').css('display', 'block');
jQuery('.categories-menu').animate({'height': realCateMenuH}, function(){
jQuery('.morecate').css('display', 'none');
jQuery('.lesscate').css('display', 'block');
jQuery('.categories-menu').css('overflow', 'visible');
});
}});
});
jQuery(window).resize(function(){
window.setTimeout(function(){
oldCateMenuH=james_menu_number * jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').outerHeight() + jQuery('.catemenu-toggler').outerHeight();
realMMH=jQuery('#mega_main_menu ul.mega_main_menu_ul > li.menu-item').length * jQuery('#mega_main_menu ul.mega_main_menu_ul > li').outerHeight();
realCateMenuH=jQuery('.catemenu-toggler').outerHeight() + realMMH + jQuery('.morelesscate').outerHeight();
if(jQuery('.morecate').css('display')!='none'){
jQuery('.categories-menu').css('height', oldCateMenuH);
}else{
jQuery('.categories-menu').css('height', realCateMenuH);
}}, 300);
});
jQuery(window).on('load',function(){
if(jQuery('form.checkout')){
/*jQuery('form.checkout').removeAttr('novalidate');
jQuery('.woocommerce-billing-fields__field-wrapper .validate-required input').attr("required", true);
jQuery('.woocommerce-billing-fields__field-wrapper .validate-required input').after("<span id='error-text' style='color: red;'></span>");
jQuery('#billing_first_name').attr("autofocus", true);
jQuery('#billing_first_name , #billing_last_name').on("focusout", function (){
var inputval=jQuery(this).val();
console.log("focusout triggered" + inputval);
if(/^[0-9!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]*$/.test(inputval)==true){
if(inputval.length===0){
jQuery(this).next("span").text("your name is required.");
jQuery(this).attr("style","border: 3px solid red !important;");
}else{
jQuery(this).next("span").text("your name should contain only letters.");
jQuery(this).attr("style","border: 3px solid red !important;");
}}else{
console.log("NOt Matched");
jQuery(this).next('span').text("");
jQuery(this).removeAttr("style");
}});*/
/*jQuery('#billing_email').on("focusout", function (){
var inputval=jQuery('#billing_email').val();
console.log("focusout triggered" + inputval);
if(/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(inputval)==true){
console.log("NOt Matched");
jQuery('#billing_email').next('span').text("");
jQuery('#billing_email').removeAttr("style");
}else{
console.log("Matched");
if(inputval.length===0){
jQuery('#billing_email').next("span").text("Your email address is required.");
jQuery('#billing_email').attr("style","border: 3px solid red !important;");
}else{
jQuery('#billing_email').next("span").text("please enter a valid Email");
jQuery('#billing_email').attr("style","border: 3px solid red !important;");
}}
});*/
/*jQuery('#billing_phone').on("focusout", function (){
var inputval=jQuery('#billing_phone').val();
console.log("focusout triggered" + inputval);
if(/^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$/.test(inputval)==true){
console.log("Matched");
if(inputval.length===0){
jQuery('#billing_phone').next("span").text("Your phone number is required.");
jQuery('#billing_phone').attr("style","border: 3px solid red !important;");
}else{
jQuery('#billing_phone').next("span").text("please enter a valid phone number");
jQuery('#billing_phone').attr("style","border: 3px solid red !important;");
}}else{
console.log("NOt Matched");
jQuery('#billing_phone').next('span').text("");
jQuery('#billing_phone').removeAttr("style");
}});*/
/*jQuery('#billing_postcode').on("focusout", function (){
var inputval=jQuery('#billing_postcode').val();
console.log("focusout triggered" + inputval);
if(/^[a-z]{1,2}\d[a-z\d]?\s*\d[a-z]{2}$/.test(inputval)==true){
console.log("NOt Matched");
jQuery('#billing_postcode').next('span').text("");
jQuery('#billing_postcode').removeAttr("style");
}else{
console.log("Matched");
if(inputval.length===0){
jQuery('#billing_postcode').next("span").text("Your post code is required.");
jQuery('#billing_postcode').attr("style","border: 3px solid red !important;");
}else{
jQuery('#billing_postcode').next("span").text("please enter a valid post code");
jQuery('#billing_postcode').attr("style","border: 3px solid red !important;");
}}
});*/
/*jQuery('.woocommerce-billing-fields__field-wrapper .validate-required input').attr("onfocusout","if(typeof this.reportValidity==='function'){this.reportValidity();}");
jQuery('#billing_first_name').attr("autofocus", true);
jQuery('#billing_first_name').attr("pattern","[a-zA-Z ',-.]{2,120}");
jQuery('#billing_first_name').attr("title","Name can only contain minimum 2 and maximum 120 English Alphabets. e.g. john Oflenzo");
jQuery('#billing_last_name').attr("pattern","[a-zA-Z ',-.]{2,120}");
jQuery('#billing_last_name').attr("title","Name can only contain minimum 2 and maximum 120 English Alphabets. e.g. john Oflenzo");
jQuery('#billing_company').attr("pattern","[a-zA-Z ',-.]{2,120}");
jQuery('#billing_address_1').attr("pattern","[a-zA-Z #'&/\(),-.0-9]{10,150}");
jQuery('#billing_address_2').attr("pattern","[a-zA-Z #'&/\(),-.0-9]{10,150}");
jQuery('#billing_city_field').attr("pattern","[a-zA-Z ',-.]{10,60}");
jQuery('#billing_state').attr("pattern","[a-zA-Z ',-.]{3,60}");
jQuery('#billing_postcode').attr("pattern","[a-zA-Z 0-9]{5,12}");
jQuery('#billing_phone').attr("pattern","[0-9 ()-+]{5,15}");
jQuery('#billing_email').attr("pattern","[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}$");
/*$('#ship-to-different-address-checkbox').change(function(){
if(this.checked){
jQuery('.woocommerce-shipping-fields__field-wrapper .validate-required input').attr("required", true);
jQuery('.woocommerce-shipping-fields__field-wrapper .validate-required input').attr("onfocusout","if(typeof this.reportValidity==='function'){this.reportValidity();}");
jQuery('#shipping_first_name').attr("pattern","[a-zA-Z ',-.]{3,60}");
jQuery('#shipping_first_name').attr("title","Name can only contain maximum 60 Alphabets. e.g. john Oflenzo");
jQuery('#shipping_last_name').attr("pattern","[a-zA-Z ',-.]{3,60}");
jQuery('#shipping_last_name').attr("title","Name can only contain maximum 60 Alphabets. e.g. john Oflenzo");
jQuery('#shipping_company').attr("pattern","[a-zA-Z ',-.]{3,60}");
jQuery('#shipping_address_1').attr("pattern","[a-zA-Z #'&/\(),-.0-9]{3,100}");
jQuery('#shipping_address_2').attr("pattern","[a-zA-Z #'&/\(),-.0-9]{3,100}");
jQuery('#shipping_city').attr("pattern","[a-zA-Z ',-.]{3,60}");
jQuery('#shipping_state').attr("pattern","[a-zA-Z ',-.]{3,60}");
jQuery('#shipping_postcode').attr("pattern","[a-zA-Z 0-9]{5,12}");
}else{
jQuery('.woocommerce-shipping-fields__field-wrapper .validate-required input').removeAttr("required");
jQuery('.woocommerce-shipping-fields__field-wrapper .validate-required input').removeAttr("onfocusout","if(typeof this.reportValidity==='function'){this.reportValidity();}");
jQuery('.woocommerce-shipping-fields__field-wrapper input').removeAttr("pattern");
jQuery('.woocommerce-shipping-fields__field-wrapper input').removeAttr("title");
}});*/
}
jQuery('.list_projects #projects_list').shuffle({ itemSelector: '.project' });
jQuery('.filter-options .btn').on('click', function(){
var filterBtn=jQuery(this),
isActive=filterBtn.hasClass('active'),
group=isActive ? 'all':filterBtn.data('group');
if(!isActive){
jQuery('.filter-options .active').removeClass('active');
}
filterBtn.toggleClass('active');
jQuery('.list_projects #projects_list').shuffle('shuffle', group);
});
});
})(jQuery);
"use strict";
function RoadgetParameterByName(name, string){
name=name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex=new RegExp("[\\?&]" + name + "=([^&#]*)"),
results=regex.exec(string);
return results===null ? "":decodeURIComponent(results[1].replace(/\+/g, " "));
}
function roadtabCarousel(element, itemnumbers1, itemnumbers2, itemnumbers3, itemnumbers4, itemnumbers5){
jQuery(element).slick({
infinite: false,
slidesToShow: itemnumbers1,
slidesToScroll: 1,
speed: 700,
easing: 'linear',
autoplaySpeed: 3000,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: itemnumbers2,
slidesToScroll: 1
}},
{
breakpoint: 960,
settings: {
slidesToShow: itemnumbers3,
slidesToScroll: 1
}},
{
breakpoint: 760,
settings: {
slidesToShow: itemnumbers4,
slidesToScroll: 1
}},
{
breakpoint: 600,
settings: {
slidesToShow: itemnumbers5,
slidesToScroll: 1
}}
]
});
}
function roadMiniCartRemove(url, itemid){
jQuery('#mcitem-' + itemid).fadeOut();
jQuery('#lcitem-' + itemid).fadeOut();
jQuery.get(url, function(data,status){
if(status=='success'){
jQuery('#mcitem-' + itemid).remove();
jQuery('#lcitem-' + itemid).remove();
var mCartHeight=jQuery('.mini_cart_inner').outerHeight();
jQuery('.mini_cart_content').animate({'height': mCartHeight});
var $html=jQuery(data);
var cartCount=$html.find('.cart__quantity-badge').text();
var subTotal=$html.find('.cart__item-sub.cart-subtotal .amount').html();
jQuery('.cart-contents-count, .cart__quantity-badge').text(cartCount);
jQuery('.cart__item-sub.cart-subtotal .amount').html(subTotal);
jQuery(document.body).trigger('updated_checkout');
if(parseInt(cartCount)===0){
setTimeout(function(){
jQuery('.section-header').attr('style','margin-bottom:0px !important;');
jQuery('#CartPageForm').remove();
jQuery('.xoo-wsc-empty-cart').show();
}, 200);
}}else{
jQuery('#mcitem-' + itemid).fadeIn();
jQuery('#lcitem-' + itemid).fadeIn();
}});
}
function roadtip(element, content){
if(content=='html'){
var tipText=element.html();
}else{
var tipText=element.attr('title');
}
element.on('mouseover', function(){
if(jQuery('.roadtip').length==0){
element.before('<span class="roadtip" style="display: none;">'+tipText+'</span>');
var tipWidth=jQuery('.roadtip').outerWidth();
var tipPush=-(tipWidth/2 - element.outerWidth()/2);
jQuery('.roadtip').css('margin-left', tipPush);
jQuery('.roadtip').fadeIn();
}});
element.on('mouseleave', function(){
jQuery('.roadtip').fadeOut();
jQuery('.roadtip').remove();
});
}
function showQuickView(productID, quickviewArr){
prevArrID=quickviewArr[quickviewArr.indexOf(productID) - 1];
nextArrID=quickviewArr[quickviewArr.indexOf(productID) + 1];
jQuery('.qvprev').attr('data-quick-id', prevArrID);
jQuery('.qvnext').attr('data-quick-id', nextArrID);
jQuery('body').addClass('quickview');
window.setTimeout(function(){
jQuery('.quickview-wrapper').addClass('open');
jQuery('.qvloading').fadeIn();
jQuery.post(ajaxurl,
{
'action': 'product_quickview',
'data':   productID
},
function(response){
jQuery('#quickview-content').html(response);
jQuery('.qvloading').fadeOut();
jQuery('.variations_form').wc_variation_form();
jQuery('.variations_form .variations select').change();
jQuery('.quick-thumbnails')
jQuery('.quick-thumbnails').slick({
slidesToScroll: 1,
slidesToShow: 4,
arrows: false,
dots: true
});
jQuery('.quick-thumbnails a').each(function(){
var quickThumb=jQuery(this);
var quickImgSrc=quickThumb.attr('href');
quickThumb.on('click', function(event){
event.preventDefault();
jQuery('.main-image').find('img').attr('src', quickImgSrc);
});
});
jQuery('.woocommerce-review-link').on('click', function(event){
event.preventDefault();
var reviewLink=jQuery('.see-all').attr('href');
window.location.href=reviewLink + '#reviews';
});
}
);
}, 300);
}
function hideQuickView(){
jQuery('.quickview-wrapper').removeClass('open');
window.setTimeout(function(){
jQuery('body').removeClass('quickview');
}, 500);
}
function refreshMyCartFragments(){
var get_wcurl=function(endpoint){
return xoo_wsc_params.wc_ajax_url.toString().replace('%%endpoint%%',
endpoint
);
};
jQuery.ajax({
url: get_wcurl('xoo_wsc_refresh_fragments'),
type: 'POST',
context: this,
data: {},
success: function(response){
updateFragments(response);
},
complete: function(){
}});
}
function updateFragments(response){
console.log('updated');
if(response.fragments){
if(typeof wc_cart_fragments_params!=='undefined'&&('sessionStorage' in window&&window.sessionStorage!==null) ){
sessionStorage.setItem(wc_cart_fragments_params.fragment_name, JSON.stringify(response.fragments) );
localStorage.setItem(wc_cart_fragments_params.cart_hash_key, response.cart_hash);
sessionStorage.setItem(wc_cart_fragments_params.cart_hash_key, response.cart_hash);
if(response.cart_hash){
sessionStorage.setItem('wc_cart_created',(new Date()).getTime());
}}
jQuery(document.body).trigger('wc_fragments_refreshed');
}
if(xoo_wsc_params.refreshCart==="yes"&&typeof wc_cart_fragments_params!=='undefined'){
return;
}}
jQuery(function($){
$(document).on('click', 'button.js-qty__adjust--plus', function (){
var qty_value=$(this).prevAll('div').children('input').val();
var max_value=parseInt($(this).prevAll('div').children('input').attr("max"));
qty_value=Math.min(parseInt(qty_value) + 1, max_value);
console.log("qty value=" + qty_value);
if(qty_value <=max_value){
$(this).prevAll('div').children('input').val(qty_value);
$(this).prevAll('div').children('input').attr("value",qty_value);
$(this).prevAll('div').children('input.qty').trigger('change');
}});
$(document).on('click', 'button.js-qty__adjust--minus', function (){
var qty_value=$(this).prevAll('div').children('input').val();
var min_value=0;
qty_value=Math.max(parseInt(qty_value) - 1, min_value);
console.log("qty value=" + qty_value);
if(qty_value >=min_value){
$(this).prevAll('div').children('input').val(qty_value);
$(this).prevAll('div').children('input').attr("value",qty_value);
$(this).prevAll('div').children('input.qty').trigger('change');
}});
$(document).on('change', 'input.qty', function(){
block();
var get_wcurl=function(endpoint){
return xoo_wsc_params.wc_ajax_url.toString().replace('%%endpoint%%',
endpoint
);
};
var $thisbutton=$(this);
var item_hash=$(this).attr('name').replace(/cart\[([\w]+)\]\[qty\]/g, "$1");
var item_quantity=$(this).val();
var item_max_value=parseInt($(this).attr("max"));
var currentVal=parseInt(item_quantity);
if(currentVal > item_max_value){
$(this).val(item_max_value);
$(this).attr("value", item_max_value);
currentVal=item_max_value;
}
if(currentVal < 0){
$(this).val(1);
$(this).attr("value", 1);
}
if(currentVal==0){
$('#lcitem-' + item_hash).fadeOut();
}
var formData={
cart_key: item_hash,
qty: currentVal
}
$.ajax({
url: get_wcurl('xoo_wsc_update_item_quantity'),
type: 'POST',
context: this,
data: setAjaxData(formData),
success: function(fragments){
unblock();
var cart_qty_count, cart_subtotal;
$.each(fragments , function(key, value){
$(key).replaceWith(value);
});
$.each(fragments, function (name, value){
if(name=="fragments"){
fragments=value;
$.each(fragments, function (name, value){
if(name==".cart__quantity-badge"){
cart_qty_count=String(value).replace(/[^0-9]/g,'');
if(currentVal==0){
jQuery('#lcitem-' + item_hash).remove();
}}
if(name==".mini-cart"){
cart_subtotal=$($.parseHTML(value)).find('.mini-cart__price-total').text();
cart_subtotal=String(cart_subtotal).replace(/[^0-9.]/g,'');
}});
}});
$('.cart-contents-count').text(cart_qty_count);
$('.cart__quantity-badge').text(cart_qty_count);
if(parseInt(cart_qty_count)==0){
cart_subtotal=$.parseHTML('<bdi><span class="woocommerce-Price-currencySymbol">£</span>0.00</bdi>');
}else{
cart_subtotal=$.parseHTML('<bdi><span class="woocommerce-Price-currencySymbol">£</span>'+cart_subtotal+'</bdi>');
}
$('.cart-subtotal .amount').html(cart_subtotal);
if(cart_qty_count==0){
setTimeout(function(){
jQuery('.section-header').attr('style','margin-bottom:0px !important;');
jQuery('#CartPageForm').hide();
jQuery('.xoo-wsc-empty-cart').show();
}, 200);
}},
error: function(XMLHttpRequest, textStatus, errorThrown){
if(currentVal==0){
$('#lcitem-' + item_hash).fadeIn();
}}
});
function setAjaxData(data, noticeSection){
var isCartPage=xoo_wsc_params.isCart=='1',
isCheckoutPage=xoo_wsc_params.isCheckout=='1';
var ajaxData={
container: 'cart',
noticeSection: this.container,
isCheckout: isCheckoutPage,
isCart: isCartPage
}
if(typeof data==='object'){
$.extend(ajaxData, data);
}else{
var serializedData=data;
$.each(ajaxData, function(key, value){
serializedData +=('&'+key+'='+value);
})
ajaxData=serializedData;
}
return ajaxData;
}
function block(){
$('#CartPageForm').addClass('xoo-wsc-loading');
}
function unblock(){
$('#CartPageForm').removeClass('xoo-wsc-loading');
}});
});
jQuery(document).ready(function (){
});
jQuery(document.body).on("updated_checkout", function (){
});
/*function amazonpay_button_refresh_script(){
var iterations=0;
var timer=setInterval(function(){
iterations +=1;
iterations > 100&&clearInterval(this.timer);
try {
jQuery(document.body).find("#pay_with_amazon_product , #pay_with_amazon_cart").get(0).shadowRoot.innerHTML.length&&(jQuery(document.body).find("#pay_with_amazon_product , #pay_with_amazon_cart").get(0).shadowRoot.innerHTML="",
jQuery("#pay_with_amazon_product , #pay_with_amazon_cart").css("opacity", "1"),
clearInterval(this.timer));
} catch (e){
jQuery("#pay_with_amazon_product , #pay_with_amazon_cart").css("opacity", "1");
clearInterval(this.timer);
}}, 25);
var iterations=0;
var timer=setInterval(function(){
iterations +=1;
iterations > 100&&clearInterval(timer);
try {
jQuery(document.body).find("#pay_with_amazon_product , #pay_with_amazon_cart ").get(0).shadowRoot.innerHTML.length&&(jQuery(document.body).find("#pay_with_amazon_product , #pay_with_amazon_cart ").get(0).shadowRoot.innerHTML="",
jQuery("#pay_with_amazon_product , #pay_with_amazon_cart ").css("opacity", "1"),
clearInterval(timer));amazonpay_button_refresh_script();
jQuery(document.body).find("div.xoo-wsc-payment-btns  div#pay_with_amazon_cart").get(0).shadowRoot.innerHTML.length&&(jQuery(document.body).find("div.xoo-wsc-payment-btns div#pay_with_amazon_cart").get(0).shadowRoot.innerHTML="",
jQuery("div.xoo-wsc-payment-btns div#pay_with_amazon_cart").css("opacity", "1"),
clearInterval(timer));
} catch (e){
jQuery("#pay_with_amazon_product , #pay_with_amazon_cart , div.xoo-wsc-payment-btns div#pay_with_amazon_cart").css("opacity", "1");
jQuery("div.xoo-wsc-payment-btns div#pay_with_amazon_cart").css("opacity", "1");
clearInterval(timer);
}}, 25);
} */
jQuery(document).ready(function (){
elemHeight=document.querySelector(".xoo-wsc-payment-btns").offsetHeight;
if(elemHeight > 80){
jQuery(".xoo-wsc-payment-btns").closest("h2").css("margin-bottom","110px !important;");
}
jQuery('.xoo-wsc-payment-btns').on('change', function (){
elemHeight=document.querySelector(".xoo-wsc-payment-btns").offsetHeight;
if(elemHeight > 70){
jQuery(".xoo-wsc-payment-btns").closest("h2").css("margin-bottom","110px !important;");
}});
});
(function($){
let renderTimeout;
function getCartTotal(){
let amountEl=document.querySelector('.xoo-wsc-ft-totals .amount, .cart-subtotal .amount');
if(!amountEl) return null;
return parseFloat(amountEl.innerText.replace(/[^0-9.]/g, ""));
}
function renderPlacement(selector, placementId){
let node=document.querySelector(selector);
if(!node) return;
let total=getCartTotal();
try {
window.paypal.Messages({
amount: total||null,
placement: placementId,
style: { layout: 'text' }}).render(node);
} catch (e){
setTimeout(()=> {
let stableNode=document.querySelector(selector);
if(stableNode){
window.paypal.Messages({
amount: total||null,
placement: placementId,
style: { layout: 'text' }}).render(stableNode);
}}, 250);
}}
function safeRender(){
clearTimeout(renderTimeout);
renderTimeout=setTimeout(function(){
if(!window.paypal||!window.paypal.Messages) return;
renderPlacement('.xoo-wsc-payment-btns .ppcp-messages', 'side-cart');
renderPlacement('#CartPageForm .ppcp-messages', 'cart');
}, 250);
}
function initSubtotalObserver(){
const subtotalEl=document.querySelector('.cart-subtotal .amount');
if(!subtotalEl) return;
const observer=new MutationObserver(function(mutations){
safeRender();
});
observer.observe(subtotalEl, {
childList: true,
characterData: true,
subtree: true
});
}
$(document).on('ppcp-paypal-loaded ppcp-js-sdk-loaded', function(){
initSubtotalObserver();
});
$(document.body).on('wc_fragments_loaded wc_fragments_refreshed updated_checkout', function (){
initSubtotalObserver();
});
$(document).on('ppcp-paypal-loaded ppcp-js-sdk-loaded', safeRender);
$(document.body).on('wc_fragments_loaded wc_fragments_refreshed updated_checkout',
safeRender
);
$(document).ajaxComplete(function(event, xhr, settings){
if(settings.url.includes('wc-ajax')) safeRender();
});
})(jQuery);
jQuery(document).ready(function($){
if(typeof NewsletterPopup!=='undefined'){
NewsletterPopup.submit=async function (event){
event.preventDefault();
event.stopImmediatePropagation();
const form=document.getElementById('tnp-subscription-popup');
if(!form) return;
const $form=$(form);
const $submitButton=$form.find('.tnp-submit');
let $responseDiv=$('#tnp-ajax-response');
if($responseDiv.length===0){
$form.append('<div id="tnp-ajax-response" style="margin-top: 10px;font-family: Montserrat, sans-serif;font-size: 14px"></div>');
$responseDiv=$('#tnp-ajax-response');
}
const originalText=$submitButton.val();
$submitButton.prop('disabled', true).addClass('tnp-loading').val('Processing...');
$responseDiv.html('').hide();
try {
const formData=new FormData(form);
const response=await fetch(newsletter_popup_data.action, {
method: "POST",
body: formData,
});
if(!response.ok) throw new Error('Network response was not ok');
const resultText=await response.text();
$submitButton.prop('disabled', false).removeClass('tnp-loading').css('opacity', '1').val('Success!');
$responseDiv.css('color', 'black').html('Thank you!').fadeIn();
$form.find('input[type="email"]').val('');
if(typeof NewsletterPopup.close==='function'){
}
setTimeout(function(){
if(typeof NewsletterPopup.close==='function'){
NewsletterPopup.close();
}else{
$('#tnp-modal').fadeOut();
}}, 3000);
} catch (error){
console.error("Newsletter Submission Error:", error);
$responseDiv.css('color', '#ff0000').html('An error occurred. Please try again.').fadeIn();
$submitButton.prop('disabled', false).removeClass('tnp-loading').css('opacity', '1').val(originalText);
}
return false;
};}
window.addEventListener('pageshow', function(event){
});
});