/*progressively.init({
  delay: 50,
  throttle: 300,
 
});*/
 new WOW().init();
var stepper = function(s, dp) {
    if (s && typeof s == 'string') s = parseFloat(s)
    if (dp && typeof dp == 'string') dp = parseFloat(dp)
    if (arguments.length == 1) dp = -1
    this.s = s
    this.dp = dp
    this.running = true;
    this.validate()
    return this
}
stepper.prototype = {
    validate: function() {
        if (parseFloat(this.setDP(this.s)) == 0) {
            alert("The decimal places cannot be shorter than the PIP.\ndp = " + this.dp + ", pip = " + this.s)
        }
    },
    mul: function() {
        return Math.pow(10, this.dp == -1 ? 1 : this.dp)
    },
    upToInt: function(n) {
        return Math.round(n * this.mul())
    },
    downToFloat: function(n) {
        return (n / this.mul())
    },
    setDP: function(n) {
        var r = n.toString()
        if (this.dp == -1) return r
        if (this.dpLen(r) == -1 && this.dp > 0) r += ".0"
        else if (this.dpLen(r) == -1 && this.dp == 0) return r
        if (this.dpLen(r) > this.dp) {
            var i = r.indexOf('.')
            r = r.substring(0, i) + '.' + r.substring(i + 1, i + 1 + this.dp)
        } else {
            while (this.dpLen(r) < this.dp) r += "0"
        }
        return r
    },
    dpLen: function(n) {
        if (n.indexOf('.') == -1) return -1
        else
            return (n.length) - (n.indexOf('.') + 1)
    },
    step: function(n) {
        if (arguments.length) {
            if (arguments[0] && typeof arguments[0] == 'string') {
                this.n = parseFloat(arguments[0])
            } else if (arguments[0] == NaN) {
                this.n = 0
            } else {
                this.n = arguments[0]
            }
        } else {
            alert("stepper::step expects a float value")
            return
        }
        var n = this.upToInt(this.n)
        var s = this.upToInt(this.s)
        var r = this.setDP(this.downToFloat(n - (n % s) + s))
        return r
    }
}
jQuery.fn.mousehold = function(timeout, f) {
    if (timeout && typeof timeout == 'function') {
        f = timeout;
        timeout = 100;
    }
    if (f && typeof f == 'function') {
        var timer = 0;
        var fireStep = 0;
        return this.each(function() {
            jQuery(this).mousedown(function() {
                fireStep = 1;
                var ctr = 0;
                var t = this;
                timer = setInterval(function() {
                    ctr++;
                    f.call(t, ctr);
                    fireStep = 2;
                }, timeout);
            })
            clearMousehold = function() {
                clearInterval(timer);
                if (fireStep == 1) f.call(this, 1);
                fireStep = 0;
            }
            jQuery(this).mouseout(clearMousehold);
            jQuery(this).mouseup(clearMousehold);
        })
    }
}







function initRpMenu(){

		$menu = $("#master-menu").clone();
		$product = $("#fixed-top .main-menu-nav:first > ul").clone();
		$menu.removeAttr("id");
		$menu.find(".no-index").remove();
		$menu.find("img").remove();
		$("#responsive-menu .content").append($menu);
		
		$("#responsive-menu .content").append('<div class="clearfix"></div>');
		$menu = $("#responsive-menu .content ul");
		$product.find(".fa").remove();
		$menu.find(".has-menu").append($product);
		$menu.find("li").each(function(){
			if($(this).find("ul").length){
				$(this).addClass("has-child");
				$(this).find("a").first().append("<span class='toggle-menu'><i class='glyphicon glyphicon-menu-down'></i></span>");
			}
		})
		$("#responsive-menu .toggle-menu").click(function(){
				$(this).find("i").toggleClass("glyphicon-menu-down");
				$(this).find("i").toggleClass("glyphicon-menu-up");
			if(!$(this).hasClass("active")){
				$(this).parent().parent().find("ul").first().slideDown();
				$(this).addClass("active");
			}else{
				$(this).parent().parent().find("ul").first().slideUp();
				$(this).removeClass("active");
			}
			return false;
		})
		$("#responsive-menu .title").click(function(){
			$list = $(this).next().next().find("ul").first();
			
			if($list.is(":visible")){
				$list.slideUp();
			}else{
				
				$list.slideDown();
			}
		})
		$("#top-header .menu .toggle").click(function(){
			$(".title-rpmenu").trigger("click");
		})
		if($("#responsive-menu").length){
		$("#responsive-menu").attr("data-top",$("#responsive-menu").offset().top);
		$(window).scroll(function(){
			$top = $(window).scrollTop();
			$ele = $("#responsive-menu").attr("data-top");
			if($top > $ele){
				//$("#responsive-menu").css({position:"fixed"});
			}else{
			//	$("#responsive-menu").css({position:"relative"});
			}
			
		})
		}
		
		$(".title-rpmenu").click(function(){
		$("body").css({
				"overflow-x":"hidden"
		})
		$("#responsive-menu").css({'transition' : 'all 0.7s ease-in-out',
		'transform' : 'translateX(300px)'});
		$(".title-rpmenu").fadeOut();

		return false;
	})
	
	$("#responsive-menu button.close,#nav-page-wrapper,#xmen").click(function(){
		
		$("#responsive-menu").css({
		'transform' : 'translateX(0px)'});
		setTimeout(function(){
			$(".title-rpmenu").fadeIn();
			$("body").css({
				"overflow-x":"auto"
		})
		},1000)
	})
		
}
function setRaty() {
    if ($(".raty").length) {
        $(".raty").each(function() {
            path = $(this).data("big") ? 'images_big' : 'images';
            $(this).raty({
                path: 'assets/plugins/raty/' + path,
                score: $(this).data("score"),
                readOnly: true
            });
        })
    }
}

