var DORTHEME = {
	idShop:(typeof DOR != "undefined" && typeof DOR.id_shop != "undefined" && DOR.id_shop != null)?DOR.id_shop:1,
	checkLoad:0,
	init:function(){
		window.addEventListener('load', function (){
		    $(".dor-page-loading").remove();
		});
		
		DORTHEME.ScrollTop();
		DORTHEME.SortCateProduct();
		DORTHEME.MoveTitlePage();
		DORTHEME.ToggleSearch();
		DORTHEME.ToolTipBootstrap();
		DORTHEME.QuickViewAct();
		DORTHEME.AboutUsListUser();
		DORTHEME.EventSite();
		DORTHEME.ResizeCategoryWindow();
		DORTHEME.ShowDisplay();
		DORTHEME.RebuildShowDisplay();
		DORTHEME.AboutSayClient();
		DORTHEME.CheckCmsPage();
		DORTHEME.MiniCartV2();
		DORTHEME.RemoveItemMiniCart();
		//DORTHEME.MoveLogo();
		DORTHEME.DorQuantity();
		DORTHEME.LoadMoreList();
		if(parseInt($( window ).width()) <= 991){
			DORTHEME.checkLoad = 1;
			DORTHEME.MobileEventHeader();
		}
		$( window ).resize(function() {
			if(parseInt($( window ).width()) <= 991 && DORTHEME.checkLoad == 0){
				DORTHEME.MobileEventHeader();
			}
		});
		if (jQuery(".scroll-div").length) {
            jQuery(".scroll-div").mCustomScrollbar({
                theme: "dark-2",
                scrollButtons: {
                    enable: false
                }
            });
        }

        if (jQuery(".miniCartv2 #cart-mini-content-lists").length) {
            jQuery(".miniCartv2 #cart-mini-content-lists").mCustomScrollbar({
                theme: "dark-2",
                scrollButtons: {
                    enable: false
                }
            });
        }
		if (jQuery("header:not(.miniCartv2) .minicart-product-lists").length) {
            jQuery("header:not(.miniCartv2) .minicart-product-lists").mCustomScrollbar({
                theme: "dark-2",
                scrollButtons: {
                    enable: false
                }
            });
        }
	},
	MobileEventHeader:function(){
		jQuery(".nav-setting-button").click(function(){
			var checkOpen1 = $(this).closest(".dor-block-selection").hasClass("open");
			if(!checkOpen1){
				$(this).closest(".dor-block-selection").addClass("open");
			}else{
				$(this).closest(".dor-block-selection").removeClass("open");
			}
		});


		jQuery(document).click(function (event) {
            if (!jQuery(event.target).is(".nav-setting-button, .dor-block-selection *")) {
                jQuery(".dor-block-selection").removeClass("open");
            }
        });


        jQuery(".user-info.selection-options-wrapper > .line-selected").click(function(){
			var checkOpen2 = $(this).closest(".user-info.selection-options-wrapper").hasClass("open");
			if(!checkOpen2){
				$(this).closest(".user-info.selection-options-wrapper").addClass("open");
			}else{
				$(this).closest(".user-info.selection-options-wrapper").removeClass("open");
			}
		});


		jQuery(document).click(function (event) {
            if (!jQuery(event.target).is(".user-info.selection-options-wrapper.open *")) {
                jQuery(".user-info.selection-options-wrapper").removeClass("open");
            }
        });
	},
	LoadMoreList:function(){
		jQuery(".load-more-data").click(function(){
			jQuery(".next.js-search-link").click();
		});
	},
	DorQuantity:function(){
		$('.dor_quantity_wanted').unbind("change");
		$('.dor_quantity_wanted').TouchSpin({
	      verticalbuttons: true,
	      verticalupclass: 'material-icons touchspin-up',
	      verticaldownclass: 'material-icons touchspin-down',
	      buttondown_class: 'btn btn-touchspin js-touchspin',
	      buttonup_class: 'btn btn-touchspin js-touchspin',
	      min: 1,
	      max: 1000000
	    });
	},
	EventSite:function(){
		var idObjPage = jQuery("body").attr("id");
		if(idObjPage == "category" || idObjPage == "authentication" || idObjPage == "password" || idObjPage == "module-dorblockwishlist-dorwishlist"){
			if(parseInt($( window ).width()) <= 991){
			  	jQuery("#left-column").detach().insertAfter('#content-wrapper');
			}
			DORTHEME.ResizeCategoryWindow();
		}

		var headerfloat = localStorage.getItem("optionHeaderFloat-Shop"+DORTHEME.idShop);
		if((typeof DOR != "undefined" && typeof DOR.dorFloatHeader != "undefined" && parseInt(DOR.dorFloatHeader) == 1 && headerfloat == null) || (headerfloat != null && parseInt(headerfloat) == 1)){
			DORTHEME.ScrollFixedMenu();
		}
		
		if((typeof DOR != "undefined" && typeof DOR.dorSubscribe != "undefined" && parseInt(DOR.dorSubscribe) == 1)){
			var localStorPopup = localStorage.getItem("popupScrAgain-"+DORTHEME.idShop);
	        if(localStorPopup == null && parseInt(localStorPopup) != 1 && typeof sessionStorage['popupScr-'+DORTHEME.idShop] == "undefined" && sessionStorage['popupScr-'+DORTHEME.idShop] != 1){
	        	DORTHEME.ShowPopupScre();
	        }
	        if(typeof sessionStorage['popupScr-'+DORTHEME.idShop] == "undefined" && sessionStorage['popupScr-'+DORTHEME.idShop] != 1){
	        	sessionStorage['popupScr-'+DORTHEME.idShop] = 1;
	        }
	        jQuery("input[name='notShowSubs']").change(function(){
	        	if($(this).is(':checked')){
	        		localStorage.setItem("popupScrAgain-"+DORTHEME.idShop,1);
	        	}else{
	        		localStorage.removeItem("popupScrAgain-"+DORTHEME.idShop);
	        	}
	        });
        }

		jQuery(".nav-group > button").click(function(){
			var checkopen = jQuery(".main-data-nav-setting").hasClass("open");
			if(!checkopen){
				jQuery(".main-data-nav-setting").addClass("open");
			}else{
				jQuery(".main-data-nav-setting").removeClass("open");
			}
		});
		jQuery(document).click(function (event) {
            if (!jQuery(event.target).is(".nav-group > button, .main-data-nav-setting *")) {
                jQuery(".main-data-nav-setting").removeClass("open");
            }
        });
	},
	MoveLogo:function(){
		var checkLengthMenu = jQuery('#dor-top-menu > .nav.navbar-nav.megamenu > li').length;
		var posLogo = Math.ceil(checkLengthMenu/2);
		if(parseInt($( window ).width()) >= 992){
			var html = jQuery(".h1-logo").detach().html();
			html = '<li class="dorfix-logo">'+html+'</li>';
			jQuery(html).insertAfter('#dor-top-menu > .nav.navbar-nav.megamenu > li:nth-child('+posLogo+')');
		}

		$( window ).resize(function() {
		  var widthW = $( window ).width();
		  var posLogo = Math.ceil(checkLengthMenu/2);
		  var checkpage = jQuery("body").attr("id");
		  if(checkpage != "checkout"){
			  if(parseInt(widthW) <= 991){
			  	var checkFixLogo = jQuery(".h1-logo").html();
			  	var checkPage = jQuery("body").attr("id");
			  	var html = jQuery(".dorfix-logo").detach().html();
			  	if(jQuery.trim(checkFixLogo) == ""){
				  	jQuery(".h1-logo").remove();
				  	if(checkPage != "index"){
				  		html = '<div class="h1-logo no-margin">'+html+'</div>';
				  	}else{
				  		html = '<h1 class="h1-logo no-margin">'+html+'</h1>';
				  	}
				  	jQuery("#_desktop_logo").html(html);
			  	}
			  }else{
			  	var checkFixLogo = jQuery(".dorfix-logo").html();
			  	if(jQuery.trim(checkFixLogo) == ""){
				  	jQuery(".dorfix-logo").remove();
				  	var html = jQuery(".h1-logo").detach().html();
					html = '<li class="dorfix-logo">'+html+'</li>';
					jQuery(html).insertAfter('#dor-top-menu > .nav.navbar-nav.megamenu > li:nth-child('+posLogo+')');
			  	}
			  }
		  }
		});
	},
	SortCateProduct:function(){
		jQuery("body").on("click",".products-sort-order .select-title",function(){
			var checkShow = jQuery(".products-sort-order").hasClass("show-sort-order");
			if(!checkShow)
				jQuery(".products-sort-order").addClass("show-sort-order");
			else
				jQuery(".products-sort-order").removeClass("show-sort-order");
			return false;
		});
		jQuery("body").on("click",".select-list.js-search-link",function(){
			var title = jQuery(this).text();
			setTimeout(function(){
				jQuery(".products-sort-order .select-title").text(title);
			},2000);
		});
		jQuery(document).click(function (event) {
            if (!jQuery(event.target).is(".products-sort-order .select-title, .products-sort-order .select-title *, .products-sort-order .dropdown-menu, .products-sort-order .dropdown-menu *")) {
                jQuery(".products-sort-order").removeClass("show-sort-order");
            }
        });
	},
	MoveTitlePage:function(){
		var checkpage = jQuery("body").attr("id");
		if(typeof checkpage != "undefined" && checkpage != "index"){
			var titlePage = "<h1>";
				titlePage += "";
			var titleCate = jQuery("h1.h1").first().text();
			if(checkpage == "authentication" || checkpage == "password" || checkpage == "my-account" || checkpage == "identity" || 
			checkpage == "addresses" || checkpage == "address" || checkpage == "order-slip" || checkpage == "discount" || checkpage == "history" ){
				titleCate = jQuery(".page-header > h1").first().text();
				jQuery(".page-header > h1").remove();
			}
			if(checkpage == "search"){
				titleCate = jQuery("#main > h2.h2").first().text();
			}
			if(typeof titleCate != "undefined"){
				titlePage += titleCate;
			}
			if(checkpage == "product"){
				titlePage += jQuery(".h1.product-name-detail").first().text();
			}
			if(checkpage == "cms"){
				titlePage += jQuery(".page-header > h1").first().text();
				jQuery("header.page-header").remove();
			}
			if(checkpage == "order-confirmation"){

				titlePage += jQuery(".h1.card-title > span").first().text();
			}
			titlePage += "</h1>";
			jQuery("#title-page-show").html(titlePage);
			if(checkpage != "product"){
				jQuery("h1.h1").remove();
			}
			
		}

	},
	ShowDisplay:function(){
		$('body').on('click','.dor-display-cate a', function( event ) {
			event.preventDefault();
			var objId = jQuery(this).attr("data-id");
			localStorage.removeItem("dorDisplay-"+DORTHEME.idShop);
			localStorage.setItem("dorDisplay-"+DORTHEME.idShop,objId);
			var style = 1;
			var checkStyle = jQuery("body").hasClass("dorHoverProduct2");
			if(checkStyle) style = 2;
			DORTHEME.DisplayAct(objId,style);
		});
		
	},
	DisplayAct:function(objId,style){
		jQuery(".dor-display-cate a").removeClass("active");
		jQuery(".dor-display-cate a[data-id='"+objId+"']").addClass("active");
		if(objId == "list"){
			if(style == 2){
				jQuery("#js-product-list article.product-miniature").addClass("dor-list-display");
				jQuery("#category article.product-miniature").each(function(){
					jQuery(this).find(".product-more-options").detach().insertAfter(jQuery(this).find('.right-block .product-description-short'));
					setTimeout(function(){
						$('[data-toggle="tooltip"]').tooltip();
					},1000);
				});
			}else{
				jQuery("#js-product-list article.product-miniature").addClass("dor-list-display");
				jQuery("#category article.product-miniature").each(function(){
					jQuery(this).find(".left-block .show-btn-products").detach().insertAfter(jQuery(this).find('.right-block .product-description-short'));
					jQuery(this).find(".left-block .dor-addcart-button").detach().insertAfter(jQuery(this).find('.right-block .product-description-short'));
					setTimeout(function(){
						$('[data-toggle="tooltip"]').tooltip();
					},1000);
				});
			}
			
			
		}else{
			if(style == 2){
				jQuery("#js-product-list article.product-miniature").removeClass("dor-list-display");
				jQuery("#category article.product-miniature").each(function(){
					jQuery(this).find(".right-block .product-more-options").detach().insertAfter(jQuery(this).find('.dor-display-product-info'));
					setTimeout(function(){
						$('[data-toggle="tooltip"]').tooltip();
					},1000);
				});
			}else{
				jQuery("#js-product-list article.product-miniature").removeClass("dor-list-display");
				jQuery("#category article.product-miniature").each(function(){
					jQuery(this).find(".right-block .show-btn-products").detach().insertAfter(jQuery(this).find('.left-block .product-image-container'));
					jQuery(this).find(".right-block .dor-addcart-button").detach().insertAfter(jQuery(this).find('.left-block .product-image-container'));
					setTimeout(function(){
						$('[data-toggle="tooltip"]').tooltip();
					},1000);
				});
			}
		}
	},
	RebuildShowDisplay:function(){
		var display = localStorage.getItem("dorDisplay-"+DORTHEME.idShop);
		if(display == null){
			if(typeof DOR != "undefined" && typeof DOR.dorCategoryShow != "undefined" && DOR.dorCategoryShow == "list"){
				display = "list";
			}else{
				display = "grid";
			}
		}
		var style = 1;
		var checkStyle = jQuery("body").hasClass("dorHoverProduct2");
		if(checkStyle) style = 2;
		DORTHEME.DisplayAct(display,style);
	},
	ToggleSearch:function(){
		jQuery(".nav-search-button button").click(function(e){
			e.preventDefault();
			jQuery(".dorHeaderSearch-Wapper").slideToggle(300,function(){
				if(jQuery(this).is(":hidden")){
					jQuery(".dorHeaderSearch-Wapper").removeClass("openSearch")
				}else{
					jQuery(".dorHeaderSearch-Wapper").addClass("openSearch")
					$("#dor_query_top").focus();
				}
			});
		});
		jQuery(document).click(function (event) {
            if (!jQuery(event.target).is(".dorHeaderSearch-Wapper, .dorHeaderSearch-Wapper *, .nav-search-button button, .nav-search-button button *")) {
                if(!jQuery(".dorHeaderSearch-Wapper").is(":hidden")){
                	jQuery(".dorHeaderSearch-Wapper").slideToggle(300,function(){});
                }
            }
        });
	},
	ToolTipBootstrap:function(){
		setTimeout(function(){
			$('[data-toggle="tooltip"]').tooltip();
		},1000);
	},
	QuickViewAct:function(){
		jQuery("body").on("click",".quickview .btn-group.bootstrap-select", function(){
			var checkShow = jQuery(this).find(".dropdown-menu").hasClass("showview");
			if(!checkShow){
				jQuery(this).find(".dropdown-menu").addClass("showview");
			}else{
				jQuery(this).find(".dropdown-menu").removeClass("showview");
			}
		});
	},
	AboutUsListUser:function(){
		$('.about-us-lists').owlCarousel({
	        items: 4,
	        loop: ($(this).find('.owl-item').length > 1) ? true : false,
	        nav: false,
	        autoplay: true,
	        margin:20,
	        responsive: {
	            0: {items: 1},
	            1500: {items: 4},
	            1200: {items: 4},
	            990: {items: 3},
	            767: {items: 2},
	            551: {items: 2},
	            320: {items: 1}
	        },
	        navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
	    });
	},
	ResizeCategoryWindow:function(){
		if(parseInt($( window ).width()) <= 991){
			jQuery(".cart-grid .blockproductscategory").detach().insertAfter('#cart .card.cart-summary');
		}
		$( window ).resize(function() {
		  var widthW = $( window ).width();
		  if(parseInt(widthW) <= 991){
		  	jQuery("#left-column").detach().insertAfter('#content-wrapper');
		  	jQuery(".cart-grid .blockproductscategory").detach().insertAfter('#cart .card.cart-summary');
		  }else{
		  	jQuery("#left-column").detach().insertBefore('#content-wrapper');
		  	jQuery(".cart-grid .blockproductscategory").detach().insertAfter('#cart .cart-grid-body > a.label');
		  }
		});
	},
	ScrollTop:function(){
		jQuery('.to-top').click(function () {
            jQuery('html, body').animate({scrollTop: 0}, 800);
            return false;
        });
        jQuery(window).scroll(function () {
		    if (jQuery(this).scrollTop() > 100) {
		        jQuery('.to-top').css({bottom: '20px'});
		    }
		    else {
		        jQuery('.to-top').css({bottom: '-50px'});
		    }

		});
	},
	ScrollFixedMenu:function(){
		var n = 90;
		var n1 = 100;
		$(window).bind('scroll', function() {
	     var navHeight = n;
	       if ($(window).scrollTop() > navHeight) {
	         $('#header').addClass('fixed');
	         var checkLogoFix = jQuery(".logoFixed").html();
	       }
	       else {
	         $('#header').removeClass('fixed');
	         $('#header').removeClass('fixed-tran');
	       }
	       if($(window).scrollTop() > n1) {
	       	$('#header').addClass('fixed-tran');
	       }
	       jQuery(".main-data-nav-setting").removeClass("open");
	    });
	},
	ShowPopupScre:function(){
		$('.subscribe-me').bPopup({
            speed: 450,
            transition: 'slideDown'
        });
	},
	AboutSayClient:function(){
		$('.aboutus-sayclient > ul').owlCarousel({
            items: 1,
	        loop: ($(this).find('.owl-item').length > 1) ? true : false,
	        navigation: true,
	        nav: true,
	        autoplay: true,
	        navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
        });
	},
	CheckCmsPage:function(){
		var checkPage = jQuery("#dor-aboutus-main").html();
		var checkPageCms = jQuery("#cms").html();
		if( typeof checkPageCms != "undefined" && typeof checkPage != "undefined"){
			jQuery("#cms").addClass("dor-page-cms");
		}

		jQuery("#accordion .panel-title > a").click(function(event){
			event.preventDefault();
			var objId = jQuery(this).attr("href");
			var checkHeight = jQuery(objId).height();
			var checkStatus = jQuery(objId).hasClass("in");
			if(!checkStatus){
				jQuery(".panel-collapse").removeClass("in");
				jQuery("#accordion .panel-title > a").find("i.add").removeClass("hidden");
				jQuery("#accordion .panel-title > a").find("i.remove").addClass("hidden");
				jQuery(this).find("i.add").addClass("hidden");
				jQuery(this).find("i.remove").removeClass("hidden");
				jQuery(objId).addClass("in");
			}else{
				jQuery(".panel-collapse").removeClass("in");
				jQuery(this).find("i.remove").addClass("hidden");
				jQuery(this).find("i.add").removeClass("hidden");
			}
			

		});
	},
	/******************************/

	RemoveItemMiniCart:function(){
		
		$("body").on("click","#cart-mini-content-lists .remove-from-cart",function(event){
			event.preventDefault();
			var reloadHtml = DORCORE.ReloadProcess();
			var _this = this;
			$(_this).closest("li").addClass("processRemove");
			$(_this).closest("li").append(reloadHtml);
			var quantity = 0;
			var totalQuantity = 0;
			totalQuantity = $(".blockcart.cart-preview .cart-products-count").text();
			quantity = $(this).closest("li").find(".product-quantity").text();
			if(typeof quantity != "undefined") quantity = parseInt(quantity.replace(/[^0-9]/g, ''));
			else quantity = 0;
			if(typeof totalQuantity != 'undefined') totalQuantity = parseInt(totalQuantity.replace(/[^0-9]/g, ''));
			else totalQuantity = 0;
			var urlAjax = $(this).attr("href");
			$.ajax(urlAjax, {
			  dataType: 'html',
			  context: {
			    url: urlAjax
			  }
			}).done(function(html) {
				$(_this).closest("li").remove();
				var regularPrice = $(html).find("#cart-subtotal-products .value").text();console.log("regularPrice=",regularPrice);
				var shipPrice = $(html).find("#cart-subtotal-shipping .value").text();console.log("shipPrice=",shipPrice);
				var taxPrice = $(html).find(".cart-detailed-totals .card-block > .cart-summary-line .value").text();console.log("taxPrice=",taxPrice);
				var totalPrice = $(html).find(".cart-summary-line.cart-total .value").text();console.log("totalPrice=",totalPrice);

				$('#header .header-nav .cart-preview .body .cart-subtotals > .products > .value').text(regularPrice);
				$('#header .header-nav .cart-preview .body .cart-subtotals > .shipping > .value').text(shipPrice);
				$('#header .header-nav .cart-preview .body .cart-total span.value').text(totalPrice);
				var regularQuantity = totalQuantity - quantity;
				$(".blockcart.cart-preview .cart-products-count").text(regularQuantity)
				var items = $("#header .minicart-product-lists li").length;
				if(typeof items != "undefined" && items <= 0 ){
					$(".no-item-cart-ajax").removeClass("hidden");
					$("body #header .header-nav .cart-preview .body").addClass("none-minicart");
				}
			});

		});
	},
	MiniCartV2:function(){
		$("body").on("click",".modal-backdrop.blockcart-modal-backdrop.fade.in",function(){
			$("#header.miniCartv2 #close-mini-cart").click();
			$(".modal-backdrop.blockcart-modal-backdrop.fade.in").remove();
			$("body").removeClass("closeModal");
		});
		$('body').on('click','#close-mini-cart', function( event ) {
			event.preventDefault();
			$("body #header.miniCartv2 .header-nav .cart-preview .body").animate({right: -350}, 500);
			$(".modal-backdrop.blockcart-modal-backdrop.fade.in").remove();
			$("body").removeClass("closeModal");
		});
		$("body").on("click","#header.miniCartv2 .header-nav .blockcart .header",function(event) {
			event.preventDefault();
		  $("body #header.miniCartv2 .header-nav .cart-preview .body").animate({right: 0}, 300);
		});
	},
}



