	  
// Подписка
        jQuery(function($){
        $(document).ready(function () {

        $(document).on("click", "#sub", function () {
			
			var arr = $("#addsub").serializeArray();
            var aParams = [];
            var sParam;

            for (var i = 0, count = arr.length; i < count; i++) {
                sParam = encodeURIComponent(arr[i].name);
                sParam += "=";
                sParam += encodeURIComponent(arr[i].value);
                aParams.push(sParam);
            }

            sParam = 'action';
            aParams.push(sParam);

            var sendData = aParams.join("&");

            $.ajax({
                url: "https://yourwingshop.ru/phpnewsletter.php",
                method: "POST",
                data: sendData,
                dataType: "json",
                success: function (data) {
                    if (data.result != null) {
                        var alert_msg = '';
                        if (data.result == 'success') {
                            $('.nosuccess-form').fadeOut(200); // Скрыть форму
		$(".success-form").fadeIn(400);     // Показать сообщение об успешной отправке
                        } else if (data.result == 'errors') {
                            $.each(data.msg, function (index, val) {
                                alert_msg += '<div class="alert alert-danger alert-dismissable" style="color:#FF0000; padding-bottom:25px;">';

                                var arr = data.msg[index];
                                alert_msg += '<ul>';

                                for (var i = 0; i < arr.length; i++) {
                                    alert_msg += '<li>' + arr[i] + '</li>';
                                }

                                alert_msg += '</ul>';
                            });
                        }

                        $("#resultSub").html(alert_msg);
                    }
                }
            });
            
        });
    });
     }) 
$(".accordion-permanent").click(function() {
    $(this).toggleClass("newminus");
});
$(".accordion-vopros").click(function() {
    $(this).toggleClass("newminus");
});
$(".accord-permanent").click(function() {
    $(this).toggleClass("open");
});
// меню пигменты
jQuery( ".menu-item-229" ).hover(function() {
  $(".menu-item-229 ul").toggleClass("hover");
});
jQuery( ".menu-item-230" ).hover(function() {
  $(".menu-item-230 ul").toggleClass("hover1");
});
jQuery( ".menu-item-234" ).hover(function() {
  $(".menu-item-234 ul").toggleClass("hover1");
});
jQuery( ".menu-item-238" ).hover(function() {
  $(".menu-item-238 ul").toggleClass("hover1");
});
jQuery( ".menu-item-240" ).hover(function() {
  $(".menu-item-240 ul").toggleClass("hover1");
});
jQuery( ".menu-item-348" ).hover(function() {
  $(".menu-item-348 ul").toggleClass("hover1");
});
// Меню Товары для ПМ
jQuery( ".menu-item-243" ).hover(function() {
  $(".menu-item-243 ul").toggleClass("hover");
});
jQuery( ".menu-item-248" ).hover(function() {
  $(".menu-item-248 ul").toggleClass("hover1");
});
jQuery( ".menu-item-251" ).hover(function() {
  $(".menu-item-251 ul").toggleClass("hover1");
});
jQuery( ".menu-item-253" ).hover(function() {
  $(".menu-item-253 ul").toggleClass("hover1");
});
jQuery( ".menu-item-256" ).hover(function() {
  $(".menu-item-256 ul").toggleClass("hover1");
});
jQuery( ".menu-item-259" ).hover(function() {
  $(".menu-item-259 ul").toggleClass("hover1");
});
jQuery( ".menu-item-244" ).hover(function() {
  $(".menu-item-244 ul").toggleClass("hover1");
});
jQuery( ".menu-item-1100" ).hover(function() {
  $(".menu-item-1100 ul").toggleClass("hover");
});
jQuery( ".menu-item-1101" ).hover(function() {
  $(".menu-item-1101 ul").toggleClass("hover1");
});
 // Успешная отправка письма дистрибьютеров
 document.addEventListener('wpcf7mailsent', function (event) {
		$('.nosuccess-form').fadeOut(400); // Скрыть форму
		$(".success-form").fadeIn(400);     // Показать сообщение об успешной отправке
	}, false);