function initAjax(options) {
    var defaults = {
        url: '',
        type: 'post',
        data: null,
        dataType: 'html',
        error: function(e) {
            console.log(e)
        },
        success: function() {
            return false;
        },
        beforeSend: function() {},
    };
    var options = $.extend({}, defaults, options);
    $.ajax({
        url: options.url,
        data: options.data,
        success: options.success,
        error: options.error,
        type: options.type,
        dataType: options.dataType,
    })
}
function removeCard($code){
	if(confirm("Bạn có chắc chắn muốn xóa sản phẩm này?")){
	$ob = $(".product.line-"+$code);
	$ob.find("input").val(0);
	updateCartFrame();
	}
}
function updateCartFrame(){
	$("#box-shopcart").addClass("ani-loading");
	$("#box-shopcart").before("<div class='ajax-loading'></div>");
	$.ajax({
		type:"post",
		url:"ajax/update-cart.html",
		data:$("#box-shopcart form").serialize(),
		success:function(data){
			
			$("#box-shopcart").html(data);
			$(".ajax-loading").fadeOut(function(){
				
				$(".ajax-loading").remove();
				
			})
			$("#box-shopcart").removeClass("ani-loading");
			$("#box-shopcart").addClass("reani-loading");
		}
		
		
		
	})
	return false;
	
}
function controlProductQty() {
    /*$("button.add-cart").unbind("click");
    $("button.add-cart").click(function() {
        p = $(this).parents(".product-qty");
        doAddCart($(this).data("name"), $(this).data("id"),$	("#qty").val(),0,0,true);
        return false;
    })*/
    $(".product-qty .controls button").unbind("mousehold");
    $(".product-qty .controls button").mousehold(function() {
        a = $(this);
        c = $(this).parent().find("input");
        v = parseInt(c.val());
        if (a.hasClass("is-up")) {
            v++;
        } else {
            v--;
        }
        if (v < 1) {
            v = 1;
        }
        c.val(v);
    })
}

function checkImageError() {
    $("img.image-thumb").attr("onerror", "this.onerror=null;this.src='images/no_photo.png'");
    $("img.image-thumb").each(function() {
        d = new Date();
        $(this).attr("src", $(this).attr("src") + "?" + d.getTime());
    })
}

function initBackToTop() {
    $(window).scroll(function() {
        if ($(window).scrollTop() != 0) {
            $(".back-to-top").stop().animate({
                right: '25px',
                bottom: '25px'
            })
        } else {
            $(".back-to-top").stop().animate({
                right: '-60px',
                bottom: '-60px'
            });
        }
    });
    $(".back-to-top").click(function() {
        $("html, body").animate({
            scrollTop: 0
        }, 1000);
        return false;
    });
}

function resetEmptyContent() {
    $(".empty-content").each(function() {
        $w = $(this).find("span").width() + 70;
        $(this).width($w);
    })
}

function initMenu() {
    $("#main-nav").css({
        "opacity": "0"
    });
    $("ul#main-nav li").css({
        overflow: "hidden"
    });
    $("ul#main-nav li *").attr("style", "");
    $w = 0;
    $sl = 0;
    $("#main-nav > li").each(function() {
        $(this).find("a").css({
            "padding-left": "0",
            "padding-right": "0"
        });
        $w += $(this).outerWidth();
        $sl++;
    })
    $win = $("nav #main-nav").width();
    $sprt = $win;
    $pad = (($sprt / $sl));
    $xx = 0;
    $("#main-nav > li > a").each(function() {
        $padx = (($pad - $(this).width()) / 2) - 5;
        $(this).css({
            "padding-left": $padx,
            "padding-right": $padx
        });
    })
    $("#main-nav").css({
        "opacity": "1"
    });
    setTimeout(function() {
        $(".s-child").parent().addClass("s");
        $(".title-link").click(function() {
            $(this).next().slideToggle();
            return false;
        })
        $("#main-nav  li.f").each(function() {
            if ($(this).find("ul").length) {
                $obj = $(this).find("ul").first();
                $w = $obj.find("li.t").first().find("a").width();
                $obj.find("li.t").each(function() {
                    if ($(this).find("a").width() > $w) {
                        console.log($(this).find("a").width());
                        $w = $(this).find("a").width();
                    }
                })
                $obj.css({
                    "width": $w + 20,
                    "display": "none",
                    "position": "absolute"
                });
            }
        });
        $("#main-nav  li.f").parent().addClass("x");
        $("#main-nav  li").each(function() {
            if ($(this).find("ul").length) {
                $obj = $(this).find("ul.x").first();
                $w = $obj.find("li.f").first().find("a").width();
                $obj.find("li.f").each(function() {
                    if ($(this).find("a").width() > $w) {
                        $w = $(this).find("a").width();
                    }
                })
                $obj.css({
                    "width": $w + 20,
                    "display": "none",
                    "position": "absolute"
                });
            }
        });
        $("#main-nav  li").css({
            overflow: "inherit"
        });
    }, 1000);
}

function setList() {
    $w = 0;
    $max = $(".container").width();
    var $stt = 0;
    $(".top-footer .menu ul li a").each(function() {
        $stt++;
        $w += $(this).width();
    })
    $pd = (($max - $w) / $stt) / 2;
    $(".top-footer .menu ul").width($max);
    $(".top-footer .menu ul li").css({
        "padding": "0 " + $pd + "px"
    });
}

function setCenterTitle() {
    setTimeout(function() {
        $(".global-title").each(function() {
            $core = $(this).find("h2");
            $core.css("padding", "0 30px");
            $core.removeClass("active");
            $core.css({
                float: "left",
                "margin": "auto"
            });
            $w = $core[0].clientWidth;
            $core.css({
                width: $w,
                "float": "none",
                "padding": 0
            });
            $core.addClass("active");
        })
    }, 200);
}

function initQuickView() {
    $(".quick-view-product").click(function() {
        $href = $(this).attr("href");
        $.fancybox({
            href: $href,
            type: "ajax",
            autoSize: false,
            width: 900,
            height: 900,
            afterShow: function() {
                initShowTooltip();
            }
        })
        return false;
    })
}

function initOpenFormMember() {
    $(".open_form").click(function() {
        if (!$("#form_member").length) {
            $("body").append("<div id='form_member' class=''></div>");
        }
        $.post(base_url + "/thanh-vien/open-form.html", {
            type: $(this).data("type")
        }, function(data) {
            $("#form_member").html(data);
            $("#form_member").append("<a href='' data-toggle='modal' id='tg_modal' data-target='#regestration'>bcddddddd</a>")
            $("#tg_modal").click();
            return false;
        });
        return false;
    })
}

function showMsg($type, $msg) {
    notify({
        type: $type,
        title: "Thông báo",
        message: $msg,
        position: {
            x: "right",
            y: "top"
        },
        icon: '<img src="assets/plugins/notify/images/paper_plane.png" />',
        size: "normal",
        overlay: false,
        closeBtn: true,
        overflowHide: false,
        spacing: 20,
        theme: "default",
        autoHide: true,
        delay: 2500,
        onShow: null,
        onClick: null,
        onHide: null,
        template: '<div class="notify"><div class="notify-text"></div></div>'
    });
}

