// source --> https://laduvetnordique.com/wp-content/plugins/cookie-law-info/legacy/public/js/cookie-law-info-public.js?ver=3.2.10 
CLI_ACCEPT_COOKIE_NAME = (typeof CLI_ACCEPT_COOKIE_NAME !== 'undefined' ? CLI_ACCEPT_COOKIE_NAME : 'viewed_cookie_policy');
CLI_PREFERENCE_COOKIE = (typeof CLI_PREFERENCE_COOKIE !== 'undefined' ? CLI_PREFERENCE_COOKIE : 'CookieLawInfoConsent');
CLI_ACCEPT_COOKIE_EXPIRE = (typeof CLI_ACCEPT_COOKIE_EXPIRE !== 'undefined' ? CLI_ACCEPT_COOKIE_EXPIRE : 365);
CLI_COOKIEBAR_AS_POPUP = (typeof CLI_COOKIEBAR_AS_POPUP !== 'undefined' ? CLI_COOKIEBAR_AS_POPUP : false);
var CLI_Cookie = {
	set: function (name, value, days) {
		var secure = "";
		if (true === Boolean(Cli_Data.secure_cookies)) {
			secure = ";secure";
		}
		if (days) {
			var date = new Date();
			date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
			var expires = "; expires=" + date.toGMTString();
		} else {
			var expires = "";
		}
		document.cookie = name + "=" + value + secure + expires + "; path=/";
		if (days < 1) {
			host_name = window.location.hostname;
			document.cookie = name + "=" + value + expires + "; path=/; domain=." + host_name + ";";
			if (host_name.indexOf("www") != 1) {
				var host_name_withoutwww = host_name.replace('www', '');
				document.cookie = name + "=" + value + secure + expires + "; path=/; domain=" + host_name_withoutwww + ";";
			}
			host_name = host_name.substring(host_name.lastIndexOf(".", host_name.lastIndexOf(".") - 1));
			document.cookie = name + "=" + value + secure + expires + "; path=/; domain=" + host_name + ";";
		}
	},
	read: function (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;
	},
	erase: function (name) {
		this.set(name, "", -10);
	},
	exists: function (name) {
		return (this.read(name) !== null);
	},
	getallcookies: function () {
		var pairs = document.cookie.split(";");
		var cookieslist = {};
		for (var i = 0; i < pairs.length; i++) {
			var pair = pairs[i].split("=");
			cookieslist[(pair[0] + '').trim()] = unescape(pair[1]);
		}
		return cookieslist;
	}
}
var CLI =
{
	bar_config: {},
	showagain_config: {},
	allowedCategories: [],
	js_blocking_enabled: false,
	set: function (args) {
		if (typeof JSON.parse !== "function") {
			console.log("CookieLawInfo requires JSON.parse but your browser doesn't support it");
			return;
		}
		if (typeof args.settings !== 'object') {
			this.settings = JSON.parse(args.settings);
		} else {
			this.settings = args.settings;
		}
		this.js_blocking_enabled = Boolean(Cli_Data.js_blocking);
		this.settings = args.settings;
		this.bar_elm = jQuery(this.settings.notify_div_id);
		this.showagain_elm = jQuery(this.settings.showagain_div_id);
		this.settingsModal = jQuery('#cliSettingsPopup');

		/* buttons */
		this.main_button = jQuery('.cli-plugin-main-button');
		this.main_link = jQuery('.cli-plugin-main-link');
		this.reject_link = jQuery('.cookie_action_close_header_reject');
		this.delete_link = jQuery(".cookielawinfo-cookie-delete");
		this.settings_button = jQuery('.cli_settings_button');
		this.accept_all_button = jQuery('.wt-cli-accept-all-btn');
		if (this.settings.cookie_bar_as == 'popup') {
			CLI_COOKIEBAR_AS_POPUP = true;
		}
		this.mayBeSetPreferenceCookie();
		this.addStyleAttribute();
		this.configBar();
		this.toggleBar();
		this.attachDelete();
		this.attachEvents();
		this.configButtons();
		this.reviewConsent();
		var cli_hidebar_on_readmore = this.hideBarInReadMoreLink();
		if (Boolean(this.settings.scroll_close) === true && cli_hidebar_on_readmore === false) {
			window.addEventListener("scroll", CLI.closeOnScroll, false);
		}

	},
	hideBarInReadMoreLink: function () {
		if (Boolean(CLI.settings.button_2_hidebar) === true && this.main_link.length > 0 && this.main_link.hasClass('cli-minimize-bar')) {
			this.hideHeader();
			cliBlocker.cookieBar(false);
			this.showagain_elm.slideDown(this.settings.animate_speed_show);
			return true;
		}
		return false;
	},
	attachEvents: function () {
		jQuery(document).on(
			'click',
			'.wt-cli-privacy-btn',
			function (e) {
				e.preventDefault();
				CLI.accept_close();
				CLI.settingsPopUpClose();
			}
		);

		jQuery('.wt-cli-accept-btn').on(
			"click",
			function (e) {
				e.preventDefault();
				CLI.acceptRejectCookies(jQuery(this));
			});
		jQuery('.wt-cli-accept-all-btn').on(
			"click",
			function (e) {
				e.preventDefault();
				CLI.acceptRejectCookies(jQuery(this), 'accept');
			});
		jQuery('.wt-cli-reject-btn').on(
			"click",
			function (e) {
				e.preventDefault();
				CLI.acceptRejectCookies(jQuery(this), 'reject');
			});
		this.settingsPopUp();
		this.settingsTabbedAccordion();
		this.toggleUserPreferenceCheckBox();
		this.hideCookieBarOnClose();
		this.cookieLawInfoRunCallBacks();

	},
	acceptRejectCookies(element, action = 'custom') {
		var open_link = element[0].hasAttribute("href") && element.attr("href") != '#' ? true : false;
		var new_window = false;
		if (action == 'accept') {
			this.enableAllCookies();
			this.accept_close();
			new_window = CLI.settings.button_7_new_win ? true : false;

		} else if (action == 'reject') {
			this.disableAllCookies();
			this.reject_close();
			new_window = Boolean(this.settings.button_3_new_win) ? true : false;
		} else {
			this.accept_close();
			new_window = Boolean(this.settings.button_1_new_win) ? true : false;
		}
		if (open_link) {
			if (new_window) {
				window.open(element.attr("href"), '_blank');
			} else {
				window.location.href = element.attr("href");
			}
		}
	},
	toggleUserPreferenceCheckBox: function () {

		jQuery('.cli-user-preference-checkbox').each(
			function () {

				categoryCookie = 'cookielawinfo-' + jQuery(this).attr('data-id');
				categoryCookieValue = CLI_Cookie.read(categoryCookie);
				if (categoryCookieValue == null) {
					if (jQuery(this).is(':checked')) {
						CLI_Cookie.set(categoryCookie, 'yes', CLI_ACCEPT_COOKIE_EXPIRE);
					} else {
						CLI_Cookie.set(categoryCookie, 'no', CLI_ACCEPT_COOKIE_EXPIRE);
					}
				} else {
					if (categoryCookieValue == "yes") {
						jQuery(this).prop("checked", true);
					} else {
						jQuery(this).prop("checked", false);
					}

				}

			}
		);
		jQuery('.cli-user-preference-checkbox').on(
			"click",
			function (e) {
				var dataID = jQuery(this).attr('data-id');
				var currentToggleElm = jQuery('.cli-user-preference-checkbox[data-id=' + dataID + ']');
				if (jQuery(this).is(':checked')) {
					CLI_Cookie.set('cookielawinfo-' + dataID, 'yes', CLI_ACCEPT_COOKIE_EXPIRE);
					currentToggleElm.prop('checked', true);
				} else {
					CLI_Cookie.set('cookielawinfo-' + dataID, 'no', CLI_ACCEPT_COOKIE_EXPIRE);
					currentToggleElm.prop('checked', false);
				}
				CLI.checkCategories();
				CLI.generateConsent();
			}
		);

	},
	settingsPopUp: function () {
		jQuery(document).on(
			'click',
			'.cli_settings_button',
			function (e) {
				e.preventDefault();
				CLI.settingsModal.addClass("cli-show").css({ 'opacity': 0 }).animate({ 'opacity': 1 });
				CLI.settingsModal.removeClass('cli-blowup cli-out').addClass("cli-blowup");
				jQuery('body').addClass("cli-modal-open");
				jQuery(".cli-settings-overlay").addClass("cli-show");
				jQuery("#cookie-law-info-bar").css({ 'opacity': .1 });
				if (!jQuery('.cli-settings-mobile').is(':visible')) {
					CLI.settingsModal.find('.cli-nav-link:eq(0)').trigger("click");
				}
			}
		);
		jQuery('#cliModalClose').on(
			"click",
			function (e) {
				CLI.settingsPopUpClose();
			}
		);
		CLI.settingsModal.on(
			"click",
			function (e) {
				if (!(document.getElementsByClassName('cli-modal-dialog')[0].contains(e.target))) {
					CLI.settingsPopUpClose();
				}
			}
		);
		jQuery('.cli_enable_all_btn').on(
			"click",
			function (e) {
				var cli_toggle_btn = jQuery(this);
				var enable_text = cli_toggle_btn.attr('data-enable-text');
				var disable_text = cli_toggle_btn.attr('data-disable-text');
				if (cli_toggle_btn.hasClass('cli-enabled')) {
					CLI.disableAllCookies();
					cli_toggle_btn.html(enable_text);
				} else {
					CLI.enableAllCookies();
					cli_toggle_btn.html(disable_text);

				}
				jQuery(this).toggleClass('cli-enabled');
			}
		);

		this.privacyReadmore();
	},
	settingsTabbedAccordion: function () {
		jQuery(".cli-tab-header").on(
			"click",
			function (e) {
				if (!(jQuery(e.target).hasClass('cli-slider') || jQuery(e.target).hasClass('cli-user-preference-checkbox'))) {
					if (jQuery(this).hasClass("cli-tab-active")) {
						jQuery(this).removeClass("cli-tab-active");
						jQuery(this)
							.siblings(".cli-tab-content")
							.slideUp(200);

					} else {
						jQuery(".cli-tab-header").removeClass("cli-tab-active");
						jQuery(this).addClass("cli-tab-active");
						jQuery(".cli-tab-content").slideUp(200);
						jQuery(this)
							.siblings(".cli-tab-content")
							.slideDown(200);
					}
				}
			}
		);
	},
	settingsPopUpClose: function () {
		this.settingsModal.removeClass('cli-show');
		this.settingsModal.addClass('cli-out');
		jQuery('body').removeClass("cli-modal-open");
		jQuery(".cli-settings-overlay").removeClass("cli-show");
		jQuery("#cookie-law-info-bar").css({ 'opacity': 1 });
	},
	privacyReadmore: function () {
		var el = jQuery('.cli-privacy-content .cli-privacy-content-text');
		if (el.length > 0) {
			var clone = el.clone(),
				originalHtml = clone.html(),
				originalHeight = el.outerHeight(),
				Trunc = {
					addReadmore: function (textBlock) {
						if (textBlock.html().length > 250) {
							jQuery('.cli-privacy-readmore').show();
						} else {
							jQuery('.cli-privacy-readmore').hide();
						}
					},
					truncateText: function (textBlock) {
						var strippedText = jQuery('<div />').html(textBlock.html());
						strippedText.find('table').remove();
						textBlock.html(strippedText.html());
						currentText = textBlock.text();
						if (currentText.trim().length > 250) {
							var newStr = currentText.substring(0, 250);
							textBlock.empty().html(newStr).append('...');
						}
					},
					replaceText: function (textBlock, original) {
						return textBlock.html(original);
					}

				};
			Trunc.addReadmore(el);
			Trunc.truncateText(el);
			jQuery('a.cli-privacy-readmore').on(
				"click",
				function (e) {
					e.preventDefault();
					if (jQuery('.cli-privacy-overview').hasClass('cli-collapsed')) {
						Trunc.truncateText(el);
						jQuery('.cli-privacy-overview').removeClass('cli-collapsed');
						el.css('height', '100%');
					} else {
						jQuery('.cli-privacy-overview').addClass('cli-collapsed');
						Trunc.replaceText(el, originalHtml);
					}

				}
			);
		}

	},
	attachDelete: function () {
		this.delete_link.on(
			"click",
			function (e) {
				CLI_Cookie.erase(CLI_ACCEPT_COOKIE_NAME);
				for (var k in Cli_Data.nn_cookie_ids) {
					CLI_Cookie.erase(Cli_Data.nn_cookie_ids[k]);
				}
				CLI.generateConsent();
				return false;
			}
		);

	},
	configButtons: function () {
		/*[cookie_button] */
		this.main_button.css('color', this.settings.button_1_link_colour);
		if (Boolean(this.settings.button_1_as_button)) {
			this.main_button.css('background-color', this.settings.button_1_button_colour);

			this.main_button.on(
				'mouseenter',
				function () {
					jQuery(this).css('background-color', CLI.settings.button_1_button_hover);
				}
			)
				.on(
					'mouseleave',
					function () {
						jQuery(this).css('background-color', CLI.settings.button_1_button_colour);
					}
				);
		}

		/* [cookie_link] */
		this.main_link.css('color', this.settings.button_2_link_colour);
		if (Boolean(this.settings.button_2_as_button)) {
			this.main_link.css('background-color', this.settings.button_2_button_colour);

			this.main_link.on(
				'mouseenter',
				function () {
					jQuery(this).css('background-color', CLI.settings.button_2_button_hover);
				}
			)
				.on(
					'mouseleave',
					function () {
						jQuery(this).css('background-color', CLI.settings.button_2_button_colour);
					}
				);

		}
		/* [cookie_reject] */
		this.reject_link.css('color', this.settings.button_3_link_colour);
		if (Boolean(this.settings.button_3_as_button)) {

			this.reject_link.css('background-color', this.settings.button_3_button_colour);
			this.reject_link.on(
				'mouseenter',
				function () {
					jQuery(this).css('background-color', CLI.settings.button_3_button_hover);
				}
			)
				.on(
					'mouseleave',
					function () {
						jQuery(this).css('background-color', CLI.settings.button_3_button_colour);
					}
				);
		}
		/* [cookie_settings] */
		this.settings_button.css('color', this.settings.button_4_link_colour);
		if (Boolean(this.settings.button_4_as_button)) {
			this.settings_button.css('background-color', this.settings.button_4_button_colour);
			this.settings_button.on(
				'mouseenter',
				function () {
					jQuery(this).css('background-color', CLI.settings.button_4_button_hover);
				}
			)
				.on(
					'mouseleave',
					function () {
						jQuery(this).css('background-color', CLI.settings.button_4_button_colour);
					}
				);
		}
		/* [cookie_accept_all] */
		this.accept_all_button.css('color', this.settings.button_7_link_colour);
		if (this.settings.button_7_as_button) {
			this.accept_all_button.css('background-color', this.settings.button_7_button_colour);
			this.accept_all_button.on(
				'mouseenter',
				function () {
					jQuery(this).css('background-color', CLI.settings.button_7_button_hover);
				}
			)
				.on(
					'mouseleave',
					function () {
						jQuery(this).css('background-color', CLI.settings.button_7_button_colour);
					}
				);
		}
	},
	toggleBar: function () {
		if (CLI_COOKIEBAR_AS_POPUP) {
			this.barAsPopUp(1);
		}
		if (CLI.settings.cookie_bar_as == 'widget') {
			this.barAsWidget(1);
		}
		if (!CLI_Cookie.exists(CLI_ACCEPT_COOKIE_NAME)) {
			this.displayHeader();
		} else {
			this.hideHeader();
		}
		if (Boolean(this.settings.show_once_yn)) {
			setTimeout(
				function () {
					CLI.close_header();
				},
				CLI.settings.show_once
			);
		}
		if (CLI.js_blocking_enabled === false) {
			if (Boolean(Cli_Data.ccpaEnabled) === true) {
				if (Cli_Data.ccpaType === 'ccpa' && Boolean(Cli_Data.ccpaBarEnabled) === false) {
					cliBlocker.cookieBar(false);
				}
			} else {
				jQuery('.wt-cli-ccpa-opt-out,.wt-cli-ccpa-checkbox,.wt-cli-ccpa-element').remove();
			}
		}

		this.showagain_elm.on(
			"click",
			function (e) {
				e.preventDefault();
				CLI.showagain_elm.slideUp(
					CLI.settings.animate_speed_hide,
					function () {
						CLI.bar_elm.slideDown(CLI.settings.animate_speed_show);
						if (CLI_COOKIEBAR_AS_POPUP) {
							CLI.showPopupOverlay();
						}
					}
				);
			}
		);
	},
	configShowAgain: function () {
		this.showagain_config = {
			'background-color': this.settings.background,
			'color': this.l1hs(this.settings.text),
			'position': 'fixed',
			'font-family': this.settings.font_family
		};
		if (Boolean(this.settings.border_on)) {
			var border_to_hide = 'border-' + this.settings.notify_position_vertical;
			this.showagain_config['border'] = '1px solid ' + this.l1hs(this.settings.border);
			this.showagain_config[border_to_hide] = 'none';
		}
		var cli_win = jQuery(window);
		var cli_winw = cli_win.width();
		var showagain_x_pos = this.settings.showagain_x_position;
		if (cli_winw < 300) {
			showagain_x_pos = 10;
			this.showagain_config.width = cli_winw - 20;
		} else {
			this.showagain_config.width = 'auto';
		}
		var cli_defw = cli_winw > 400 ? 500 : cli_winw - 20;
		if (CLI_COOKIEBAR_AS_POPUP) { /* cookie bar as popup */
			var sa_pos = this.settings.popup_showagain_position;
			var sa_pos_arr = sa_pos.split('-');
			if (sa_pos_arr[1] == 'left') {
				this.showagain_config.left = showagain_x_pos;
			} else if (sa_pos_arr[1] == 'right') {
				this.showagain_config.right = showagain_x_pos;
			}
			if (sa_pos_arr[0] == 'top') {
				this.showagain_config.top = 0;

			} else if (sa_pos_arr[0] == 'bottom') {
				this.showagain_config.bottom = 0;
			}
			this.bar_config['position'] = 'fixed';

		} else if (this.settings.cookie_bar_as == 'widget') {
			this.showagain_config.bottom = 0;
			if (this.settings.widget_position == 'left') {
				this.showagain_config.left = showagain_x_pos;
			} else if (this.settings.widget_position == 'right') {
				this.showagain_config.right = showagain_x_pos;
			}
		} else {
			if (this.settings.notify_position_vertical == "top") {
				this.showagain_config.top = '0';
			} else if (this.settings.notify_position_vertical == "bottom") {
				this.bar_config['position'] = 'fixed';
				this.bar_config['bottom'] = '0';
				this.showagain_config.bottom = '0';
			}
			if (this.settings.notify_position_horizontal == "left") {
				this.showagain_config.left = showagain_x_pos;
			} else if (this.settings.notify_position_horizontal == "right") {
				this.showagain_config.right = showagain_x_pos;
			}
		}
		this.showagain_elm.css(this.showagain_config);
	},
	configBar: function () {
		this.bar_config = {
			'background-color': this.settings.background,
			'color': this.settings.text,
			'font-family': this.settings.font_family
		};
		if (this.settings.notify_position_vertical == "top") {
			this.bar_config['top'] = '0';
			if (Boolean(this.settings.header_fix) === true) {
				this.bar_config['position'] = 'fixed';
			}
		} else {
			this.bar_config['bottom'] = '0';
		}
		this.configShowAgain();
		this.bar_elm.css(this.bar_config).hide();
	},
	l1hs: function (str) {
		if (str.charAt(0) == "#") {
			str = str.substring(1, str.length);
		} else {
			return "#" + str;
		}
		return this.l1hs(str);
	},
	close_header: function () {
		CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME, 'yes', CLI_ACCEPT_COOKIE_EXPIRE);
		this.hideHeader();
	},
	accept_close: function () {
		this.hidePopupOverlay();
		this.generateConsent();
		this.cookieLawInfoRunCallBacks();

		CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME, 'yes', CLI_ACCEPT_COOKIE_EXPIRE);
		if (Boolean(this.settings.notify_animate_hide)) {
			if (CLI.js_blocking_enabled === true) {
				this.bar_elm.slideUp(this.settings.animate_speed_hide, cliBlocker.runScripts);
			} else {
				this.bar_elm.slideUp(this.settings.animate_speed_hide);
			}

		} else {
			if (CLI.js_blocking_enabled === true) {
				this.bar_elm.hide(0, cliBlocker.runScripts);

			} else {
				this.bar_elm.hide();
			}
		}
		if (Boolean(this.settings.showagain_tab)) {
			this.showagain_elm.slideDown(this.settings.animate_speed_show);
		}
		if (Boolean(this.settings.accept_close_reload) === true) {
			this.reload_current_page();
		}
		return false;
	},
	reject_close: function () {
		this.hidePopupOverlay();
		this.generateConsent();
		this.cookieLawInfoRunCallBacks();
		for (var k in Cli_Data.nn_cookie_ids) {
			CLI_Cookie.erase(Cli_Data.nn_cookie_ids[k]);
		}
		CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME, 'no', CLI_ACCEPT_COOKIE_EXPIRE);

		if (Boolean(this.settings.notify_animate_hide)) {
			if (CLI.js_blocking_enabled === true) {

				this.bar_elm.slideUp(this.settings.animate_speed_hide, cliBlocker.runScripts);

			} else {

				this.bar_elm.slideUp(this.settings.animate_speed_hide);
			}

		} else {
			if (CLI.js_blocking_enabled === true) {

				this.bar_elm.hide(cliBlocker.runScripts);

			} else {

				this.bar_elm.hide();

			}

		}
		if (Boolean(this.settings.showagain_tab)) {
			this.showagain_elm.slideDown(this.settings.animate_speed_show);
		}
		if (Boolean(this.settings.reject_close_reload) === true) {
			this.reload_current_page();
		}
		return false;
	},
	reload_current_page: function () {

		window.location.reload(true);
	},
	closeOnScroll: function () {
		if (window.pageYOffset > 100 && !CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)) {
			CLI.accept_close();
			if (Boolean(CLI.settings.scroll_close_reload) === true) {
				window.location.reload();
			}
			window.removeEventListener("scroll", CLI.closeOnScroll, false);
		}
	},
	displayHeader: function () {
		if (Boolean(this.settings.notify_animate_show)) {
			this.bar_elm.slideDown(this.settings.animate_speed_show);
		} else {
			this.bar_elm.show();
		}
		this.showagain_elm.hide();
		if (CLI_COOKIEBAR_AS_POPUP) {
			this.showPopupOverlay();
		}
	},
	hideHeader: function () {
		if (Boolean(this.settings.showagain_tab)) {
			if (Boolean(this.settings.notify_animate_show)) {
				this.showagain_elm.slideDown(this.settings.animate_speed_show);
			} else {
				this.showagain_elm.show();
			}
		} else {
			this.showagain_elm.hide();
		}
		this.bar_elm.slideUp(this.settings.animate_speed_show);
		this.hidePopupOverlay();
	},
	hidePopupOverlay: function () {
		jQuery('body').removeClass("cli-barmodal-open");
		jQuery(".cli-popupbar-overlay").removeClass("cli-show");
	},
	showPopupOverlay: function () {
		if (this.bar_elm.length) {
			if (Boolean(this.settings.popup_overlay)) {
				jQuery('body').addClass("cli-barmodal-open");
				jQuery(".cli-popupbar-overlay").addClass("cli-show");
			}
		}

	},
	barAsWidget: function (a) {
		var cli_elm = this.bar_elm;
		cli_elm.attr('data-cli-type', 'widget');
		var cli_win = jQuery(window);
		var cli_winh = cli_win.height() - 40;
		var cli_winw = cli_win.width();
		var cli_defw = cli_winw > 400 ? 300 : cli_winw - 30;
		cli_elm.css(
			{
				'width': cli_defw, 'height': 'auto', 'max-height': cli_winh, 'overflow': 'auto', 'position': 'fixed', 'box-sizing': 'border-box'
			}
		);
		if (this.checkifStyleAttributeExist() === false) {
			cli_elm.css({ 'padding': '25px 15px' });
		}
		if (this.settings.widget_position == 'left') {
			cli_elm.css(
				{
					'left': '15px', 'right': 'auto', 'bottom': '15px', 'top': 'auto'
				}
			);
		} else {
			cli_elm.css(
				{
					'left': 'auto', 'right': '15px', 'bottom': '15px', 'top': 'auto'
				}
			);
		}
		if (a) {
			this.setResize();
		}
	},
	barAsPopUp: function (a) {
		if (typeof cookie_law_info_bar_as_popup === 'function') {
			return false;
		}
		var cli_elm = this.bar_elm;
		cli_elm.attr('data-cli-type', 'popup');
		var cli_win = jQuery(window);
		var cli_winh = cli_win.height() - 40;
		var cli_winw = cli_win.width();
		var cli_defw = cli_winw > 700 ? 500 : cli_winw - 20;

		cli_elm.css(
			{
				'width': cli_defw, 'height': 'auto', 'max-height': cli_winh, 'bottom': '', 'top': '50%', 'left': '50%', 'margin-left': (cli_defw / 2) * -1, 'margin-top': '-100px', 'overflow': 'auto'
			}
		).addClass('cli-bar-popup cli-modal-content');
		if (this.checkifStyleAttributeExist() === false) {
			cli_elm.css({ 'padding': '25px 15px' });
		}
		cli_h = cli_elm.height();
		li_h = cli_h < 200 ? 200 : cli_h;
		cli_elm.css({ 'top': '50%', 'margin-top': ((cli_h / 2) + 30) * -1 });
		setTimeout(
			function () {
				cli_elm.css(
					{
						'bottom': ''
					}
				);
			},
			100
		);
		if (a) {
			this.setResize();
		}
	},
	setResize: function () {
		var resizeTmr = null;
		jQuery(window).resize(
			function () {
				clearTimeout(resizeTmr);
				resizeTmr = setTimeout(
					function () {
						if (CLI_COOKIEBAR_AS_POPUP) {
							CLI.barAsPopUp();
						}
						if (CLI.settings.cookie_bar_as == 'widget') {
							CLI.barAsWidget();
						}
						CLI.configShowAgain();
					},
					500
				);
			}
		);
	},
	enableAllCookies: function () {

		jQuery('.cli-user-preference-checkbox').each(
			function () {
				var cli_chkbox_elm = jQuery(this);
				var cli_chkbox_data_id = cli_chkbox_elm.attr('data-id');
				if (cli_chkbox_data_id != 'checkbox-necessary') {
					cli_chkbox_elm.prop('checked', true);
					CLI_Cookie.set('cookielawinfo-' + cli_chkbox_data_id, 'yes', CLI_ACCEPT_COOKIE_EXPIRE);
				}
			}
		);
	},
	disableAllCookies: function () {
		jQuery('.cli-user-preference-checkbox').each(
			function () {

				var cli_chkbox_elm = jQuery(this);
				var cli_chkbox_data_id = cli_chkbox_elm.attr('data-id');
				cliCategorySlug = cli_chkbox_data_id.replace('checkbox-', '');
				if (Cli_Data.strictlyEnabled.indexOf(cliCategorySlug) === -1) {
					cli_chkbox_elm.prop('checked', false);
					CLI_Cookie.set('cookielawinfo-' + cli_chkbox_data_id, 'no', CLI_ACCEPT_COOKIE_EXPIRE);
				}
			}
		);
	},
	hideCookieBarOnClose: function () {
		jQuery(document).on(
			'click',
			'.cli_cookie_close_button',
			function (e) {
				e.preventDefault();
				var elm = jQuery(this);
				if (Cli_Data.ccpaType === 'ccpa') {
					CLI.enableAllCookies();
				}
				CLI.accept_close();
			}
		);
	},
	checkCategories: function () {
		var cliAllowedCategories = [];
		var cli_categories = {};
		jQuery('.cli-user-preference-checkbox').each(
			function () {
				var status = false;
				cli_chkbox_elm = jQuery(this);
				cli_chkbox_data_id = cli_chkbox_elm.attr('data-id');
				cli_chkbox_data_id = cli_chkbox_data_id.replace('checkbox-', '');
				cli_chkbox_data_id_trimmed = cli_chkbox_data_id.replace('-', '_')
				if (jQuery(cli_chkbox_elm).is(':checked')) {
					status = true;
					cliAllowedCategories.push(cli_chkbox_data_id);
				}

				cli_categories[cli_chkbox_data_id_trimmed] = status;
			}
		);
		CLI.allowedCategories = cliAllowedCategories;
	},
	cookieLawInfoRunCallBacks: function () {
		this.checkCategories();
		if (CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) == 'yes') {
			if ("function" == typeof CookieLawInfo_Accept_Callback) {
				CookieLawInfo_Accept_Callback();
			}
		}
	},
	generateConsent: function () {
		var preferenceCookie = CLI_Cookie.read(CLI_PREFERENCE_COOKIE);
		cliConsent = {};
		if (preferenceCookie !== null) {
			cliConsent = window.atob(preferenceCookie);
			cliConsent = JSON.parse(cliConsent);
		}
		cliConsent.ver = Cli_Data.consentVersion;
		categories = [];
		jQuery('.cli-user-preference-checkbox').each(
			function () {
				categoryVal = '';
				cli_chkbox_data_id = jQuery(this).attr('data-id');
				cli_chkbox_data_id = cli_chkbox_data_id.replace('checkbox-', '');
				if (jQuery(this).is(':checked')) {
					categoryVal = true;
				} else {
					categoryVal = false;
				}
				cliConsent[cli_chkbox_data_id] = categoryVal;
			}
		);
		cliConsent = JSON.stringify(cliConsent);
		cliConsent = window.btoa(cliConsent);
		CLI_Cookie.set(CLI_PREFERENCE_COOKIE, cliConsent, CLI_ACCEPT_COOKIE_EXPIRE);
	},
	addStyleAttribute: function () {
		var bar = this.bar_elm;
		var styleClass = '';
		if (jQuery(bar).find('.cli-bar-container').length > 0) {
			styleClass = jQuery('.cli-bar-container').attr('class');
			styleClass = styleClass.replace('cli-bar-container', '');
			styleClass = styleClass.trim();
			jQuery(bar).attr('data-cli-style', styleClass);
		}
	},
	getParameterByName: function (name, url) {
		if (!url) {
			url = window.location.href;
		}
		name = name.replace(/[\[\]]/g, '\\$&');
		var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
			results = regex.exec(url);
		if (!results) {
			return null;
		}
		if (!results[2]) {
			return '';
		}
		return decodeURIComponent(results[2].replace(/\+/g, ' '));
	},
	CookieLawInfo_Callback: function (enableBar, enableBlocking) {
		enableBar = typeof enableBar !== 'undefined' ? enableBar : true;
		enableBlocking = typeof enableBlocking !== 'undefined' ? enableBlocking : true;
		if (CLI.js_blocking_enabled === true && Boolean(Cli_Data.custom_integration) === true) {
			cliBlocker.cookieBar(enableBar);
			cliBlocker.runScripts(enableBlocking);
		}
	},
	checkifStyleAttributeExist: function () {
		var exist = false;
		var attr = this.bar_elm.attr('data-cli-style');
		if (typeof attr !== typeof undefined && attr !== false) {
			exist = true;
		}
		return exist;
	},
	reviewConsent: function () {
		jQuery(document).on(
			'click',
			'.cli_manage_current_consent,.wt-cli-manage-consent-link',
			function () {
				CLI.displayHeader();
			}
		);
	},
	mayBeSetPreferenceCookie: function () {
		if (CLI.getParameterByName('cli_bypass') === "1") {
			CLI.generateConsent();
		}
	}
}
var cliBlocker =
{
	blockingStatus: true,
	scriptsLoaded: false,
	ccpaEnabled: false,
	ccpaRegionBased: false,
	ccpaApplicable: false,
	ccpaBarEnabled: false,
	cliShowBar: true,
	isBypassEnabled: CLI.getParameterByName('cli_bypass'),
	checkPluginStatus: function (callbackA, callbackB) {
		this.ccpaEnabled = Boolean(Cli_Data.ccpaEnabled);
		this.ccpaRegionBased = Boolean(Cli_Data.ccpaRegionBased);
		this.ccpaBarEnabled = Boolean(Cli_Data.ccpaBarEnabled);

		if (Boolean(Cli_Data.custom_integration) === true) {
			callbackA(false);
		} else {
			if (this.ccpaEnabled === true) {
				this.ccpaApplicable = true;
				if (Cli_Data.ccpaType === 'ccpa') {
					if (this.ccpaBarEnabled !== true) {
						this.cliShowBar = false;
						this.blockingStatus = false;
					}
				}
			} else {
				jQuery('.wt-cli-ccpa-opt-out,.wt-cli-ccpa-checkbox,.wt-cli-ccpa-element').remove();
			}
			if (cliBlocker.isBypassEnabled === "1") {
				cliBlocker.blockingStatus = false;
			}
			callbackA(this.cliShowBar);
			callbackB(this.blockingStatus);
		}

	},
	cookieBar: function (showbar) {
		showbar = typeof showbar !== 'undefined' ? showbar : true;
		cliBlocker.cliShowBar = showbar;
		if (cliBlocker.cliShowBar === false) {
			CLI.bar_elm.hide();
			CLI.showagain_elm.hide();
			CLI.settingsModal.removeClass('cli-blowup cli-out');
			CLI.hidePopupOverlay();
			jQuery(".cli-settings-overlay").removeClass("cli-show");
		} else {
			if (!CLI_Cookie.exists(CLI_ACCEPT_COOKIE_NAME)) {
				CLI.displayHeader();
			} else {
				CLI.hideHeader();
			}
		}
	},
	removeCookieByCategory: function () {

		if (cliBlocker.blockingStatus === true) {
			if (CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) !== null) {
				var non_necessary_cookies = Cli_Data.non_necessary_cookies;
				for (var key in non_necessary_cookies) {
					currentCategory = key;
					if (CLI.allowedCategories.indexOf(currentCategory) === -1) {
						var nonNecessaryCookies = non_necessary_cookies[currentCategory];
						for (var i = 0; i < nonNecessaryCookies.length; i++) {
							if (CLI_Cookie.read(nonNecessaryCookies[i]) !== null) {
								CLI_Cookie.erase(nonNecessaryCookies[i]);
							}

						}
					}
				}
			}
		}
	},
	runScripts: function (blocking) {
		blocking = typeof blocking !== 'undefined' ? blocking : true;
		cliBlocker.blockingStatus = blocking;
		srcReplaceableElms = ['iframe', 'IFRAME', 'EMBED', 'embed', 'OBJECT', 'object', 'IMG', 'img'];
		var genericFuncs =
		{

			renderByElement: function (callback) {
				cliScriptFuncs.renderScripts();
				callback();
				cliBlocker.scriptsLoaded = true;
			},

		};
		var cliScriptFuncs =
		{
			// trigger DOMContentLoaded
			scriptsDone: function () {
				if (typeof Cli_Data.triggerDomRefresh !== 'undefined') {
					if (Boolean(Cli_Data.triggerDomRefresh) === true) {
						var DOMContentLoadedEvent = document.createEvent('Event')
						DOMContentLoadedEvent.initEvent('DOMContentLoaded', true, true)
						window.document.dispatchEvent(DOMContentLoadedEvent);
					}
				}
			},
			seq: function (arr, callback, index) {
				// first call, without an index
				if (typeof index === 'undefined') {
					index = 0
				}

				arr[index](
					function () {
						index++
						if (index === arr.length) {
							callback()
						} else {
							cliScriptFuncs.seq(arr, callback, index)
						}
					}
				)
			},
			/* script runner */
			insertScript: function ($script, callback) {
				var s = '';
				var scriptType = $script.getAttribute('data-cli-script-type');
				var elementPosition = $script.getAttribute('data-cli-element-position');
				var isBlock = $script.getAttribute('data-cli-block');
				var s = document.createElement('script');
				var ccpaOptedOut = cliBlocker.ccpaOptedOut();
				s.type = 'text/plain';
				if ($script.async) {
					s.async = $script.async;
				}
				if ($script.defer) {
					s.defer = $script.defer;
				}
				if ($script.src) {
					s.onload = callback
					s.onerror = callback
					s.src = $script.src
				} else {
					s.textContent = $script.innerText
				}
				var attrs = jQuery($script).prop("attributes");
				for (var ii = 0; ii < attrs.length; ++ii) {
					if (attrs[ii].nodeName !== 'id') {
						s.setAttribute(attrs[ii].nodeName, attrs[ii].value);
					}
				}
				if (cliBlocker.blockingStatus === true) {

					if ((CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) == 'yes' && CLI.allowedCategories.indexOf(scriptType) !== -1)) {
						s.setAttribute('data-cli-consent', 'accepted');
						s.type = 'text/javascript';
					}
					if (cliBlocker.ccpaApplicable === true) {
						if (ccpaOptedOut === true || CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) == null) {
							s.type = 'text/plain';
						}
					}
				} else {
					s.type = 'text/javascript';
				}

				if ($script.type != s.type) {
					if (elementPosition === 'head') {
						document.head.appendChild(s);
					} else {
						document.body.appendChild(s);
					}
					if (!$script.src) {
						callback()
					}
					$script.parentNode.removeChild($script);

				} else {

					callback();
				}
			},
			renderScripts: function () {
				var $scripts = document.querySelectorAll('script[data-cli-class="cli-blocker-script"]');
				if ($scripts.length > 0) {
					var runList = []
					var typeAttr
					Array.prototype.forEach.call(
						$scripts,
						function ($script) {
							// only run script tags without the type attribute
							// or with a javascript mime attribute value
							typeAttr = $script.getAttribute('type')
							runList.push(
								function (callback) {
									cliScriptFuncs.insertScript($script, callback)
								}
							)
						}
					)
					cliScriptFuncs.seq(runList, cliScriptFuncs.scriptsDone);
				}
			}
		};
		genericFuncs.renderByElement(cliBlocker.removeCookieByCategory);
	},
	ccpaOptedOut: function () {
		var ccpaOptedOut = false;
		var preferenceCookie = CLI_Cookie.read(CLI_PREFERENCE_COOKIE);
		if (preferenceCookie !== null) {
			cliConsent = window.atob(preferenceCookie);
			cliConsent = JSON.parse(cliConsent);
			if (typeof cliConsent.ccpaOptout !== 'undefined') {
				ccpaOptedOut = cliConsent.ccpaOptout;
			}
		}
		return ccpaOptedOut;
	}
}
jQuery(document).ready(
	function () {
		if (typeof cli_cookiebar_settings != 'undefined') {
			CLI.set(
				{
					settings: cli_cookiebar_settings
				}
			);
			if (CLI.js_blocking_enabled === true) {
				cliBlocker.checkPluginStatus(cliBlocker.cookieBar, cliBlocker.runScripts);
			}
		}
	}
);
// source --> https://laduvetnordique.com/wp-content/plugins/woocommerce/assets/js/jquery-blockui/jquery.blockUI.js?ver=2.7.0-wc.9.8.7 
/*!
 * jQuery blockUI plugin
 * Version 2.70.0-2014.11.23
 * Requires jQuery v1.7 or later
 *
 * Examples at: http://malsup.com/jquery/block/
 * Copyright (c) 2007-2013 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
 */