$('html').on('click','.woocommerce-product-gallery__image a',function(event){
			event.preventDefault();
		});
function toggle_shadow(block_name) {
	$(".shadow-js").fadeToggle();
	$(".shadow-js").attr("id", "shadow-" + block_name);
}

function hide_when_away_click(block, call_button, block_name, method, e) {
	if (!$(block).is(e.target) && $(block).has(e.target).length === 0 &&
		!$(call_button).is(e.target) && $(call_button).has(e.target).length === 0) {
		if (method === null) {
			$(block).hide();
		} else if (method == "slide") {
			$(block).slideUp();
		} else if (method == "fade") {
			$(block).fadeOut();
		} else {
			$(block).removeClass(method);
		}
		$(block).removeClass("active");
		$(call_button).removeClass("active");
		$("#shadow-" + block_name).fadeOut(400, function () {
			$("body").removeClass("no-scroll");
		});
		
	
	}
}


function cookieSet(index, value) {
	$.cookie(index, value, {
		expires: null,
		path: '/',
		domain: document.location.hostname
	});
}


function cookieDel(index) {
	$.cookie(index, null, {
		expires: null,
		path: '/',
		domain: document.location.hostname
	});
}
function fnMorph(n, w1, w2, w3) {
	let count = parseInt(n);
	if (count > 10 && count < 20) return w3;
	count = count % 10;
	if (count > 1 && count < 5) return w2;
	if (count == 1) return w1;

	return w3;
}



//функция которая переносит целевой текст в модалку в футере и показывает её
function create_modal(text){
    var modal_container = $("#commonModal");
        modal_container.find(".content-js").html(text);
        modal_container.toggleClass("show");
		$("body").addClass("no-scroll");
        
}


function startCarousel(item) {
    $(item).owlCarousel({
        dots: false,
            nav:false,
            margin: 32,
            navText: ['<span class="icon-arrow-down"></span>', '<span class="icon-arrow-down"></span>'],
            items: 3,
            responsive: {
                0: {
                    items: 1,
                    autoWidth: true,
                    margin: 16
                },
                575:{
                    items: 1,
                    autoWidth: false,
                    margin: 24
                },
                767: {
                    items: 2,
                    
                },
                1199: {
                    items: 3,
                    autoWidth: false,
                    margin: 32
                }
                
            }
    });
}
function stopCarousel(item) {
    var owl = $(item);
    owl.trigger('destroy.owl.carousel');
    owl.addClass('off');
}
function attachmentCardPic(event) {
    let itemGallery = event.item.index;
    $(".card-slider-js").trigger('to.owl.carousel', [itemGallery]);
    $(".card-slider-nav-js .item").removeClass("chosen");

	$(".card-slider-nav-js .item[data-position="+itemGallery+"]").addClass("chosen");
			
}
function attachmentCardNav(event) {
    let itemGallery = event.item.index;
    $(".card-slider-nav-js").trigger('to.owl.carousel', [itemGallery]);
    $(".card-slider-nav-js .item").removeClass("chosen");

    $(".card-slider-nav-js .item[data-position="+itemGallery+"]").addClass("chosen");
}