function updateCart() {
    NProgress.start();
    $("#content-center").animate({
        opacity: ".9"
    });
    initAjax({
        url: "ajax/update-cart.html",
        data: $("#box-shopcart form").serialize(),
        success: function(data) {
            console.log(data);
            refreshCart();
        }
    })
}

function refreshCart() {
    $.post("gio-hang.html", function(data) {
        $("#box-shopcart").html(data);
        updateCartNumber();
        NProgress.done();
        $("#content-center").animate({
            opacity: 1
        });
        $('[data-toggle="tooltip"]').tooltip();
    })
}

function updateCartNumber() {
    $.post("ajax/get-cart-num.html", function(data) {
        $(".cart-num").html(data);
    })

}



	function setHeaderFixed(){
		
		//$("body").css({paddingTop:$("header").height()});
		$(".nav-fixed-scroll").attr("data-height",$(".nav-fixed-scroll").offset().top);
	
		
		function setFix(){
			if($(".nav-fixed-scroll").length){
				$he = $(".nav-fixed-scroll").data("height");
				if($(window).width() > 991){
				$w = $(window).scrollTop();
				if($w > $he){
					
					$(".nav-fixed-scroll").addClass("fixed");
					
				}else{
					
					$(".nav-fixed-scroll").removeClass("fixed");
					
				}
				
				}else{
						$(".nav-fixed-scroll").removeClass("fixed");
				}
			}
			
		}
		setFix();
		$(window).scroll(function(){
			setFix();
		})
	
}
function numberFormat(num,ext) {
			ext = (!ext) ? ' đ' : ext;
		   return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".")+ext;
		}

function initIndex(){
	if($("ul#count").length){
		$('ul#count').countdown({

			date: promotion_end
			
		})
	}
	
	if($("#dialog-member").length){
	
		$("body").css({backgroundColor:$("#dialog-member").css("backgroundColor")});
	}
		
	if($(window).width() <=768){	
		$(".top-menu-rev .title span.ar").click(function(){
			$(this).parent().find("ul").first().slideToggle();
			return false;
		})
	}
	
	
	
	
	
	
	
	
	
	if($(".product-carousel").length){
		$(".product-carousel .owl-carousel").owlCarousel({
			loop:true,
			margin:0,
			nav:true,
			navText:['<span class="wrap"><i class="fa fa-angle-left" aria-hidden="true"></i></span>','<span class="wrap"><i class="fa fa-angle-right" aria-hidden="true"></i></span>'],
			responsiveClass:true,
			responsive:{
				0:{
								items:1,
								
							},
							
							380:{
								items:1,
								
							},
							600:{
								items:2,
							
							},
							1000:{
								items:2,
								
							}
			}
		})
	}
	if($(".owl-hot-seller").length){
		$(".owl-hot-seller").owlCarousel({
			loop:true,
			margin:10,
			nav:false,
			responsiveClass:true,
			responsive:{
				0:{
								items:1,
								
							},
							320:{
								items:2,
								
							},
							600:{
								items:2,
							
							},
							1000:{
								items:3,
								margin:30,
							}
			}
		})
		
		
		$(".left-in-product .carousel.active").owlCarousel({
			loop:true,
			margin:0,
			nav:false,
			responsiveClass:true,
			responsive:{
				0:{
								items:1,
								
							},
							320:{
								items:2,
								
							},
							600:{
								items:2,
							
							},
							1000:{
								items:4,
								
							}
			}
		})
		
		
		$(".tab .top-tab-control a").click(function(){
			if(!$(this).parent().hasClass("active")){
				$id = $(this).attr("href");
				$par = $(this).parent();
				$par.parent().find("li").removeClass("active");
				$par.addClass("active");
				$content = $par.parents(".tab").find(".top-tab-content");
				
				$content.find(".tab-content").removeClass("active");
				$tar = $content.find($id);
				$tar.addClass("active");
				if(!$tar.find(".owl-theme").length){
					$tar.find(".owl-carousel").owlCarousel({
						loop:true,
						margin:10,
						nav:false,
						responsiveClass:true,
						responsive:{
							0:{
								items:1,
								
							},
							320:{
								items:2,
								
							},
							600:{
								items:2,
							
							},
							1000:{
								items:3,
								
							}
						}
					})
				}
			}
			return false;
		})
		
		
		
		
		
		
		
		
		
				if($(".wrap-big-section").length){
			
			
			$(".wrap-big-section").each(function(){
				$(this).find(".tab:not(.active)").find(".item-product.mini").addClass("loading");
			})
			$(".wrap-big-section .list-wrap li:not(.link) a").click(function(){
				if(!$(this).parent().hasClass("active")){
				$hr = $(this).attr("href");
				$tar = $(this).parents(".wrap-big-section").find(".body-ad");
				$tar.find(".tab.active").addClass("loading");
				$tar.find(".basel-products-loader").addClass("loading");
				setTimeout(function(){
					$tar.find(".item-product").addClass("loading");
					$tar.find(".tab.active").removeClass("active");
					$tar.find(".basel-products-loader").removeClass("loading");
					$tar.find(".tab").removeClass("loading");
					$tar.find($hr).addClass("active");
					
					if(!$tar.find($hr).find(".owl-theme").length){
					$tar.find($hr).find(".owl-carousel").owlCarousel({
						loop:true,
						margin:10,
						nav:false,
						responsiveClass:true,
						responsive:{
							0:{
								items:1,
								
							},
							380:{
								items:1,
								
							},
							600:{
								items:2,
							
							},
							1000:{
								items:4,
								
							}
						}
					})
				}
					
					
					$x=0;
					$tar.find($hr).find(".root").each(function(index){
						$x++;
						setTimeout(function(){
							var $faded = false;
							$tar.find($hr).find(".root").each(function(){
								if($(this).find(".item-product").hasClass("loading") && !$faded){
									$(this).find(".item-product").removeClass('loading');
									$faded = true;
									
								}								
							})							
						},150*index);
						
					})
					
					//$tar.find(".tab").removeClass("loading");
				},0);
					$(this).parents("ul").find("li").removeClass("active");
					$(this).parent().addClass("active");
				}
				return false;
				
			})
			
			
			
		}
		
		
		
		
		
		
		
		
		
		
	}
}
function removeOrder($ob){
	if(confirm("Bạn có chắc chắn muốn xóa đơn hàng này")){
		$id = $ob.data("id");
		$.ajax({
			url:"ajax/remove-order.html",
			type:"post",
			data:{id:$id},
			success:function(){
				location.reload();
			}
			
		})
	}
	return false;
}