var DORTHEME1 = {
	init1:function(){
		DORTHEME1.EventTheme();
		DORTHEME1.FooterClickMobile();
		DORTHEME1.MoveBannerStatic();
		DORTHEME1.BrandsLists();
		DORTHEME1.DealBanner();
	},
	
	DealBanner:function(){
		$('.dor-banner-deal-item-wrapper').owlCarousel({
	        items: 1,
	        loop: true,
	        nav: false,
	        autoplay: true,
	        autoplayTimeout: 3000,
	        margin:0,
	        lazyLoad: true,
	        responsive: {
	            0: {items: 1},
	            1200: {items: 1},
	            992: {items: 1},
	            650: {items: 1},
	            370: {items: 1},
	            300: {items: 1}
	        },
	        onInitialize: function (event) {
		        if ($('.dor-banner-deal-item-wrapper').find('.item-deal-banner').length <= 1) {
		           this.settings.loop = false;
		        }
		    },
	        navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
	    });
	},
	EventTheme:function(){
		jQuery(".select-setting").click(function(){
			var checkOpen = jQuery(this).closest(".dor-topbar-inner").hasClass("open");
			if(!checkOpen){
				jQuery(this).closest(".dor-topbar-inner").addClass("open");
			}else{
				jQuery(this).closest(".dor-topbar-inner").removeClass("open");
			}
		});
		jQuery(document).click(function (event) {
            if (!jQuery(event.target).is(".select-setting, .select-setting *, .topbar-selector, .topbar-selectorn *")) {
                jQuery(".dor-topbar-inner").removeClass("open");
            }
        });
	},
	FooterClickMobile:function(){
		jQuery(".footer-block .navbar-toggler").click(function(){
			var checkOpen = jQuery(this).closest(".footer-block").hasClass("open");
			if(!checkOpen){
				jQuery(this).closest(".footer-block").addClass("open");
			}else{
				jQuery(this).closest(".footer-block").removeClass("open");
			}
		});
		jQuery(document).click(function (event) {
            if (!jQuery(event.target).is(".footer-block .navbar-toggler, .footer-block .navbar-toggler *, .dorFooterInner .collapse, .dorFooterInner .collapse *")) {
                jQuery(".footer-block").removeClass("open");
            }
        });
	},
	MoveBannerStatic:function(){
		if(parseInt($( window ).width()) <= 767){
			jQuery(".banner-field.main-field").detach().insertAfter('.banner-field.tickfield');
		}
		$( window ).resize(function() {
		  var widthW = $( window ).width();
		  if(parseInt(widthW) <= 767){
		  	jQuery(".banner-field.main-field").detach().insertAfter('.banner-field.tickfield');
		  }else{
		  	jQuery(".banner-field.tickfield").detach().insertAfter('.banner-field.main-field');
		  }
		});
	},

	BrandsLists:function(){
		$('.brands-lists ul').owlCarousel({
	        items: 6,
	        loop: true,
	        navigation: true,
	        nav: true,
	        autoplay: true,
	        lazyLoad:true,
	        responsive: {
	            0: {items: 1},
	            1198: {items: 6},
	            1165: {items: 5},
	            990: {items: 4},
	            700: {items: 3},
	            600: {items: 3},
	            370: {items: 2},
	            320: {items: 1}
	        },
	        onInitialize: function (event) {
		        if ($('.brands-lists ul').find('li').length <= 1) {
		           this.settings.loop = false;
		        }
		    },
	        navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
	    });
	},

};