;(function() {
/*jshint eqeqeq:false curly:false latedef:false */
"use strict";

	function setup($) {
		$.fn._fadeIn = $.fn.fadeIn;

		var noOp = $.noop || function() {};

		// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
		// confusing userAgent strings on Vista)
		var msie = /MSIE/.test(navigator.userAgent);
		var ie6  = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent);
		var mode = document.documentMode || 0;
		var setExpr = 'function' === typeof document.createElement('div').style.setExpression ? document.createElement('div').style.setExpression : false;

		// global $ methods for blocking/unblocking the entire page
		$.blockUI   = function(opts) { install(window, opts); };
		$.unblockUI = function(opts) { remove(window, opts); };

		// convenience method for quick growl-like notifications  (http://www.google.com/search?q=growl)
		$.growlUI = function(title, message, timeout, onClose) {
			var $m = $('<div class="growlUI"></div>');
			if (title) $m.append('<h1>'+title+'</h1>');
			if (message) $m.append('<h2>'+message+'</h2>');
			if (timeout === undefined) timeout = 3000;

			// Added by konapun: Set timeout to 30 seconds if this growl is moused over, like normal toast notifications
			var callBlock = function(opts) {
				opts = opts || {};

				$.blockUI({
					message: $m,
					fadeIn : typeof opts.fadeIn  !== 'undefined' ? opts.fadeIn  : 700,
					fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000,
					timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout,
					centerY: false,
					showOverlay: false,
					onUnblock: onClose,
					css: $.blockUI.defaults.growlCSS
				});
			};

			callBlock();
			var nonmousedOpacity = $m.css('opacity');
			$m.on( 'mouseover', function() {
				callBlock({
					fadeIn: 0,
					timeout: 30000
				});

				var displayBlock = $('.blockMsg');
				displayBlock.stop(); // cancel fadeout if it has started
				displayBlock.fadeTo(300, 1); // make it easier to read the message by removing transparency
			}).on( 'mouseout', function() {
				$('.blockMsg').fadeOut(1000);
			});
			// End konapun additions
		};

		// plugin method for blocking element content
		$.fn.block = function(opts) {
			if ( this[0] === window ) {
				$.blockUI( opts );
				return this;
			}
			var fullOpts = $.extend({}, $.blockUI.defaults, opts || {});
			this.each(function() {
				var $el = $(this);
				if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked'))
					return;
				$el.unblock({ fadeOut: 0 });
			});

			return this.each(function() {
				if ($.css(this,'position') == 'static') {
					this.style.position = 'relative';
					$(this).data('blockUI.static', true);
				}
				this.style.zoom = 1; // force 'hasLayout' in ie
				install(this, opts);
			});
		};

		// plugin method for unblocking element content
		$.fn.unblock = function(opts) {
			if ( this[0] === window ) {
				$.unblockUI( opts );
				return this;
			}
			return this.each(function() {
				remove(this, opts);
			});
		};

		$.blockUI.version = 2.70; // 2nd generation blocking at no extra cost!

		// override these in your code to change the default behavior and style
		$.blockUI.defaults = {
			// message displayed when blocking (use null for no message)
			message:  '<h1>Please wait...</h1>',

			title: null,		// title string; only used when theme == true
			draggable: true,	// only used when theme == true (requires jquery-ui.js to be loaded)

			theme: false, // set to true to use with jQuery UI themes

			// styles for the message when blocking; if you wish to disable
			// these and use an external stylesheet then do this in your code:
			// $.blockUI.defaults.css = {};
			css: {
				padding:	0,
				margin:		0,
				width:		'30%',
				top:		'40%',
				left:		'35%',
				textAlign:	'center',
				color:		'#000',
				border:		'3px solid #aaa',
				backgroundColor:'#fff',
				cursor:		'wait'
			},

			// minimal style set used when themes are used
			themedCSS: {
				width:	'30%',
				top:	'40%',
				left:	'35%'
			},

			// styles for the overlay
			overlayCSS:  {
				backgroundColor:	'#000',
				opacity:			0.6,
				cursor:				'wait'
			},

			// style to replace wait cursor before unblocking to correct issue
			// of lingering wait cursor
			cursorReset: 'default',

			// styles applied when using $.growlUI
			growlCSS: {
				width:		'350px',
				top:		'10px',
				left:		'',
				right:		'10px',
				border:		'none',
				padding:	'5px',
				opacity:	0.6,
				cursor:		'default',
				color:		'#fff',
				backgroundColor: '#000',
				'-webkit-border-radius':'10px',
				'-moz-border-radius':	'10px',
				'border-radius':		'10px'
			},

			// IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
			// (hat tip to Jorge H. N. de Vasconcelos)
			/*jshint scripturl:true */
			iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',

			// force usage of iframe in non-IE browsers (handy for blocking applets)
			forceIframe: false,

			// z-index for the blocking overlay
			baseZ: 1000,

			// set these to true to have the message automatically centered
			centerX: true, // <-- only effects element blocking (page block controlled via css above)
			centerY: true,

			// allow body element to be stetched in ie6; this makes blocking look better
			// on "short" pages.  disable if you wish to prevent changes to the body height
			allowBodyStretch: true,

			// enable if you want key and mouse events to be disabled for content that is blocked
			bindEvents: true,

			// by default blockUI will suppress tab navigation from leaving blocking content
			// (if bindEvents is true)
			constrainTabKey: true,

			// fadeIn time in millis; set to 0 to disable fadeIn on block
			fadeIn:  200,

			// fadeOut time in millis; set to 0 to disable fadeOut on unblock
			fadeOut:  400,

			// time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
			timeout: 0,

			// disable if you don't want to show the overlay
			showOverlay: true,

			// if true, focus will be placed in the first available input field when
			// page blocking
			focusInput: true,

            // elements that can receive focus
            focusableElements: ':input:enabled:visible',

			// suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
			// no longer needed in 2012
			// applyPlatformOpacityRules: true,

			// callback method invoked when fadeIn has completed and blocking message is visible
			onBlock: null,

			// callback method invoked when unblocking has completed; the callback is
			// passed the element that has been unblocked (which is the window object for page
			// blocks) and the options that were passed to the unblock call:
			//	onUnblock(element, options)
			onUnblock: null,

			// callback method invoked when the overlay area is clicked.
			// setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used.
			onOverlayClick: null,

			// don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
			quirksmodeOffsetHack: 4,

			// class name of the message block
			blockMsgClass: 'blockMsg',

			// if it is already blocked, then ignore it (don't unblock and reblock)
			ignoreIfBlocked: false
		};

		// private data and functions follow...

		var pageBlock = null;
		var pageBlockEls = [];

		function install(el, opts) {
			var css, themedCSS;
			var full = (el == window);
			var msg = (opts && opts.message !== undefined ? opts.message : undefined);
			opts = $.extend({}, $.blockUI.defaults, opts || {});

			if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked'))
				return;

			opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
			css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
			if (opts.onOverlayClick)
				opts.overlayCSS.cursor = 'pointer';

			themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
			msg = msg === undefined ? opts.message : msg;

			// remove the current block (if there is one)
			if (full && pageBlock)
				remove(window, {fadeOut:0});

			// if an existing element is being used as the blocking content then we capture
			// its current place in the DOM (and current display style) so we can restore
			// it when we unblock
			if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
				var node = msg.jquery ? msg[0] : msg;
				var data = {};
				$(el).data('blockUI.history', data);
				data.el = node;
				data.parent = node.parentNode;
				data.display = node.style.display;
				data.position = node.style.position;
				if (data.parent)
					data.parent.removeChild(node);
			}

			$(el).data('blockUI.onUnblock', opts.onUnblock);
			var z = opts.baseZ;

			// blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
			// layer1 is the iframe layer which is used to suppress bleed through of underlying content
			// layer2 is the overlay layer which has opacity and a wait cursor (by default)
			// layer3 is the message content that is displayed while blocking
			var lyr1, lyr2, lyr3, s;
			if (msie || opts.forceIframe)
				lyr1 = $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>');
			else
				lyr1 = $('<div class="blockUI" style="display:none"></div>');

			if (opts.theme)
				lyr2 = $('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>');
			else
				lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');

			if (opts.theme && full) {
				s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">';
				if ( opts.title ) {
					s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
				}
				s += '<div class="ui-widget-content ui-dialog-content"></div>';
				s += '</div>';
			}
			else if (opts.theme) {
				s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">';
				if ( opts.title ) {
					s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
				}
				s += '<div class="ui-widget-content ui-dialog-content"></div>';
				s += '</div>';
			}
			else if (full) {
				s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>';
			}
			else {
				s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>';
			}
			lyr3 = $(s);

			// if we have a message, style it
			if (msg) {
				if (opts.theme) {
					lyr3.css(themedCSS);
					lyr3.addClass('ui-widget-content');
				}
				else
					lyr3.css(css);
			}

			// style the overlay
			if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/)
				lyr2.css(opts.overlayCSS);
			lyr2.css('position', full ? 'fixed' : 'absolute');

			// make iframe layer transparent in IE
			if (msie || opts.forceIframe)
				lyr1.css('opacity',0.0);

			//$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
			var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
			$.each(layers, function() {
				this.appendTo($par);
			});

			if (opts.theme && opts.draggable && $.fn.draggable) {
				lyr3.draggable({
					handle: '.ui-dialog-titlebar',
					cancel: 'li'
				});
			}

			// ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
			var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0);
			if (ie6 || expr) {
				// give body 100% height
				if (full && opts.allowBodyStretch && $.support.boxModel)
					$('html,body').css('height','100%');

				// fix ie6 issue when blocked element has a border width
				if ((ie6 || !$.support.boxModel) && !full) {
					var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
					var fixT = t ? '(0 - '+t+')' : 0;
					var fixL = l ? '(0 - '+l+')' : 0;
				}

				// simulate fixed position
				$.each(layers, function(i,o) {
					var s = o[0].style;
					s.position = 'absolute';
					if (i < 2) {
						if (full)
							s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"');
						else
							s.setExpression('height','this.parentNode.offsetHeight + "px"');
						if (full)
							s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"');
						else
							s.setExpression('width','this.parentNode.offsetWidth + "px"');
						if (fixL) s.setExpression('left', fixL);
						if (fixT) s.setExpression('top', fixT);
					}
					else if (opts.centerY) {
						if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
						s.marginTop = 0;
					}
					else if (!opts.centerY && full) {
						var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0;
						var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
						s.setExpression('top',expression);
					}
				});
			}

			// show the message
			if (msg) {
				if (opts.theme)
					lyr3.find('.ui-widget-content').append(msg);
				else
					lyr3.append(msg);
				if (msg.jquery || msg.nodeType)
					$(msg).show();
			}

			if ((msie || opts.forceIframe) && opts.showOverlay)
				lyr1.show(); // opacity is zero
			if (opts.fadeIn) {
				var cb = opts.onBlock ? opts.onBlock : noOp;
				var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
				var cb2 = msg ? cb : noOp;
				if (opts.showOverlay)
					lyr2._fadeIn(opts.fadeIn, cb1);
				if (msg)
					lyr3._fadeIn(opts.fadeIn, cb2);
			}
			else {
				if (opts.showOverlay)
					lyr2.show();
				if (msg)
					lyr3.show();
				if (opts.onBlock)
					opts.onBlock.bind(lyr3)();
			}

			// bind key and mouse events
			bind(1, el, opts);

			if (full) {
				pageBlock = lyr3[0];
				pageBlockEls = $(opts.focusableElements,pageBlock);
				if (opts.focusInput)
					setTimeout(focus, 20);
			}
			else
				center(lyr3[0], opts.centerX, opts.centerY);

			if (opts.timeout) {
				// auto-unblock
				var to = setTimeout(function() {
					if (full)
						$.unblockUI(opts);
					else
						$(el).unblock(opts);
				}, opts.timeout);
				$(el).data('blockUI.timeout', to);
			}
		}

		// remove the block
		function remove(el, opts) {
			var count;
			var full = (el == window);
			var $el = $(el);
			var data = $el.data('blockUI.history');
			var to = $el.data('blockUI.timeout');
			if (to) {
				clearTimeout(to);
				$el.removeData('blockUI.timeout');
			}
			opts = $.extend({}, $.blockUI.defaults, opts || {});
			bind(0, el, opts); // unbind events

			if (opts.onUnblock === null) {
				opts.onUnblock = $el.data('blockUI.onUnblock');
				$el.removeData('blockUI.onUnblock');
			}

			var els;
			if (full) // crazy selector to handle odd field errors in ie6/7
				els = $(document.body).children().filter('.blockUI').add('body > .blockUI');
			else
				els = $el.find('>.blockUI');

			// fix cursor issue
			if ( opts.cursorReset ) {
				if ( els.length > 1 )
					els[1].style.cursor = opts.cursorReset;
				if ( els.length > 2 )
					els[2].style.cursor = opts.cursorReset;
			}

			if (full)
				pageBlock = pageBlockEls = null;

			if (opts.fadeOut) {
				count = els.length;
				els.stop().fadeOut(opts.fadeOut, function() {
					if ( --count === 0)
						reset(els,data,opts,el);
				});
			}
			else
				reset(els, data, opts, el);
		}

		// move blocking element back into the DOM where it started
		function reset(els,data,opts,el) {
			var $el = $(el);
			if ( $el.data('blockUI.isBlocked') )
				return;

			els.each(function(i,o) {
				// remove via DOM calls so we don't lose event handlers
				if (this.parentNode)
					this.parentNode.removeChild(this);
			});

			if (data && data.el) {
				data.el.style.display = data.display;
				data.el.style.position = data.position;
				data.el.style.cursor = 'default'; // #59
				if (data.parent)
					data.parent.appendChild(data.el);
				$el.removeData('blockUI.history');
			}

			if ($el.data('blockUI.static')) {
				$el.css('position', 'static'); // #22
			}

			if (typeof opts.onUnblock == 'function')
				opts.onUnblock(el,opts);

			// fix issue in Safari 6 where block artifacts remain until reflow
			var body = $(document.body), w = body.width(), cssW = body[0].style.width;
			body.width(w-1).width(w);
			body[0].style.width = cssW;
		}

		// bind/unbind the handler
		function bind(b, el, opts) {
			var full = el == window, $el = $(el);

			// don't bother unbinding if there is nothing to unbind
			if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
				return;

			$el.data('blockUI.isBlocked', b);

			// don't bind events when overlay is not in use or if bindEvents is false
			if (!full || !opts.bindEvents || (b && !opts.showOverlay))
				return;

			// bind anchors and inputs for mouse and key events
			var events = 'mousedown mouseup keydown keypress keyup touchstart touchend touchmove';
			if (b)
				$(document).on(events, opts, handler);
			else
				$(document).off(events, handler);

		// former impl...
		//		var $e = $('a,:input');
		//		b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
		}

		// event handler to suppress keyboard/mouse events when blocking
		function handler(e) {
			// allow tab navigation (conditionally)
			if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) {
				if (pageBlock && e.data.constrainTabKey) {
					var els = pageBlockEls;
					var fwd = !e.shiftKey && e.target === els[els.length-1];
					var back = e.shiftKey && e.target === els[0];
					if (fwd || back) {
						setTimeout(function(){focus(back);},10);
						return false;
					}
				}
			}
			var opts = e.data;
			var target = $(e.target);
			if (target.hasClass('blockOverlay') && opts.onOverlayClick)
				opts.onOverlayClick(e);

			// allow events within the message content
			if (target.parents('div.' + opts.blockMsgClass).length > 0)
				return true;

			// allow events for content that is not being blocked
			return target.parents().children().filter('div.blockUI').length === 0;
		}

		function focus(back) {
			if (!pageBlockEls)
				return;
			var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
			if (e)
				e.trigger( 'focus' );
		}

		function center(el, x, y) {
			var p = el.parentNode, s = el.style;
			var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
			var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
			if (x) s.left = l > 0 ? (l+'px') : '0';
			if (y) s.top  = t > 0 ? (t+'px') : '0';
		}

		function sz(el, p) {
			return parseInt($.css(el,p),10)||0;
		}

	}


	/*global define:true */
	if (typeof define === 'function' && define.amd && define.amd.jQuery) {
		define(['jquery'], setup);
	} else {
		setup(jQuery);
	}

})();