function initSearchForm(){
	$(".form-search,.search-form").submit(function(){
					$cat = "";
					if($(this).find("select").length){
						$cat = $(this).find("select").val()
					}
							window.location.href="search.html/keyword="+$(this).find("input").val()+"&category="+$cat;
							return false;
						})
}
function showAlert($text,$title){
	if(!$title){
		$title = _lang.alert;
	}
	alertify.alert().setting({
    'label':'Ok',
	'title':$title,
    'message': $text ,
	'transition':'fade',
  }).show();
  
}
function initSlider(){
	
	$(".inner .menu-float .nav,#fixed-top .menu-float .nav").click(function(){
			
			$(this).next().stop().slideToggle();
		})
	
	if($("#camera_wrap_1").length){
		
		
		$('#camera_wrap_1').camera({
				thumbnails: true,
				autoAdvance:true,
				time:2000,
				height:"43%",

			});
		
		
		
		
		/*$(".slick-vertical .inner-slider").slick({
			slidesToShow:7,
		  slidesToScroll: 1,
		  arrows: false,
		  vertical:true,
		 
		});*/
		
			
	}
}
function initNewsletter(){
	
	$("#form-subscrible").submit(function(){
		$form = $(this);
		if(!$form.hasClass("sending")){
			!$form.addClass("sending");
			btn = $(this).find("button:submit");
			btn.button('loading');
			$.ajax({
				url:"ajax/newsletter.html",
				data:$form.serialize(),
				type:"post",
				success:function(){
					!$form.removeClass("sending");
					alert("Đăng ký nhận bản tin thành công!");
					$form.trigger("reset");
					btn.button('reset');
				}
			})
		}
		return false;
	})
}
function initVideoListCarousel(){
	if($(".video-list-carousel").length){
		$(".video-list-carousel").owlCarousel({
			loop:true,
			margin:10,
			nav:false,
			responsiveClass:true,
			responsive:{
				0:{
					items:3,
					
				},
				600:{
					items:3,
				
				},
				1000:{
					items:3,
					
				}
			}
		})
		$(".video-list-carousel .item a").click(function(){
			$id = $(this).data("id");
			$target = $(".video-list-carousel-target").find("iframe");
			$target.attr("src","http://www.youtube.com/embed/"+$id+"?autoplay=1");
			return false;
		})
		
/*		$(".wrap-list-photo ul").bxSlider({
			
			captions: true,
			auto:true,
			pause:5000,
			pager:false,
		})*/
	}
}
function initLogo(){
	if( $("#flexiselDemo3").length){
	 $("#flexiselDemo3").flexisel({
				visibleItems:6,
				animationSpeed: 1000,
				autoPlay: true,
				autoPlaySpeed: 3000,            
				pauseOnHover: true,
				enableResponsiveBreakpoints: true,
				
			});
			setTimeout(function(){
				$("#logo-partne .nbs-flexisel-nav-left").append('<i class="fa fa-angle-left fa-2x" aria-hidden="true"></i>');
				$("#logo-partne .nbs-flexisel-nav-right").append('<i class="fa fa-angle-right fa-2x" aria-hidden="true"></i>');
				
			$(".nbs-flexisel-nav-left,.nbs-flexisel-nav-right").append("<div class='append'></div>");
			},1000);
	}
}
function initIndexHotline(){
	if($(".has-list-p").length){
		$(".has-list-p").each(function(){
			$w = $(this).find(".list").width()+10;
			$(this).find(".xhotline").width($w);
		})
	}
}
function initPopup(){
	
			$(".fancy-popup").fancybox({padding:0,margin:0,wrapCSS:"defaul"});
			setTimeout(function(){$(".fancy-popup").click();},500);
	
	
	
	
}
function fixToManager(){
								if($("#fix-to").length){
									
									$('.box-left-detail').fixTo('#content-center', {top:55});	 
								}
								
								
								  var sync2 = $("#sync2");
								 if(sync2.length){
									 
									 
								 $('#more-product').fixTo('#content-center');	 
							}
							initPorudctDetail();
							function initProduct(){
								
								if(!sync2.length){
								return;
								}
								
									 
								 
								  var slidesPerPage = 4; //globaly define number of elements per page
								  var syncedSecondary = true;

	
								  sync2
									.on('initialized.owl.carousel', function () {
									  sync2.find(".owl-item").eq(0).addClass("current");
									})
									.owlCarousel({
									items : slidesPerPage,
									dots: true,
									nav: false,
									smartSpeed: 200,
									slideSpeed : 500,
									slideBy: slidesPerPage, //alternatively you can slide by 1, this way the active slide will stick to the first item in the second carousel
									responsiveRefreshRate : 100
								  }).on('changed.owl.carousel', syncPosition2);

								
								  
								  function syncPosition2(el) {
									if(syncedSecondary) {
									  var number = el.item.index;
									  sync2.find(".owl-item").removeClass("current");
									  sync2.find(".owl-item").eq(number).addClass("current");
									  refreshImage();
									}
								  }
								  
								  sync2.on("click", ".owl-item", function(e){
									e.preventDefault();
									var number = $(this).index();
									sync2.find(".owl-item").removeClass("current");
									$(this).addClass("current");
									refreshImage();
									
								  });
								
								
								 function refreshImage(){
									  $href = sync2.find(".owl-item.current").find("a").attr("href");
									  $thumb = sync2.find(".owl-item.current").find("a").data("thumb");
									  $("#main-image a").attr("href",$href);
									  $("#main-image img").attr("src",$thumb);
									  $("#m-x a").attr("data-fancybox","quick-view");
									  $("#m-x a[href='"+$href+"']").removeAttr("data-fancybox");
								 }
								refreshImage();
								$(".quick_view").fancybox({
									baseClass	: 'quick-view-container',
									infobar		: false,
									buttons		: true,
									thumbs		: false,
									margin      : 0,
									touch       : {
										vertical : false
									},
									closeClickOutside : true,
									baseTpl : '<div class="fancybox-container" role="dialog">' +
												'<div class="quick-view-content">' +
													'<div class="quick-view-carousel">' +
														'<div class="fancybox-slider-wrap"><ul class="fancybox-slider"></ul></div>' +
													'</div>' +
													//'<div class="quick-view-aside"></div>' +
													'<button data-fancybox-close class="quick-view-close">X</button>' +
												'</div>' +
											'</div>',

									onInit : function( instance ) {

										/*

											#1 Create bullet navigation links

										*/

										var bullets = '<ul class="quick-view-bullets">';

										for ( var i = 0; i < instance.group.length; i++ ) {
											bullets += '<li><a data-index="' + i + '" href="javascript:;"><span>' + ( i + 1 ) + '</span></a></li>';
										}

										bullets += '</ul>';

										$( bullets ).on('click touchstart', 'a', function() {
												var index = $(this).data('index');

												$.fancybox.getInstance(function() {
													this.jumpTo( index );
												});

											})
											.appendTo( instance.$refs.container.find('.quick-view-carousel') );


										/*

											#2 Add product form

										*/

										var $element = instance.group[ instance.currIndex ].opts.$orig;
										var form_id = $element.data('qw-form');

										instance.$refs.container.find('.quick-view-aside').append(

											// In this example, this element contains the form
											$( '#' + form_id ).clone( true ).removeClass('hidden')
										);

									},

									beforeMove : function( instance ) {

										/*
											Set active current navigation link
										*/

										instance.$refs.container.find('.quick-view-bullets')
											.children().removeClass('active')
											.eq( instance.currIndex ).addClass('active');

									}

								});
							
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								 }
								 initProduct();
function initPorudctDetail(){
	
	if($("#product-detail").length){
		
		
		
		
		
		
		
		
		
		
		
		
						    
							
							$("#qty").change(function(){
								if(!parseInt($(this).val(), 10)){
										$(this).val(1);									
								}
								if(parseInt($(this).val()) < 1){
									$(this).val(1);
								}
							})
							$(".tab-category li a").click(function(){
								$(".tab-category li").removeClass("active");
								$id = $(this).attr("href");
								$(this).parent().addClass("active");
								$(".tab-category .tab").hide();
									$(".tab-category .tab").removeClass("active");
									$(".tab-category .tab"+$id).show().addClass("active");				
									
								return false;
							})
							
							
							
							
							
							
							
								
								
								
								
								
								
								
								
			/*$("#carousel").bxSlider({
				
			
				slideMargin: 5,
				minSlides:5,
				maxSlides:5,
				moveSlides:1,
				slideWidth:($("#main-detail").width()/5),
				pager:0,
				
			});*/
			
			
			
			
			
							}
						
							$(".color_item").click(function(){
								$(".color_item").removeClass("active");
								$(this).addClass("active");
								refreshImage(eval("color_image_"+$(this).data("id")));
								
							})
							$(".size_item").click(function(){
								$(".size_item").removeClass("active");
								$(this).addClass("active");
								
							})
							
							function refreshImage($image){
					
					if($image.length > 0){
						first = false;
						$str = '';
						$.each($image,function(index,item){
							if(!index){
							first = item;
							}
							$str+='<li><a href="#" data-image="<?=$config_url?>'+item+'" data-zoom-image="<?=$config_url?>'+item+'"><img id="img_01" src="<?=$config_url?>'+item+'" /> </a></li>';
							
							
						})
						$strx= '<div class="wrap-on-image"><img id="img_01" class="img-thumbnail" src="<?=$config_url?>'+first+'" data-zoom-image="<?=$config_url?>'+first+'"/></div>';
						$strx+='<div id="gal1"><ul id="carousel" class="bx-slides">';
						$strx+=$str+"</ul></div>";
					$("#x_refesh").html($strx);
					
					}else{
						refreshImage(color_image_default);
						
						
					}
					
					$(".product-bx").bxSlider({
					minSlides:4,
					maxSlides:4,
					moveSlides:1,
					slideWidth:$("#main-detail").width()/4,
					pager:0,
					
				})
					
				
			}
							
							
						
	}
}
function googleFonts(){
	$.getScript("https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js",function(){
		WebFontConfig = {
		  google: {
			families: ['Roboto:300,400,500,700:latin,vietnamese']
		  }
		};
		
		 WebFont.load(WebFontConfig);
	})
	
}
function initShowLogo(){
	if($("footer .brand-wrap").length){
		$v = $("footer .brand-wrap");
		if($v.find("li").last().find(".item").length==1){
			$v.find("li").last().append($v.find("li").first().find(".item").last()[0].outerHTML);
		}
		$(".brand-wrap ul").owlCarousel({
			items:2,
			margin:12,
			loop:true,
			smartSpeed:700,
			navText:['<i class="fa fa-angle-left fa-2x" aria-hidden="true"></i>','<i class="fa fa-angle-right fa-2x" aria-hidden="true"></i>'],
			nav:true,
			autoplay:true,
		})
	}
}
function initMember(){
	
	$("#forgot-password-form").submit(function(){
		$f = $(this);
		$f.find(".alert").addClass("hide");
		$btn = $(this).find("button:submit");
		$btn.button("loading");
		$.ajax({
			url:"thanh-vien/reset-password.html",
			data:$f.serialize(),
			type:"post",
			dataType:"json",
			error:function(){
				$btn.button("reset");
				showAlert(_lang.error.system);
				$.fancybox.close();
			},
			success:function(data){
				if(!data.status){
					$f.find(".alert-danger").html(data.message).removeClass("hide");
				}else{
					$f.find(".alert-success").html(data.message).removeClass("hide");
					setTimeout(function(){
						$f.trigger("reset");
						$.fancybox.close();
					},5000);
				}
				$btn.button("reset");
			}
			
		})
		return false;
	})
	
	$("#create_customer").submit(function(){
		$sub = false;
		$(this).find("input.required").each(function(){
			if(!$(this).val()){
				$(this).next().removeClass("opa-0");
				$(this).next().addClass("opa-1");
				$(this).focus();
				$(this).unbind("keypress");
				$(this).keypress(function(){
					$(this).next().removeClass("opa-1");
					$(this).next().addClass("opa-0");
				})
				return false;
			}
			$for = $(this).data("for");
			if($for!=undefined){
				$old_val = $("input"+$for).val();
				if($val!=$old_val){
					$(this).next().removeClass("opa-0");
					$(this).next().addClass("opa-1");
					$(this).unbind("keypress");
					$(this).keypress(function(){
						if($(this).val()==$old_val){
							$(this).next().removeClass("opa-1");
							$(this).next().addClass("opa-0");
						}
					})
					return false;
				}
			}
			
			
		})
		return $sub;
	})
	
	
	
	
	$("#create_customer").submit(function(){
		$sub = false;
		$(this).find("input.required").each(function(){
			if(!$(this).val()){
				$(this).next().removeClass("opa-0");
				$(this).next().addClass("opa-1");
				$(this).focus();
				$(this).unbind("keypress");
				$(this).keypress(function(){
					$(this).next().removeClass("opa-1");
					$(this).next().addClass("opa-0");
				})
				return false;
			}
			$for = $(this).data("for");
			if($for!=undefined){
				$old_val = $("input"+$for).val();
				if($val!=$old_val){
					$(this).next().removeClass("opa-0");
					$(this).next().addClass("opa-1");
					$(this).unbind("keypress");
					$(this).keypress(function(){
						if($(this).val()==$old_val){
							$(this).next().removeClass("opa-1");
							$(this).next().addClass("opa-0");
						}
					})
					return false;
				}
			}
			
			
		})
		return $sub;
	})
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}