function calculate_catalog_items(){ /* // upd */
    $(".product-card-js > *").each(function(){
        $(this).parent().css("height","initial");

        let height = $(this).innerHeight();
        if(height>0){
            $(this).parent().css("height",height+"px");
        }
    })
}
$(document).ready(function () {
	//gently anchor in ABOUT LANDING
	$(".land-nav-js").on("click", "a", function (event) {
		event.preventDefault();
		var id = $(this).attr('href'),
			top = $(id).offset().top - 133;
		$('body,html').animate({
			scrollTop: top
		}, 1000);
	});
    if($(".product-card-js").length>1){ /* // upd */
        calculate_catalog_items();
    }

    $(".collapse-js").click(function(){
        $(this).parent().toggleClass("open");
    })
    $('.card-actions-js').owlCarousel({
        dots: false,
        nav: false,
        margin: 32,
        loop: false,
        nav: false,
        navText: ['<span class="icon-arrow-down"></span>', '<span class="icon-arrow-down"></span>'],
        items: 2,
        responsive: {
            0: {
                nav: false,
                autoWidth: true,
                margin: 16,
                loop: false,
            },
            575: {
                nav: false,
                autoWidth: false,
                margin: 24,
                loop: false,
            },
            767: {
                nav: false,
                margin: 24, /* upd 30.09 */
                autoWidth: false,
            }
            
        }
    });
    $('.js-slider-1').owlCarousel({ //upd 30.09 Необходимо подключить доп. css файл lib/owl.carousel/assets/
        dots: false,
        margin: 2,
        loop: true,
        animateOut: 'fadeOut',
        animateIn: 'fadeIn',
        nav: true,
        navText: ['<span class="icon-arrow-down"></span>', '<span class="icon-arrow-down"></span>'],
        items: 1,
        responsive: {
            0: {
                nav: false,
                autoWidth: true,
                margin: 16,
                loop: false,
                mouseDrag: true,
                touchDrag: true,
            },
            575: {
                nav: false,
                autoWidth: false,
                margin: 24,
                loop: false,
                mouseDrag: true,
                touchDrag: true,
            },
            767: {
                nav: true, 
                autoWidth: false,
                mouseDrag: false,
                touchDrag: false,
            }
            
        }
    });
    $('.js-slider-2').owlCarousel({
        dots: false,
        nav:false,
        margin: 32,
        navText: ['<span class="icon-arrow-down"></span>', '<span class="icon-arrow-down"></span>'],
        items: 2,
        responsive: {
            0: {
                items: 1,
                autoWidth: true,
                margin: 16
            },
            575:{
                items: 1,
                autoWidth: false,
                margin: 24
            },
            767: {
                items: 2,
                autoWidth: false,
                margin: 24
            },
            1199: {
                margin: 32
            }
            
        }
    });
    if($('.js-slider-3 > *').length>1){ /* //upd */
	$('.js-slider-3').owlCarousel({
        dots: false,
        nav:false,
        margin: 32,
        navText: ['<span class="icon-arrow-down"></span>', '<span class="icon-arrow-down"></span>'],
        items: 3,
        responsive: {
            0: {
                items: 1,
                autoWidth: true,
                margin: 16
            },
            575:{
                items: 1,
                autoWidth: false,
                margin: 24
            },
            767: {
                items: 2,
                
            },
            1199: {
                items: 3,
                autoWidth: false,
                margin: 32
            }
            
        }
    });
    }
    if($('.js-slider-4 > *').length>1) { /* //upd */
        $('.js-slider-4').owlCarousel({
            dots: false,
            nav: false,
            margin: 32,
            navText: ['<span class="icon-arrow-down"></span>', '<span class="icon-arrow-down"></span>'],
            items: 4,
            responsive: {
                0: {
                    items: 1,
                    autoWidth: true,
                    margin: 16
                },
                575: {
                    items: 2,
                    autoWidth: false,
                    margin: 24
                },
                767: {
                    items: 3,
                    autoWidth: false,
                },
                1199: {
                    items: 4,
                    autoWidth: false,
                    margin: 32
                }

            }
        });
    }

    $(".card-slider-nav-js").children().each(function (index) {
		$(this).attr('data-position', index); 
	});
    $(".card-slider-js").on('initialized.owl.carousel', function () {
		$(".card-slider-nav-js").owlCarousel({
			loop: false,
			items: 5,
			slideBy: 1,
			dots: false,
			autoplay: false,
			nav: false,
			margin: 24,
			onChanged: attachmentCardPic,

		});
	})
	$(".card-slider-js").owlCarousel({
		items: 1,
		loop:false,
        margin:2,
		autoplay: false,
		mouseDrag: true,
		touchDrag: true,
		pullDrag: true,
		navText: ['<span class="icon-arrow-down"></span', '<span class="icon-arrow-down"></span'],
		nav: true,
		/*animateOut: 'fadeOut',
		animateIn: 'fadeIn',*/
		onChanged:attachmentCardNav,
        responsive: {
            0: {
                dots: true,
                nav:false,
            },
            991: {
                dots: false,
            }
            
        }
	});
	$(document).on('click', '.card-slider-nav-js .item', function (e) {
		e.preventDefault();
        $(".card-slider-nav-js .item").removeClass("chosen");
        $(this).addClass("chosen");
		$(".card-slider-js").trigger('to.owl.carousel', $(this).data('position'));
	});
    $(".mobile-select-js li").on("click",function(){
        if($(window).width() < 767){
        $(this).parent().toggleClass("open");
        }
    })
    $(".video-js").on("click",function(){
        let video = $(this).find("video");
        if($(this).hasClass("playing")){
            video.trigger("pause");
            $(this).removeClass("playing");
        }else{
            video.trigger("play");
            $(this).addClass("playing");
        }
        
        
        
    })
    $(".password-js").on("click",function(){
        if($(this).hasClass("icon-eye")){
            $(this).prev("input").attr("type","text");
        }else{
            $(this).prev("input").attr("type","password");
        }
        $(this).toggleClass("icon-eye");
        $(this).toggleClass("icon-eye-close");
        
    })
    $(".submenu-js").on("click",function(){
        $(this).toggleClass("active");
        $(this).find("ul").fadeToggle();
    })
    $(".show-more-js").on("click",function(){ /* upd 30.09 */
        let text_block = $(this).find("[data-text]");
        let new_text = text_block.data("text");
        text_block.data("text",text_block.text());
        text_block.text(new_text);
        $(this).prev(".show-js").slideToggle();
    })
    $(".call-popup-js").on("click",function(e){
        var modal_content = $(this).next().html();
        create_modal(modal_content);
    })
    $("body").on("click", ".close-js", function () {
		$(this).parent().removeClass("show");
		$("body").removeClass("no-scroll");
	});
    if($(window).scrollTop() > 1)
        $("#header-js").addClass("default");
	if ($(window).width() <= 767) {
		
	}
    $(".quality-js").on("click",function(){
        $(this).parent().siblings().show();
        $(this).parent().hide();
    })
    $(".hamburger-js").on("click",function(){
        $(this).toggleClass("active");
        $("#layout-js").fadeToggle();
    })
    $(".filter-open-js").on("click",function(){
        $(this).parent().toggleClass("open");
    })
    $(".show-filter-js").on("click",function(){
        $(".filter-js").fadeToggle();
    })
	
if($('.social-likes-js').length>0){
$('.social-likes-js').socialLikes({
});
}
if($('.sticky-js').length>0 && $(window).width() > 991){
    var sticky = new Sticky('.sticky-js');
    }
    $(".scroll-js").on("click",function(){
        let height = $("#cover-js").innerHeight();
        $('body,html').animate({
			scrollTop: height
		}, 1000);
    })
    $(window).scroll(function() {
       
        if($(window).scrollTop() > 1){
            $("#header-js").addClass("default");
        }else {
            $("#header-js").removeClass("default");
        }
    })
    if($(window).width() <= 991){
        startCarousel('.priviligies-slider-js');
        startCarousel('.mobile-slider-js');
       
    }else{
       stopCarousel('.priviligies-slider-js');
        stopCarousel('.mobile-slider-js');
    }
    if($(window).width() > 767){
        $(".tab-link-js").each(function(){
            let id = $(this).attr("data-bs-target");
            let this_text = $(this).text();
            let text = $(id).find(".tab-desc-js").text();
            $(this).html('<div class="title">'+this_text+'</div><div class="desc">'+text+'</div>');
        })
    }else{
       
    }
   
})