var DORPHOTOSWIPE = {
	initPhotoSwipeFromDOM:function(gallerySelector){

		// select all gallery elements
		var galleryElements = document.querySelectorAll( gallerySelector );
		for(var i = 0, l = galleryElements.length; i < l; i++) {
			galleryElements[i].setAttribute('data-pswp-uid', i+1);
			galleryElements[i].onclick = DORPHOTOSWIPE.onThumbnailsClick;
		}

		// Parse URL and open gallery if it contains #&pid=3&gid=1
		var hashData = DORPHOTOSWIPE.photoswipeParseHash();
		if(hashData.pid && hashData.gid) {
			DORPHOTOSWIPE.openPhotoSwipe( hashData.pid,  galleryElements[ hashData.gid - 1 ], true, true );
		}
	},

	parseThumbnailElements:function(el) {
	    var thumbElements = el.childNodes,
	        numNodes = thumbElements.length,
	        items = [],
	        el,
	        childElements,
	        thumbnailEl,
	        size,
	        item;

	    for(var i = 0; i < numNodes; i++) {
	        el = thumbElements[i];

	        // include only element nodes 
	        if(el.nodeType !== 1) {
	          continue;
	        }

	        childElements = el.children;

	        size = el.getAttribute('data-size').split('x');

	        // create slide object
	        item = {
				src: el.getAttribute('href'),
				w: parseInt(size[0], 10),
				h: parseInt(size[1], 10),
				author: el.getAttribute('data-author')
	        };

	        item.el = el; // save link to element for getThumbBoundsFn

	        if(childElements.length > 0) {
	          item.msrc = childElements[0].getAttribute('src'); // thumbnail url
	          if(childElements.length > 1) {
	              item.title = childElements[1].innerHTML; // caption (contents of figure)
	          }
	        }


			var mediumSrc = el.getAttribute('data-med');
          	if(mediumSrc) {
            	size = el.getAttribute('data-med-size').split('x');
            	// "medium-sized" image
            	item.m = {
              		src: mediumSrc,
              		w: parseInt(size[0], 10),
              		h: parseInt(size[1], 10)
            	};
          	}
          	// original image
          	item.o = {
          		src: item.src,
          		w: item.w,
          		h: item.h
          	};

	        items.push(item);
	    }

	    return items;
	},

	closest:function(el, fn) {
	    return el && ( fn(el) ? el : DORPHOTOSWIPE.closest(el.parentNode, fn) );
	},

	onThumbnailsClick:function(e) {
	    e = e || window.event;
	    e.preventDefault ? e.preventDefault() : e.returnValue = false;

	    var eTarget = e.target || e.srcElement;DORPHOTOSWIPE.photoswipeParseHash

	    var clickedListItem = DORPHOTOSWIPE.closest(eTarget, function(el) {
	        return el.tagName === 'A';
	    });

	    if(!clickedListItem) {
	        return;
	    }

	    var clickedGallery = clickedListItem.parentNode;

	    var childNodes = clickedListItem.parentNode.childNodes,
	        numChildNodes = childNodes.length,
	        nodeIndex = 0,
	        index;

	    for (var i = 0; i < numChildNodes; i++) {
	        if(childNodes[i].nodeType !== 1) { 
	            continue; 
	        }

	        if(childNodes[i] === clickedListItem) {
	            index = nodeIndex;
	            break;
	        }
	        nodeIndex++;
	    }

	    if(index >= 0) {
	        DORPHOTOSWIPE.openPhotoSwipe( index, clickedGallery );
	    }
	    return false;
	},

	photoswipeParseHash:function() {
		var hash = window.location.hash.substring(1),
	    params = {};

	    if(hash.length < 5) { // pid=1
	        return params;
	    }

	    var vars = hash.split('&');
	    for (var i = 0; i < vars.length; i++) {
	        if(!vars[i]) {
	            continue;
	        }
	        var pair = vars[i].split('=');  
	        if(pair.length < 2) {
	            continue;
	        }           
	        params[pair[0]] = pair[1];
	    }

	    if(params.gid) {
	    	params.gid = parseInt(params.gid, 10);
	    }

	    return params;
	},

	openPhotoSwipe:function(index, galleryElement, disableAnimation, fromURL) {
	    var pswpElement = document.querySelectorAll('.pswp')[0],
	        gallery,
	        options,
	        items;

		items = DORPHOTOSWIPE.parseThumbnailElements(galleryElement);

	    // define options (if needed)
	    options = {

	        galleryUID: galleryElement.getAttribute('data-pswp-uid'),

	        //getThumbBoundsFn: function(index) {
	            // See Options->getThumbBoundsFn section of docs for more info
	            // Dorado Comment
	            /*var thumbnail = items[index].el.children[0],
	                pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
	                rect = thumbnail.getBoundingClientRect(); 

	            return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};*/
	        //},

	        addCaptionHTMLFn: function(item, captionEl, isFake) {
				if(!item.title) {
					captionEl.children[0].innerText = '';
					return false;
				}
				captionEl.children[0].innerHTML = item.title +  '<br/><small>Photo: ' + item.author + '</small>';
				return true;
	        },
			
	    };


	    if(fromURL) {
	    	if(options.galleryPIDs) {
	    		// parse real index when custom PIDs are used 
	    		// http://photoswipe.com/documentation/faq.html#custom-pid-in-url
	    		for(var j = 0; j < items.length; j++) {
	    			if(items[j].pid == index) {
	    				options.index = j;
	    				break;
	    			}
	    		}
		    } else {
		    	options.index = parseInt(index, 10) - 1;
		    }
	    } else {
	    	options.index = parseInt(index, 10);
	    }

	    // exit if index not found
	    if( isNaN(options.index) ) {
	    	return;
	    }

		var radios = document.getElementsByName('gallery-style');
		for (var i = 0, length = radios.length; i < length; i++) {
		    if (radios[i].checked) {
		        if(radios[i].id == 'radio-all-controls') {

		        } else if(radios[i].id == 'radio-minimal-black') {
		        	options.mainClass = 'pswp--minimal--dark';
			        options.barsSize = {top:0,bottom:0};
					options.captionEl = false;
					options.fullscreenEl = false;
					options.shareEl = false;
					options.bgOpacity = 0.85;
					options.tapToClose = true;
					options.tapToToggleControls = false;
		        }
		        break;
		    }
		}

	    if(disableAnimation) {
	        options.showAnimationDuration = 0;
	    }

	    // Pass data to PhotoSwipe and initialize it
	    gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);

	    // see: http://photoswipe.com/documentation/responsive-images.html
		var realViewportWidth,
		    useLargeImages = false,
		    firstResize = true,
		    imageSrcWillChange;

		gallery.listen('beforeResize', function() {

			var dpiRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
			dpiRatio = Math.min(dpiRatio, 2.5);
		    realViewportWidth = gallery.viewportSize.x * dpiRatio;


		    if(realViewportWidth >= 1200 || (!gallery.likelyTouchDevice && realViewportWidth > 800) || screen.width > 1200 ) {
		    	if(!useLargeImages) {
		    		useLargeImages = true;
		        	imageSrcWillChange = true;
		    	}
		        
		    } else {
		    	if(useLargeImages) {
		    		useLargeImages = false;
		        	imageSrcWillChange = true;
		    	}
		    }

		    if(imageSrcWillChange && !firstResize) {
		        gallery.invalidateCurrItems();
		    }

		    if(firstResize) {
		        firstResize = false;
		    }

		    imageSrcWillChange = false;

		});

		gallery.listen('gettingData', function(index, item) {
		    if( useLargeImages ) {
		        item.src = item.o.src;
		        item.w = item.o.w;
		        item.h = item.o.h;
		    } else {
		        item.src = item.m.src;
		        item.w = item.m.w;
		        item.h = item.m.h;
		    }
		});

	    gallery.init();
	},
}

jQuery(document).ready(function(){
	DORTHEME.init();
	DORTHEME1.init1();
	var checkGallery = $(".demo-gallery").html();
	if(typeof checkGallery != "undefined")
		DORPHOTOSWIPE.initPhotoSwipeFromDOM(".demo-gallery");
});