$().ready(function() {
	
	
	
	
	
	
	
	function fixNav2(){
		$(".main-menu-nav").each(function(){
			if(1!=1){//$(this).parents(".nav-fixed-scroll").length){
				$pa = $(this).height();
				console.log($pa);
						
					
			}else{

				$x = $(this).offset().top+$(this).height();
				$(this).find("ul li").each(function(){
					$off = $(this).offset().top;
					$tar = $(this).find("ul").first();
					//$tar.find("li a").html($off+" "+$x);
					//	$(this).find("li a").html($off+$tar.height()+"-----"+$x);
					if($off+$tar.height() > $x){
					
						$tar.css({top:"-"+($tar.height()-(($x-$off)))+"px"});
					}
					
				})
		}
		})
		
		
	}
	setInterval(function(){
		if($(window).width() > 768){
			fixNav2();
		}
	},400);
	
	
	
	
	
	$(".top-menu-rev .title span").click(function(){
		//$(this).parent().find("ul").slideToggle();
		//return false;
	})
	$(".owl-x-visible").owlCarousel({
			loop:false,
			margin:0,
			nav:false,
			
			responsiveClass:true,
			responsive:{
				0:{
								items:3,
								
							},
							
							380:{
								items:3,
								
							},
							780:{
								items:3,
								
							},
							
			}
		})
	
	$("#quan").change(function(){
		$val = $(this).val();
		$phi = parseInt($("#quan option[value='"+$val+"'").data("price"));
		if(isNaN($phi)){
			$phi = 0;
		}
		$def = parseInt($("#price-defalt").data("price"));
		$("#phivanchuyen .bold").html(numberFormat($phi));
		
		
		
		
		$("#phaitra span.bold").html(numberFormat($def+$phi));
		
	})
	
	
	$("select#thanhpho").change(function(){
		console.log("x2");
		$quan = $("#quan");
		$quan.find("option:not(:first)").remove();
		if($(this).val()){
			$data = eval("provin_"+$(this).val());
			$id = parseInt($("#quan").data("id"));
			$.each($data,function(index,item){
				$slt = (item.id==$id) ? 'selected' : '';
				$quan.append("<option data-price="+item.price+" value='"+item.id+"' "+$slt+">"+item.type+" "+item.name+"</option>");
			})
		}
		$quan.trigger("change");
	})
	$("select#thanhpho").trigger("change");
	
	
	
	
	
	$(".top-menu-rev.inner-menu .title").click(function(){
		$(this).next().slideToggle();
	})
	
	
	
	initMember();
	fixToManager();
	initShowLogo();
	googleFonts();
	
	initPopup();
	initIndexHotline();
	initLogo();
	initRpMenu();
	initVideoListCarousel();
	initSearchForm();
    controlProductQty();
    setKeyPress();
	initIndex();
	initSlider();
	initNewsletter();
    //loadCus();
	setHeaderFixed();
	//setHeaderHotline();
})