//RESIZE 
$(window).resize(function () {
    if($(".product-card-js").length>1){ /* // upd */
        calculate_catalog_items();
    }
	if ($(window).width() <= 991) {
	
	} else {
		var sticky = new Sticky('.sticky-js');
	}
    if($(window).width() <= 991){
        startCarousel('.priviligies-slider-js');
        startCarousel('.mobile-slider-js');
    }else{
       stopCarousel('.priviligies-slider-js');
        stopCarousel('.mobile-slider-js');
    }
	
});
//END RESIZE


$(document).mouseup(function (e) {
	hide_when_away_click(".nav-js", ".hamburger-js", "menu", "active", e);
	hide_when_away_click(".callback-js", null, "callback", "show", e);
	hide_when_away_click(".popup-js", ".call-popup-js", "popup", "show", e); 
	hide_when_away_click(".mobile-nav-js", ".nav-button-js", null, "show", e);
    hide_when_away_click(".mobile-nav-js", ".nav-button-js", null, "show", e);
    hide_when_away_click(".submenu-js ul", ".submenu-js", null, "fade", e);
    
});

function setCookie(name,value,days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        expires = "; expires=" + date.toUTCString();
    }
    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
}
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function eraseCookie(name) {
    document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
// Добавляем class div в зависимости от url 
window.onload = init;
var divsWithClass = null;

function init() {
    if (window.location.href.indexOf("https://yourwingshop.ru/product-category/pigmenty/dlya-brovej-vek/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("brovi");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/pigmenty/dlya-gub/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("gybu");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/pigmenty/dlya-kozhi/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("kozha");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/pigmenty/dlya-areoly/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("areola");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
   if (window.location.href.indexOf("https://yourwingshop.ru/product-category/pigmenty/dlya-triho/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("trixo");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/remuver/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("remyver");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/kosmeticheskie-sredstva/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("cream");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/tovary-dlya-pm/oborudovanie/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("apparat");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/tovary-dlya-pm/instrumenty-dlya-eskiza/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("eskiz");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/tovary-dlya-pm/ohlazhdayushhij-krem/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("krem");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/tovary-dlya-pm/trenirovochnye-materialy/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("latex");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/tovary-dlya-pm/rashodnye-materialy/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("rasxod");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
	if (window.location.href.indexOf("https://yourwingshop.ru/product-category/tovary-dlya-pm/aksessuary/") >= 0) {
        this.divsWithClass = document.getElementsByClassName("assesori");
        var index = 0;
        while (index < divsWithClass.length) {
            divsWithClass[index].className += " open";
            index++;
        }
    }
}
$(function(){
  if ( $(window).width() < 976 ) {

	$(".hide-filter-js").on("click",function(){ 
        $(".filter-js").fadeToggle();
    })
	}
});

  //Обрезаем текст в div
  jQuery(function(){
  var cut = document.getElementsByClassName('text');
  for( var i = 0; i < cut.length; i++ ){
    cut[i].innerText = cut[i].innerText.slice(0,220) + '...';
  }
})
//Обрезаем текст в div
  jQuery(function(){
  var cut = document.getElementsByClassName('aktext');
  for( var i = 0; i < cut.length; i++ ){
    cut[i].innerText = cut[i].innerText.slice(0,280) + '...';
  }
})
//Обрезаем текст в div
  jQuery(function(){
  var cut = document.getElementsByClassName('cattext');
  for( var i = 0; i < cut.length; i++ ){
    cut[i].innerText = cut[i].innerText.slice(0,420) + '...';
  }
})

//Валидация wpcf7-form
$(document).ready(function(){
 var pattern = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
 var mail = $('#user-mail');
 
 mail.blur(function(){
  if(mail.val() != ''){
 if(mail.val().search(pattern) == 0){
 document.getElementById("user-mail").style.backgroundColor='rgb(255, 255, 255)';
 $('#valid').text('ᅠ ᅠ ');
 $('#submit').attr('disabled', false);
 mail.removeClass('error').addClass('ok');
 }else{
document.getElementById("user-mail").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#valid').text('Введен не корректный e-mail!');
 $('#submit').attr('disabled', true);
 mail.addClass('ok');
 }
 }else{
	 document.getElementById("user-mail").style.backgroundColor='rgb(243, 237, 223)';
 $('#valid').text('Поле e-mail не должно быть пустым!');
 mail.addClass('error');
 $('#submit').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
 var mail = $('#user-mails');
 
 mail.blur(function(){
  if(mail.val() != ''){
 if(mail.val().search(pattern) == 0){
 document.getElementById("user-mails").style.backgroundColor='rgb(255, 255, 255)';
 $('#valids').text('ᅠ ᅠ ');
 $('#submits').attr('disabled', false);
 mail.removeClass('error').addClass('ok');
 }else{
document.getElementById("user-mails").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#valids').text('Введен не корректный e-mail!');
 $('#submits').attr('disabled', true);
 mail.addClass('ok');
 }
 }else{
	 document.getElementById("user-mails").style.backgroundColor='rgb(243, 237, 223)';
 $('#valids').text('Поле e-mail не должно быть пустым!');
 mail.addClass('error');
 $('#submits').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /^([а-яё\s]+|[a-z\s]+)$/iu;
 var name = $('#user-name');
 
 name.blur(function(){
  if(name.val() != ''){
 if(name.val().search(pattern) == 0){
 document.getElementById("user-name").style.backgroundColor='rgb(255, 255, 255)';
 $('#valid').text('ᅠ ᅠ ');
 $('#submit').attr('disabled', false);
 name.removeClass('error').addClass('ok');
 }else{
document.getElementById("user-name").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#valid').text('Введите свое Имя используя буквы!');
 $('#submit').attr('disabled', true);
 name.addClass('ok');
 }
 }else{
	 document.getElementById("user-name").style.backgroundColor='rgb(243, 237, 223)';
 $('#valid').text('Поле Имя не должно быть пустым!');
 name.addClass('error');
 $('#submit').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /^([а-яё\s]+|[a-z\s]+)$/iu;
 var name = $('#user-names');
 
 name.blur(function(){
  if(name.val() != ''){
 if(name.val().search(pattern) == 0){
 document.getElementById("user-names").style.backgroundColor='rgb(255, 255, 255)';
 $('#valids').text('ᅠ ᅠ ');
 $('#submits').attr('disabled', false);
 name.removeClass('error').addClass('ok');
 }else{
document.getElementById("user-names").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#valids').text('Введите свое Имя используя буквы!');
 $('#submits').attr('disabled', true);
 name.addClass('ok');
 }
 }else{
	 document.getElementById("user-names").style.backgroundColor='rgb(243, 237, 223)';
 $('#valids').text('Поле Имя не должно быть пустым!');
 name.addClass('error');
 $('#submits').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /^(\s*)?(\+)?([- _():=+]?\d[- _():=+]?){10,14}(\s*)?$/;
 var phone = $('#user-phone');
 
 phone.blur(function(){
  if(phone.val() != ''){
 if(phone.val().search(pattern) == 0){
 document.getElementById("user-phone").style.backgroundColor='rgb(255, 255, 255)';
 $('#valid').text('ᅠ ᅠ ');
 $('#submit').attr('disabled', false);
 phone.removeClass('error').addClass('ok');
 }else{
document.getElementById("user-phone").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#valid').text('Введите свой номер телефона правильно!');
 $('#submit').attr('disabled', true);
 phone.addClass('ok');
 }
 }else{
	 document.getElementById("user-phone").style.backgroundColor='rgb(243, 237, 223)';
 $('#valid').text('Поле телефон не должно быть пустым!');
 phone.addClass('error');
 $('#submit').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /^(\s*)?(\+)?([- _():=+]?\d[- _():=+]?){10,14}(\s*)?$/;
 var phone = $('#user-phones');
 
 phone.blur(function(){
  if(phone.val() != ''){
 if(phone.val().search(pattern) == 0){
 document.getElementById("user-phones").style.backgroundColor='rgb(255, 255, 255)';
 $('#valids').text('ᅠ ᅠ ');
 $('#submits').attr('disabled', false);
 phone.removeClass('error').addClass('ok');
 }else{
document.getElementById("user-phones").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#valids').text('Введите свой номер телефона правильно!');
 $('#submits').attr('disabled', true);
 phone.addClass('ok');
 }
 }else{
	 document.getElementById("user-phones").style.backgroundColor='rgb(243, 237, 223)';	
 $('#valids').text('Поле телефон не должно быть пустым!');
 phone.addClass('error');
 $('#submits').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /(?:^|[^\w])(?:@)([A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}(?:[A-Za-z0-9_]))?)/;
 var insta = $('#user-insta');
 
 insta.blur(function(){
  if(insta.val() != ''){
 if(insta.val().search(pattern) == 0){
 document.getElementById("user-insta").style.backgroundColor='rgb(255, 255, 255)';
 $('#valid').text('ᅠ ᅠ ');
 $('#submit').attr('disabled', false);
 insta.removeClass('error').addClass('ok');
 }else{
document.getElementById("user-insta").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#valid').text('Введите свой @username Инстаграм!');
 $('#submit').attr('disabled', true);
 insta.addClass('ok');
 }
 }else{
	 document.getElementById("user-insta").style.backgroundColor='rgb(243, 237, 223)';
 $('#valid').text('Поле Инстаграм не должно быть пустым!');
 insta.addClass('error');
 $('#submit').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /(?:^|[^\w])(?:@)([A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}(?:[A-Za-z0-9_]))?)/;
 var insta = $('#user-instas');
 
 insta.blur(function(){
  if(insta.val() != ''){
 if(insta.val().search(pattern) == 0){
 document.getElementById("user-instas").style.backgroundColor='rgb(255, 255, 255)';
 $('#valids').text('ᅠ ᅠ ');
 $('#submits').attr('disabled', false);
 insta.removeClass('error').addClass('ok');
 }else{
document.getElementById("user-instas").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#valids').text('Введите свой @username Инстаграм!');
 $('#submits').attr('disabled', true);
 insta.addClass('ok');
 }
 }else{
	 document.getElementById("user-instas").style.backgroundColor='rgb(243, 237, 223)';
 $('#valids').text('Поле Инстаграм не должно быть пустым!');
 insta.addClass('error');
 $('#submits').attr('disabled', true);
 }
 });
});


//Валидация form Подписка
$(document).ready(function(){
 var pattern = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
 var mail = $('#email');
 
 mail.blur(function(){
  if(mail.val() != ''){
 if(mail.val().search(pattern) == 0){
 document.getElementById("email").style.backgroundColor='rgb(255, 255, 255)';
 $('#resultSub').text('ᅠ ᅠ ');
 $('#sub').attr('disabled', false);
 mail.removeClass('error').addClass('ok');
 }else{
document.getElementById("email").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#resultSub').text('Введен не корректный e-mail!');
 $('#sub').attr('disabled', true);
 mail.addClass('ok');
 }
 }else{
	 document.getElementById("email").style.backgroundColor='rgb(243, 237, 223)';
 $('#resultSub').text('Поле e-mail не должно быть пустым!');
 mail.addClass('error');
 $('#sub').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /^([а-яё\s]+|[a-z\s]+)$/iu;
 var name = $('#name');
 
 name.blur(function(){
  if(name.val() != ''){
 if(name.val().search(pattern) == 0){
 document.getElementById("name").style.backgroundColor='rgb(255, 255, 255)';
 $('#resultSub').text('ᅠ ᅠ ');
 $('#sub').attr('disabled', false);
 name.removeClass('error').addClass('ok');
 }else{
document.getElementById("name").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#resultSub').text('Введите свое Имя используя буквы!');
 $('#sub').attr('disabled', true);
 name.addClass('ok');
 }
 }else{
	 document.getElementById("name").style.backgroundColor='rgb(243, 237, 223)';
 $('#resultSub').text('Поле Имя не должно быть пустым!');
 name.addClass('error');
 $('#sub').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /^(\s*)?(\+)?([- _():=+]?\d[- _():=+]?){10,14}(\s*)?$/;
 var phone = $('#phone');
 
 phone.blur(function(){
  if(phone.val() != ''){
 if(phone.val().search(pattern) == 0){
 document.getElementById("phone").style.backgroundColor='rgb(255, 255, 255)';
 $('#resultSub').text('ᅠ ᅠ ');
 $('#sub').attr('disabled', false);
 phone.removeClass('error').addClass('ok');
 }else{
document.getElementById("phone").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#resultSub').text('Введите свой номер телефона правильно!');
 $('#sub').attr('disabled', true);
 phone.addClass('ok');
 }
 }else{
	 document.getElementById("phone").style.backgroundColor='rgb(243, 237, 223)';
 $('#resultSub').text('Поле Телефон не должно быть пустым!');
 phone.addClass('error');
 $('#sub').attr('disabled', true);
 }
 });
});

//Валидация form Оформление заказа
$(document).ready(function(){
 var pattern = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
 var mail = $('#billing_email');
 
 mail.blur(function(){
  if(mail.val() != ''){
 if(mail.val().search(pattern) == 0){
 document.getElementById("billing_email").style.backgroundColor='rgb(255, 255, 255)';
 $('#resultSub').text('ᅠ ᅠ ');
 $('#place_order').attr('disabled', false);
 mail.removeClass('error').addClass('ok');
 }else{
document.getElementById("billing_email").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#resultSub').text('Введен не корректный e-mail!');
 $('#place_order').attr('disabled', true);
 mail.addClass('ok');
 }
 }else{
	 document.getElementById("billing_email").style.backgroundColor='rgb(243, 237, 223)';
 $('#resultSub').text('Поле e-mail не должно быть пустым!');
 mail.addClass('error');
 $('#place_order').attr('disabled', true);
 }
 });
});
$(document).ready(function(){
 var pattern = /^(\s*)?(\+)?([- _():=+]?\d[- _():=+]?){10,14}(\s*)?$/;
 var phone = $('#billing_phone');
 
 phone.blur(function(){
  if(phone.val() != ''){
 if(phone.val().search(pattern) == 0){
 document.getElementById("billing_phone").style.backgroundColor='rgb(255, 255, 255)';
 $('#resultSub').text('ᅠ ᅠ ');
 $('#sub').attr('disabled', false);
 phone.removeClass('error').addClass('ok');
 }else{
document.getElementById("billing_phone").style.backgroundColor='rgb(243, 237, 223)';	 
 $('#resultSub').text('Введите свой номер телефона правильно!');
 $('#sub').attr('disabled', true);
 phone.addClass('ok');
 }
 }else{
	 document.getElementById("billing_phone").style.backgroundColor='rgb(243, 237, 223)';
 $('#resultSub').text('Поле Телефон не должно быть пустым!');
 phone.addClass('error');
 $('#sub').attr('disabled', true);
 }
 });
});
//Чекаем чекбокс в форме подписки
let checkboxes = Array.from(document.querySelectorAll('input.podpinp'));
checkboxes.forEach(input => input.checked = true);
$('input.podpinp').click(function(){
	if ($(this).is(':checked')){
		$('#resultSub').text('ᅠ ᅠ ');
		$('#sub').attr('disabled', false);
	} else {
		$('#resultSub').text('Не стоит галочка согласен с пользовательским соглашением');
		$('#sub').attr('disabled', true);
	}
});
//Чекаем чекбокс в форме оформление заказа
let agreecheckboxes = Array.from(document.querySelectorAll('input.agreeinp'));
agreecheckboxes.forEach(input => input.checked = true);
$('input.agreeinp').click(function(){
	if ($(this).is(':checked')){
		$('#resultSub').text('ᅠ ᅠ ');
		$('#place_order').attr('disabled', false);
	} else {
		$('#resultSub').text('Не стоит галочка согласен с пользовательским соглашением');
		$('#place_order').attr('disabled', true);
	}
});