function loadCus() {
    $("#email_sub").keyup(function() {
        loadCustomerInfo($(this));
    })
    $("#email_sub").change(function() {
        loadCustomerInfo($(this));
    })
}

function loadCustomerInfo($obj) {
    if ($("#user_id").val() == '') {
        if (validateEmail($obj.val())) {
            initAjax({
                url: "ajax/load-customer-info.html",
                data: {
                    email: $obj.val()
                },
                dataType: "json",
                success: function(data) {
                    if (data.stt) {
                        $.each(data.data, function($k, $v) {
                            $object = $("#form-payment ." + $k + "_");
                            if ($k == "district") {
                                loadDistrict($(".province_"), $('#district-list'), $v);
                            }
                            $object.val($v);
                        })
                    }
                }
            });
        }
    }
}

function loadDistrict($this, $object, $mid) {
    $id = $this.val();
    if ($id) {
        initAjax({
            url: "ajax/load-district.html",
            data: {
                id: $id
            },
            dataType: "json",
            success: function(data) {
                $object.find("option:not(:first)").remove();
                $.each(data, function(i, item) {
                    $str = '';
                    if ($mid > 0) {
                        if (item.districtid == $mid) {
                            $str = "selected";
                        }
                    }
                    $object.append("<option value='" + item.districtid + "' " + $str + ">" + (item.type + " " + item.name) + "</option>");
                })
            }
        })
    }
}

function deleteCart(id) {
    if (confirm("Bạn có chắc chắn muốn xóa sản phẩm này?")) {
        NProgress.start();
        $("#content-center").animate({
            opacity: ".9"
        });
        initAjax({
            url: "ajax/delete-cart.html",
            data: {
                id: id
            },
            success: function(data) {
                refreshCart();
            }
        })
    }
}

function clearCart(id) {
    if (confirm("Bạn có chắc chắn muốn xóa tất cả sản phẩm?")) {
        NProgress.start();
        $("#content-center").animate({
            opacity: ".9"
        });
        initAjax({
            url: "ajax/clear-cart.html",
            success: function(data) {
                refreshCart();
            }
        })
    }
}

function clearCart() {
    if (confirm("Bạn có muốn xóa toàn bộ sản phẩm trong giỏ hàng?")) {
        $(".box_containerlienhe .content").animate({
            opacity: 0.6
        });
        $.post("gio-hang/clear.html", function(data) {
            $(".box_containerlienhe .content").html(data);
            $(".box_containerlienhe .content").animate({
                opacity: 1
            });
            updateCartNumber();
        })
    }
}

function setKeyPress() {
    $('.product-qty').keypress(function(e) {
        if (e.which == '13') {
            $(this).parents("tr").find("td").last().find("a:first").click();
        }
    });
}

function smoothScrolling() {
    try {
        $.browserSelector();
        if ($("html").hasClass("chrome")) {
            $.smoothScroll();
        }
    } catch (err) {}
}

function initOpenFormMember() {
    $(".open_form").click(function() {
        if (!$("#form_member").length) {
            $("body").append("<div id='form_member' class=''></div>");
        }
        $.post(base_url + "/thanh-vien/open-form.html", {
            type: $(this).data("type")
        }, function(data) {
            $("#form_member").html(data);
            $("#form_member").append("<a href='' data-toggle='modal' id='tg_modal' data-target='#regestration'>bcddddddd</a>")
            $("#tg_modal").click();
            return false;
        });
        return false;
    })
}

function validateEmail(email) {
    var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return re.test(email);
}

function initShowTooltip() {
    $('[data-toggle="tooltip"]').tooltip()
}
$().ready(function() {
	$(".global-title h1,.global-title h2,.global-title a,.title-global h1,.title-global h2,.title-global a").each(function(){
		$(this).html("<span>"+$(this).html()+"</span>");
	})
   // setRaty();
    $("a[rel=fancybox],.fancybox").fancybox();
    //checkImageError();
    initBackToTop();
   // setList();
   // initOpenFormMember();
   // initMenu();
   // initQuickView();
   // initShowTooltip();
   // resetEmptyContent();
    $(window).resize(function() {
		//	$("body").css({paddingTop:$("header").height()});
		//setHeaderHotline();
	
     //   initMenu();
     //   setList();
     //   resetEmptyContent();
    })
})
function setHeaderHotline(){
	if($(window).width() > 767){
		$("header .hotline .inner").css({width:"auto","display":"block"});
	}else{
		$("header .hotline .inner").css({display:"inline-block","width":"auto"});
		$w = $("header .hotline .inner").outerWidth()+50;
		
		$("header .hotline .inner").css({width:$w,'margin':'auto',display:"inherit"});
	}
}
function doAddCartSimple($obj) {
    doAddCart($obj.parents(".item-product").data("name"), $obj.parents(".item-product").data("id"), 1, 0, 0);
    return false;
}

function doAddCart($name, $id, $qty, $color, $size,$show,$type) {
	$show = true;
    NProgress.start();
    initAjax({
        url: "ajax/add-cart.html",
        data: {
            id: $id,
            qty: $qty,
            color: $color,
            size: $size,
			show:$show,
			type:$type,
        },
		dataType:'json',
        success: function(data) {
            $(".num-cart").html(data.qty);
            showMsg("success", "Thêm sản phẩm " + $name + " vào giỏ thành công");
            NProgress.done();
			if($show){
				
				if($("#cartModal").length){
					$o = $("#cartModal");
					$o.find(".item-name").html(data.item.name);
					$o.find(".cart-img").html("<a href='"+data.item.url+"'><img src='"+data.item.photo+"'></a>");
					$o.find(".item-price").html(numberFormat(data.item.price));
					if(data.item.old_price){
						$o.find(".item-old-price").removeClass("hide");
						$o.find(".item-old-price").find(".txt-line-through").html(numberFormat(data.item.old_price));
						$o.find(".item-old-price").find(".s-discount").html(Math.round((1-(data.item.price/data.item.old_price))*100));
					}else{
						$o.find(".item-old-price").addClass("hide");
					}
					$o.find(".txt-light-blue").html("("+data.qty+" sản phẩm)");
					$o.find(".sub-total").html(numberFormat(data.price));
					if(".item-old-price")
				 $('#cartModal').modal('show');
				}
			}
			//window.location.href='thanh-toan.html';
        }
    })
    return false;
}

function addCart() {
    $("#add-cart").click(function() {
		
        $color = 0;
        $size = 0;
        $id = $(this).data("id");
        $qty = parseInt($("#qty").val());
		$type =$("#price-type").val();
		if(!$type){
			$type = 1;
		}
		
        if ($(".pick-color").length) {
             if ($(".pick-color select").val()  > 0) {
                $color = $(".pick-color select").val();
            } else {
                showMsg("warning", "Vui lòng chọn màu cho sản phẩm!");
               
                return false;
            }
        }
        if ($(".pick-size").length) {
            if ($(".pick-size select").val() > 0) {
                $size = $(".pick-size select").val();
            } else {
                showMsg("warning", "Vui lòng chọn size cho sản phẩm!");
                
                return false;
            }
        }

        doAddCart($(this).data("name"), $id, $qty, $color, $size,true,$type);
        return false;
    });
}
function cartInit(){
	
	$(".payment input").click(function(){
			$(".payment .desc-payments").addClass("hide");
			$(".payment .desc-"+$(this).val()).removeClass("hide");
		})
		
		
		$(".bill_form input").keyup(function(){
				if($("input[name=same-address]").is(":checked")){
				$id = $(this).attr("id");
				
				$val = $(this).val();
				$(".receive_form #"+$id).val($val);
				}
			})
			$("input[name=same-address]").change(function(){
				$(".bill_form input").trigger("keyup");
			})
			//$("input[name=same-address]").trigger("click");
			/*$(".trans-type input").click(function(){
				NProgress.start();
				$price = $(this).data("price");
				$.ajax({
					url:"ajax/update-transtype.html",
					data:{price:$price,id:$(this).val()},
					type:"post",
					dataType:"json",
					success:function(data){
						$(".total_cart_max .all-price .price").html(data.price);
						$(".total_cart_max .all-ship .price").html(data.ship);
						$(".total_cart_max .all-price-all .price").html(data.all);
						NProgress.done();
						
					}
				})
			})
			if($(".trans-type").length){
			$(".trans-type input").first().trigger("click");
			}*/
	
}
$().ready(function() {
	addCart();
	cartInit();
	$(".add-to-cart").click(function(){
		doAddCart($(this).data("name"), $(this).data("id"), 1,0,0);
		return false;
	})
    if ($(".product-bx").length) {
        $(".product-bx").bxSlider({
            minSlides: 4,
            maxSlides: 4,
            moveSlides: 1,
            slideWidth: $("#main-detail").width() / 4,
            pager: 0,
        })
    }
    if ($(".product-image-list #list-image").length) {
        $(".product-image-list #list-image").owlCarousel({
            items: 4,
            itemsDesktop: [1000, 4],
            itemsDesktopSmall: [900, 4],
            itemsTablet: [600, 4],
            itemsMobile: false,
            navigation: false
        });
    }
    $("#qty").change(function() {
        if (!parseInt($(this).val(), 10)) {
            $(this).val(1);
        }
        if (parseInt($(this).val()) < 1) {
            $(this).val(1);
        }
    })
    $(".tab-category li a").click(function() {
        $(".tab-category li").removeClass("active");
        $id = $(this).attr("href");
        $(this).parent().addClass("active");
        $(".tab-category .tab").fadeOut(function() {
            $(".tab-category .tab").removeClass("active");
            $(".tab-category .tab" + $id).fadeIn().addClass("active");
        })
        return false;
    })
    $(".tab-nav li").click(function() {
        $(this).find("a").click();
    })
   
})

function initDescHeight() {
    if ($("#product-detail").length) {
        $h = $("#product-detail .desc-place .wrap").height();
        if ($h > 200) {
            $("#product-detail .desc-place").css({
                "overflow-y": "scroll"
            });
        }
        $("#product-detail .desc-place").css({
            visibility: "visible"
        });
    }
}

function compareProduct($obj) {
    NProgress.start();
    $name = $obj.parents(".item-product").data("name");
    $id = $obj.parents(".item-product").data("id");
    showProductCompare(-200);
    initAjax({
        url: "ajax/add-compare.html",
        data: {
            id: $id
        },
        dataType: "json",
        success: function(data) {
            console.log(data);
            if (data.stt == 1) {
                showProductCompare(0);
            } else {
                showProductCompare(0);
                showMsg("error", "Đã có 4 sản phẩm so sánh!");
            }
            NProgress.done();
            setTimeout(function() {
                showProductCompare(-200);
            }, 5000);
        }
    })
    return false;
}

function removeCompare($obj) {
    showProductCompare(-200);
    $.post("ajax/remove-compare.html", {
        id: $obj.data("id")
    }, function() {
        showProductCompare(0);
    })
}

function showProductCompare($px) {
    if ($px < 0) {
        $("#compare-product").animate({
            "right": $px + "px"
        });
    } else {
        $.post('ajax/get-compare.html', function(data) {
            $("#compare-product .inner").html(data);
            $("#compare-product").animate({
                "right": $px + "px"
            });
            updateCartNumber();
        })
    }
}

function ShowNotify($msg, $type) {
    var t;
    $cls = "error";
    if ($type == 1) {
        $cls = "success";
    }
    if (!$("body").find(".alert-box-container").length) {
        $("body").append("<div class='alert-box-container'></div>");
    }
    $clss = Math.floor((Math.random() * 999999) + 1);
    $msg = "<div class='cl_" + $clss + " " + $cls + "-box alert-box' style='opacity:0'> <div class='msg'>" + $msg + "</div> <p><a class='toggle-alert' href='#'>Toggle</a></p> </div>";
    $(".alert-box-container").append($msg);
    $(".cl_" + $clss).animate({
        opacity: 1
    });
    setTimeout(function() {
        $(".alert-box-container .alert-box").first().slideUp(function() {
            $(".alert-box-container .alert-box").first().remove();
        })
    }, 2000);
    $(".alert-box-container .toggle-alert").click(function() {
        $(this).parents(".alert-box").slideUp(function() {
            $(this).parents(".alert-box").remove();
        });
        return false;
    });
}

function initOpenFormMember() {
    $(".open_form").click(function() {
        if (!$("#form_member").length) {
            $("body").append("<div id='form_member' class=''></div>");
        }
        $.post(base_url + "/thanh-vien/open-form.html", {
            type: $(this).data("type")
        }, function(data) {
            $("#form_member").html(data);
            $("#form_member").append("<a href='' data-toggle='modal' id='tg_modal' data-target='#regestration'></a>")
            $("#tg_modal").click();
            return false;
        });
        return false;
    })
}

function intializePopover(option) {
    option = $.extend({
        ele: "",
        title: "Lỗi",
        content: "",
    }, option);
    option.ele.popover({
        'placement': 'top',
        title: option.title,
        content: option.content
    }).show();
    option.ele.popover('show')
    option.ele.click(function() {
        $(this).popover('hide');
    })
    $(document).on('click', function(event) {
        option.ele.popover('destroy')
    });
    option.ele.focus();
}
var $t;

function delorder_gh(id) {
    if (confirm("Bạn có chắc chắn muốn xóa sản phẩm này?")) {
        NProgress.start();
        initAjax({
            url: "ajax/delete-cart.html",
            data: {
                id: id
            },
            dataType: "json",
            success: function(data) {
                NProgress.done();
                updateCartNumber();
                $("#gio_hang_sp_" + id).animate({
                    height: 0,
                    opacity: 0
                }, function() {
                    $(this).remove();
                    $("#gio_hang_tong").html(data.total);
                    if (data.qty == 0) {
                        $(".empty-cart").removeClass("hide");
                        $(".cart-enter, p.total").hide();
                    }
                })
            }
        })
    }
    return false;
}

function showCartMini() {
    initAjax({
        url: "ajax/view-mini-cart.html",
        dataType: 'json',
        success: function(data) {
            clearTimeout($t);
            $("#cart_mini ul").html(data.data);
            $("#gio_hang_tong").html(data.total);
            $("#cart_mini").stop().animate({
                right: "0%"
            }, 1000);
            $(".mini-cart-title").fadeOut();
            $t = setTimeout(function() {
                $("#cart_mini").stop().animate({
                    right: "-370px"
                }, 1000, function() {
                    $(".mini-cart-title").fadeIn();
                });
            }, 6000);
        }
    })
}

function hideCartMini() {
    $("#cart_mini").animate({
        right: "-370px"
    }, 1000, function() {
        $(".mini-cart-title").fadeIn();
    });
}
$().ready(function() {
    $("#cart_mini .close").click(function() {
        $("#cart_mini").animate({
            right: "-370px"
        }, 1000, function() {
            $(".mini-cart-title").fadeIn();
        });
    })
    $(".mini-cart-title").click(function() {
        showCartMini();
    })
})

var isMobile = window.matchMedia("only screen and (max-width: 760px)");

if (isMobile.matches) {
    $(".wow").addClass("xvisible");
}