function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
        }
    }
    return false;
};
setTimeout(setLinks, 2000);
setTimeout(setQ, 100);
function setLinks(){
	$(".ad-uniheader__logo-container--link").attr("href","https://www.bynder.com/en/");
}
function setQ(){
	var q = getUrlParameter('q');
	if(q != false){
		q=q.replace("+"," ");
		$(".searchinput").attr("value",q);
	}
	$("button[data-auto='clear-filters']").click(function(){
		window.location.href = window.location.pathname
	});
}
function scrollWithOffset(hashtag,navOffset) {
    if ($(hashtag).offset() != null) {
        $('html, body').animate({
            scrollTop: $(hashtag).offset().top - navOffset
        }, 300);
    }
}
function readCookie(name) {
    return(document.cookie.match('(^|; )'+name+'=([^;]*)')||0)[2];
}
function createCookie(name,value,days,global=false) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    if(global){
        document.cookie = name+"="+value+expires+"; domain=.bynder.com; path=/;secure;SameSite=Strict";
    }else{
        document.cookie = name +"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;Domain=.bynder.com";
        document.cookie = name+"="+value+expires+"; path=/;secure;SameSite=Strict";
    }
    
}
function eraseCookie(name) {
    createCookie(name,"",-1);
}
function deleteAllCookies() {
    var cookies = document.cookie.split(";");
    for (var i = 0; i < cookies.length; i++) {
        var cookie = cookies[i];
        var eqPos = cookie.indexOf("=");
        var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
        document.cookie = name +`=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;Domain=.bynder.com`;
    }
}
function getParameterByName(name, 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, ' '));
}
function loadScriptsBasedOnConsent(consentType) {
    $("script[data-cookieconsent='" + consentType + "']").each(function() {
        eval($(this).text());
        $(this).attr("data-cookieconsent", "loaded");
    });
}
var region="undefined";
$(document).ready(function() {
    if($(".scrollto").length) {
        $('.scrollto').on('click', function(e) {		
            var navOffset = $(".profile_header").height()+90;
            e.preventDefault();
            var hashtag = this.hash;
            scrollWithOffset(hashtag,navOffset);
        });
    }
    $(".tertiary-nav--item").click(function(){
        $(".tertiary-nav--item").removeClass("is-selected");
        $(this).addClass("is-selected");
    });
    
    var utmsource = getParameterByName('utm_source');
	var utmterm = getParameterByName('utm_term');
	var utmmedium = getParameterByName('utm_medium');
	var utmcampaign = getParameterByName('utm_campaign');
	var gclid = getParameterByName('gclid');

	if(utmsource!=null){
		$("[name='utm_source']").val(utmsource);
	}
	if(utmterm!=null){
		$("[name='utm_term']").val(utmterm);
	}
	if(utmmedium!=null){
		$("[name='utm_medium']").val(utmmedium);
	}
	if(utmcampaign!=null){
		$("[name='utm_campaign']").val(utmcampaign);
	}
	if(gclid!=null){
		$("[name='GCLID']").val(gclid);
	}
    if(readCookie("COUNTRYISO") === undefined)
    {
        $('.countrycontainer').removeClass("hidden");
    }else{
        var iso = readCookie("COUNTRYISO");
        $('select[name="country"] option[value="'+iso+'"]').attr("selected","selected");
        $('select[name="country"]').val(iso);
        var name = $('select[name="country"] option[value="'+iso+'"]').text();
        $(".js-form-country .js-dropdown-placeholder").text(name);
        if(iso == "US"){
            var stateSection = $("#lead-form-modal").find('.js-form-state');
            stateSection.removeClass("hidden");
            $('.countrycontainer').removeClass("hidden");
        }else{
            var stateSection = $("#lead-form-modal").find('.js-form-state');
            stateSection.addClass("hidden");
        }
		
    }
	var nocheck = "";
	var yescheck = "";

	$(".js-profile-lead-form").click(function(){
		$("#source").attr("value","Bynder Marketplace");
		if($("#opt_in_1").val() == "no"){
			nocheck = $("#opt_in_1");
			yescheck = $("#opt_in_2");
		}else{
			nocheck = $("#opt_in_2");
			yescheck = $("#opt_in_1");
		}
		/*defaulting to no*/
		nocheck.prop('checked',true);
		$(".js-checkbox").click(function(){
			if(yescheck.prop('checked'))
			{
				nocheck.prop('checked',false);
			}else{
				nocheck.prop('checked',true);
			}
		});
	});
var cookietype='cookietest-b';
var marketingchecked='';
var analyticalchecked='';
var cnil = '<span class="rejectcookies pull-left ML-8 white" title="Reject cookies">Reject</span>'
var cookieintro ='<h4>We use cookies</h4> <p class="hidemobile">Welcome! With your permission, we would like to use cookies to personalize your experience, analyze how you use our website and assist in our marketing efforts. If you click on "Allow all cookies" you agree to the use of these cookies. If you wish to choose the cookies you want to enable, press "<span class="cookiedetails cookiedetailslink">cookie settings</span>". Find more information in our <a href="https://www.bynder.com/en/legal/privacy-policy/" title="privacy policy" target="_blank">privacy policy</a> and <a href="https://www.bynder.com/en/legal/cookie-policy/" target="_blank" title="cookie policy">cookie policy</a>.</p><div class="cookiechoices"> <span class="cookiebuttoncontainer"> <span class="btn btn-primary allcookies pull-left savecookiepreferences">Allow all cookies</span> '+cnil+'</span>';
if(readCookie('MARKETINGCONSENT') == '1'){
    marketingchecked='checked="checked"';
}
if(readCookie('ANALYTICALCONSENT') == '1'){
    analyticalchecked='checked="checked"';
}
if(window.location.hostname != "localhost")
{
$("body").append('<div id="cookieconsent" class="cookieconsenten '+cookietype+'" style="display:none"> <div class="container"> <div class="padding-m"> <div class="row"> <div class="col-md-12">'+cookieintro+'</div><div class="cookieinformation hidden"><div class="offset-md-2 col-md-10"><div class="cookiechoices"> <span class="basicclickable dbmobile"> <input type="checkbox" disabled="disabled" checked="checked" id="basicconsent"/> <label for="basicconsent">Functional</label> </span> <span class="dbmobile"><input type="checkbox" '+analyticalchecked+' id="analyticalconsent"/> <label for="analyticalconsent">Analytical</label></span> <span class="dbmobile"><input type="checkbox" '+marketingchecked+' id="marketingconsent"/> <label for="marketingconsent">Marketing</label></span> <span class="cookiebuttoncontainer pull-right m30"><span class="btn btn-primary btn-sm customcookiepreferences">Save</span></div></div> <ul class="nav-pills nav-stacked col-md-2"> <li class="active"><span href="#basic">Functional</span></li><li><span href="#analytical">Analytical</span></li><li><span href="#marketing">Marketing</span></li></ul> <div class="tab-content col-md-10"> <div id="basic" class="tab-pane active"><p>The cookies listed below are necessary for the proper functioning of our website. These cookies help us, among other things, to track errors in our Website, which allows us to improve the functioning of the Website. These cookies also make sure you can use our Website in a secure environment and also, for example, that you can save your login data and your preferred language, so you will not have to keep entering this every time you use the Website.</p><table class="table"> <thead> <tr> <td>Name</td><td>Provider</td><td>Purpose</td><td>Expiry</td></tr></thead> <tbody class="basiccookiecontainer"></tbody> </table> </div><div id="analytical" class="tab-pane"> <p>The cookies listed below are analytical cookies, which are cookies that are used to gain insight into the use of the Website and our Products. These cookies allow us to improve the Website in terms of quality and effectivity and help us to understand how visitors interact with our website by collecting and analyzing information anonymously.</p><table class="table"> <thead> <tr> <td>Name</td><td>Provider</td><td>Purpose</td><td>Expiry</td></tr></thead> <tbody class="analyticalcookiecontainer"> </tbody> </table> </div><div id="marketing" class="tab-pane"> <p>The cookies listed below are marketing cookies, which are cookies that are used by us to be able to improve your browsing experience and to learn your preferences, so that we can improve our marketing strategy and provide you with tailored offers. Marketing cookies are also needed to make use of embedded video services.</p><table class="table"> <thead> <tr> <td>Name</td><td>Provider</td><td>Purpose</td><td>Expiry</td></tr></thead> <tbody class="marketingcookiecontainer"> </tbody> </table> </div></div></div></div></div></div></div></div>');
}
var showconsentboxes=true;
var cookieinfoloaded=false;
window.dataLayer = window.dataLayer || [];
if(location.search.substring(1) == "cookies"){
	createCookie("MARKETINGCONSENT","1",365,true);
	createCookie("ANALYTICALCONSENT","1",365,true);
	createCookie("CONSENTSHOWN","yes",365,true);
}
setTimeout(() => {
	if(region=="eu" || region=="undefined"){
		$(".rejectcookies").removeClass("white");
		if(readCookie('CONSENTSHOWN') == 'yes'){
			$("#analyticalconsent").removeAttr("disabled");
			if(readCookie('ANALYTICALCONSENT') == '0'){
				$("#analyticalconsent").removeAttr("checked");
			}
		}else{
			$("#analyticalconsent").removeAttr("checked").removeAttr("disabled");
		}
	}else{
		$("#analyticalconsent").attr("checked","checked").attr("disabled","disabled");
	}
}, 1000);
if(readCookie('CONSENTSHOWN') == 'yes' && readCookie('MARKETINGCONSENT') == 1){
	if(typeof readCookie('ANALYTICALCONSENT') == 'undefined'){
		createCookie("ANALYTICALCONSENT","1",365,true);
	}
}
$(".cookiedetails").click(function(){
	if(region=="eu" || region=="undefined"){
		$(".rejectcookies").removeClass("white");
		if(readCookie('CONSENTSHOWN') == 'yes'){
			$("#analyticalconsent").removeAttr("disabled");
			if(readCookie('ANALYTICALCONSENT') == '0'){
				$("#analyticalconsent").removeAttr("checked");
			}
		}else{
			$("#analyticalconsent").removeAttr("checked").removeAttr("disabled");
		}
	}else{
		$("#analyticalconsent").attr("checked","checked").attr("disabled","disabled");
	}
	$(".cookieinformation").toggleClass("hidden");
	$(".cookiedetails").toggleClass("active");
	$("#cookieconsent").toggleClass("open");
	if($(".cookiedetails").hasClass("active")){
		$(".cookiechoices:first").addClass("hidden");
	}else{
		$(".cookiechoices:first").removeClass("hidden");
	}
	if(cookieinfoloaded == false){
       $(".analyticalcookiecontainer").append("<tr><td>_ga,_ga_*</td><td>.bynder.com</td><td>Google Analytics cookie to store and count page views.</td><td>13 months</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_gat</td><td>.bynder.com</td><td>Associated with Google Universal Analytics to throttle the request rate - limiting the collection of data on high traffic sites.</td><td>9 months</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_gid</td><td>.bynder.com</td><td>Google Analytics cookie to store and count page views.</td><td>1 day</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_gat_gtag_*</td><td>.bynder.com</td><td>Google Analytics cookie to provide technical monitoring.</td><td>1 minute</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_gcl_au</td><td>.bynder.com</td><td>To store and track conversions.</td><td>3 months</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_gac_*</td><td>.bynder.com</td><td>Contains campaign related information for the user. If you have linked your Google Analytics and Google Ads accounts</td><td>9 months</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>EXP_XXXXXX,U_entry,U_playbook</td><td>.bynder.com</td><td>We use various names for A/B testing cookies. They all start with EXP_/U_</td><td>1 year</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_biz_nA</td><td>.bynder.com</td><td>This Bizible cookie tracks the number of pages you have seen</td><td>1 year</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_biz_flagsA</td><td>.bynder.com</td><td>This Bizible cookie contains a version number</td><td>1 year</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_biz_pendingA</td><td>.bynder.com</td><td>This Bizible cookie is an empty container</td><td>1 year</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_biz_sid</td><td>.bynder.com</td><td>This Bizible cookie gives the visitor a random session ID (anonymous)</td><td>Session</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_biz_uid</td><td>.bynder.com</td><td>This Bizible cookie gives the visitor a user ID (anonymous)</td><td>1 year</td></tr>");
$(".analyticalcookiecontainer").append("<tr><td>_BUID</td><td>.bizible.com,.bizibly.com</td><td>This Bizible cookie gives the visitor a user ID (anonymous)</td><td>1 year</td></tr>");
$(".analyticalcookiecontainerproduct").append("<tr><td>AMP_XXXXXXXXXX</td><td>portal url</td><td>This cookie is used to track usage data from end users to learn how our products are used with the purpose to improve them</td><td>9 months</td></tr>");
$(".analyticalcookiecontainerproductchoice").append("<tr><td>_ga,_ga_*</td><td>portal url</td><td>Google Analytics cookie to store and count page views.</td><td>13 months</td></tr>");
$(".analyticalcookiecontainerproductchoice").append("<tr><td>_gat</td><td>portal url</td><td>Associated with Google Universal Analytics to throttle the request rate - limiting the collection of data on high traffic sites.</td><td>9 months</td></tr>");
$(".analyticalcookiecontainerproductchoice").append("<tr><td>_gid</td><td>portal url</td><td>Google Analytics cookie to store and count page views.</td><td>1 day</td></tr>");
$(".analyticalcookiecontainerproductchoice").append("<tr><td>_gat_gtag_*</td><td>portal url</td><td>Google Analytics cookie to provide technical monitoring.</td><td>1 minute</td></tr>");
$(".analyticalcookiecontainerproductchoice").append("<tr><td>_gac_*</td><td>portal url</td><td>Contains campaign related information for the user. If you have linked your Google Analytics and Google Ads accounts</td><td>9 months</td></tr>");
$(".basiccookiecontainer").append("<tr><td>__q_state_*</td><td>.bynder.com</td><td>Qualified Chat. Necessary for the functionality of the website’s chat-box function.</td><td>1 year</td></tr>");
$(".basiccookiecontainer").append("<tr><td>_vis_opt_test_cookie</td><td>.bynder.com</td><td>This is a VWO A/B testing cookie</td><td>Session</td></tr>");
$(".basiccookiecontainer").append("<tr><td>_vis_opt_*</td><td>.bynder.com</td><td>This is a VWO A/B testing cookie</td><td>3 months</td></tr>");
$(".basiccookiecontainer").append("<tr><td>_vwo_ds</td><td>.bynder.com</td><td>This is a VWO A/B testing cookie</td><td>1 month</td></tr>");
$(".basiccookiecontainer").append("<tr><td>_vwo_sn</td><td>.bynder.com</td><td>This is a VWO A/B testing cookie</td><td>30 minutes</td></tr>");
$(".basiccookiecontainer").append("<tr><td>_vwo_uuid</td><td>.bynder.com</td><td>This is a VWO A/B testing cookie</td><td>1 year</td></tr>");
$(".basiccookiecontainer").append("<tr><td>_vwo_uuid_v2</td><td>.bynder.com</td><td>This is a VWO A/B testing cookie</td><td>Session</td></tr>");
$(".basiccookiecontainer").append("<tr><td>MARKETINGCONSENT</td><td>.bynder.com</td><td>We use this cookie to store your marketing cookie preference</td><td>1 year</td></tr>");
$(".basiccookiecontainer").append("<tr><td>ANALYTICALCONSENT</td><td>.bynder.com</td><td>We use this cookie to store your analytical cookie preference</td><td>1 year</td></tr>");
$(".basiccookiecontainer").append("<tr><td>CONSENTSHOWN</td><td>.bynder.com</td><td>We use this cookie to store if we've already shown the cookie popup</td><td>1 year</td></tr>");
$(".basiccookiecontainer").append("<tr><td>REGION</td><td>.bynder.com</td><td>We use this cookie to store your region if known</td><td>1 year</td></tr>");
$(".basiccookiecontainer").append("<tr><td>COUNTRY</td><td>.bynder.com</td><td>We use this cookie to store your country if known</td><td>1 year</td></tr>");
$(".basiccookiecontainer").append("<tr><td>COUNTRYISO</td><td>.bynder.com</td><td>We use this cookie to store your country ISO value if known</td><td>1 year</td></tr>");
$(".basiccookiecontainer").append("<tr><td>CraftSessionId</td><td>.bynder.com</td><td>Our CMS sets this cookie to identify the current session</td><td>Session</td></tr>");
$(".basiccookiecontainer").append("<tr><td>CRAFT_CSRF_TOKEN</td><td>.bynder.com</td><td>Our CMS sets this cookie to secure form transmits during current session</td><td>Session</td></tr>");
$(".basiccookiecontainer").append("<tr><td>__cfduid</td><td>*.bynder.com, .cloudflare.com</td><td>Used by the content network, Cloudflare, to identify trusted web traffic.</td><td>1 year</td></tr>");
$(".basiccookiecontainerproduct").append("<tr><td>bynder</td><td>portal url</td><td>Stores a unique session ID that is temporarily linked to a brand portal user UUID and an account ID.</td><td>1 day</td></tr>");
$(".basiccookiecontainerproduct").append("<tr><td>DefaultLocale</td><td>portal url</td><td>This cookie sets the default brand portal user language. </td><td>1 day</td></tr>");
$(".basiccookiecontainerproduct").append("<tr><td>redirectToken</td><td>portal url</td><td>This cookie is used by the Guidelines module to redirect to the correct pages</td><td>10 minutes</td></tr>");
$(".basiccookiecontainerproduct").append("<tr><td>portal-notification</td><td>portal url</td><td>This cookie hides the portal pop-up notification after it's been displayed by the user</td><td>7 days</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_fbp</td><td>.bynder.com</td><td> Used by Facebook to deliver a series of advertisement products such as real time bidding from third party advertisers. (internet based targeting)</td><td>1 month</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>li_fat_id</td><td>.bynder.com</td><td>LinkedIn Uses this cookie for routing data</td><td>1 month</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>li_giant</td><td>.bynder.com</td><td>LinkedIn Uses this cookie for routing data</td><td>1 week</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_clck</td><td>.bynder.com</td><td>Bynder uses this Bing cookie for remarketing purposes</td><td>1 year</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_clsk</td><td>.bynder.com</td><td>Bynder uses this Bing cookie for remarketing purposes</td><td>1 year</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_uetsid</td><td>.bynder.com</td><td>BING stores a user ID in the LocalStorage after cookies are accepted</td><td>Session</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_uetvid</td><td>.bynder.com</td><td>BING stores a user ID expiration date</td><td>1 year</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_an_uid</td><td>.bynder.com</td><td>Bynder uses this 6Sense-cookie for personalization</td><td>1 week</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_gd_session</td><td>.bynder.com</td><td>Bynder uses this 6Sense-cookie for personalization</td><td>4 hours</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_gd_visitor</td><td>.bynder.com</td><td>Bynder uses this 6Sense-cookie for personalization</td><td>1 year</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>test_cookie</td><td>.doubleclick.net</td><td>Tests for cookie setting permissions for Doubleclick</td><td>15 minutes</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>SID, NID, HSID, DV, SIDCC, SSID, APISID, SAPISID</td><td>.google.com</td><td>Google Ads tracking code</td><td>13 months</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_hjid</td><td>.bynder.com</td><td>We use HotJar for anonymous heatmaps so we can improve our navigation</td><td>1 year</td></tr>");
$(".marketingcookiecontainer").append("<tr><td>_hjIncludedInSample</td><td>.bynder.com</td><td>We use HotJar on certain pages for anonymous heatmaps so we can improve our layout and navigation</td><td>Session</td></tr>");
		cookieinfoloaded=true;
	}
})

$(".basicclickable").click(function(){
	if($(".cookieinformation").hasClass("hidden")){
		$(".cookiedetails").click();
	}else{
		$("span[href='#basic']").click();
	}
});


$(".nav-pills li span").each(function(){
	var tab=$(this);
	tab.click(function(){
		$(".nav-pills li").removeClass("active");
		tab.parent().addClass("active");
		var tabid=tab.attr("href");
		$(".tab-pane").removeClass("active");
		$(tabid).addClass("active");
	});
});

if(readCookie('CONSENTSHOWN') == 'yes'){
	$( document ).ready(function() {
		loadScriptsBasedOnConsent('consentshown');
	});
}else{
	$("#cookieconsent").show();
	if($("#drift-widget-container").length >0){
		$("#drift-widget-container").css("z-index",1);
	}
}
var driftloaded=false;
$(".savecookiepreferences").click(function(){
	var but = $(this);
	if(but.hasClass("allcookies"))
	{
		createCookie("MARKETINGCONSENT","1",365,true);
		createCookie("ANALYTICALCONSENT","1",365,true);
		createCookie("CONSENTSHOWN","yes",365,true);
		$("#marketingconsent").prop('checked', true);
		$("#analyticalconsent").prop('checked', true);
		loadScriptsBasedOnConsent('marketing');
		loadScriptsBasedOnConsent('analytical');
		gtag('consent', 'update', {
				analytics_storage: "granted",
				ad_storage: 'granted',
				ad_personalization: 'granted',
				ad_user_data: 'granted'
			});
			window.dataLayer.push({
				event: "analytical_consent"
			});
    		window.dataLayer.push({
				event: "marketing_consent"
			});
			window.dataLayer.push({	
				'event': 'consent_update'
			});
	}
	loadScriptsBasedOnConsent('consentshown');
	$("#cookieconsent").hide();
	$("#cookieconsent").removeClass("open");
	$(".cookiechoices:first").removeClass("hidden");
	$(".cookiedetails").text("Show details");
	if(!$(".cookieinformation").hasClass("hidden")){$(".cookieinformation").addClass("hidden");}
	checkCompliance();
});

$(".rejectcookies").click(function(){
	if(region=="eu" || region=="undefined"){
		$("#analyticalconsent").removeAttr("checked").removeAttr("disabled");
		$("#marketingconsent").removeAttr("checked");
	}
	if(readCookie('MARKETINGCONSENT') == '1' && readCookie('ANALYTICALCONSENT') == '1'){
		document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
		eraseCookie("ANALYTICALCONSENT");
    	eraseCookie("MARKETINGCONSENT");
		createCookie("MARKETINGCONSENT","0",365,true);
		createCookie("ANALYTICALCONSENT","0",365,true);
		createCookie("CONSENTSHOWN","yes",365,true);
		gtag('consent', 'update', {
				analytics_storage: "denied",
				ad_storage: 'denied',
				ad_personalization: 'denied',
				ad_user_data: 'denied'
			});
			window.dataLayer.push({	
				'event': 'consent_update'
			});
	}else if(readCookie('ANALYTICALCONSENT') == '1'){
		document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
		eraseCookie("ANALYTICALCONSENT");
		eraseCookie("MARKETINGCONSENT");
		createCookie("ANALYTICALCONSENT","0",365,true);
		createCookie("CONSENTSHOWN","yes",365,true);
		gtag('consent', 'update', {
				analytics_storage: "denied"
			});
			window.dataLayer.push({	
				'event': 'consent_update'
			});
	}else if(readCookie('MARKETINGCONSENT') == '1'){
		document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
    	eraseCookie("ANALYTICALCONSENT");
		eraseCookie("MARKETINGCONSENT");
		createCookie("MARKETINGCONSENT","0",365,true);
		createCookie("CONSENTSHOWN","yes",365,true);
			gtag('consent', 'update', {
				ad_storage: 'denied',
				ad_personalization: 'denied',
				ad_user_data: 'denied'
			});
			window.dataLayer.push({	
				'event': 'consent_update'
			});
	}else{
		if(readCookie('CONSENTSHOWN') == 'yes'){
			document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
			eraseCookie("ANALYTICALCONSENT");
    		eraseCookie("MARKETINGCONSENT");
			createCookie("MARKETINGCONSENT","0",365,true);
			createCookie("ANALYTICALCONSENT","0",365,true);
			createCookie("CONSENTSHOWN","yes",365,true);
		}else{
			document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
			eraseCookie("ANALYTICALCONSENT");
    		eraseCookie("MARKETINGCONSENT");
			createCookie("MARKETINGCONSENT","0",365,true);
			createCookie("ANALYTICALCONSENT","0",365,true);
			createCookie("CONSENTSHOWN","yes",365,true);
		}
		
	}
	loadScriptsBasedOnConsent('consentshown');
	$("#cookieconsent").hide();
	$("#cookieconsent").removeClass("open");
	$(".cookiechoices:first").removeClass("hidden");
	$(".cookiedetails").text("Show details");
	if(!$(".cookieinformation").hasClass("hidden")){$(".cookieinformation").addClass("hidden");}
	checkCompliance();
});

$(".customcookiepreferences").click(function(){
	if($("#marketingconsent:checked").length >0){
		eraseCookie("ANALYTICALCONSENT");
		eraseCookie("MARKETINGCONSENT");
		createCookie("MARKETINGCONSENT","1",365,true);
		createCookie("CONSENTSHOWN","yes",365,true);
		loadScriptsBasedOnConsent('marketing');
		if($("#analyticalconsent:checked").length >0){
			createCookie("ANALYTICALCONSENT","1",365,true);
			loadScriptsBasedOnConsent('analytical');
			gtag('consent', 'update', {
				analytics_storage: "granted",
				ad_storage: 'granted',
				ad_personalization: 'granted',
				ad_user_data: 'granted'
			});
			window.dataLayer.push({
				event: "analytical_consent"
			});
			window.dataLayer.push({
				event: "marketing_consent"
			});
			window.dataLayer.push({	
				'event': 'consent_update'
			});
		}else{
			createCookie("ANALYTICALCONSENT","0",365,true);
			gtag('consent', 'update', {
				analytics_storage: "denied",
				ad_storage: 'granted',
				ad_personalization: 'granted',
				ad_user_data: 'granted'
			});
			window.dataLayer.push({
				event: "marketing_consent"
			});
			window.dataLayer.push({	
				'event': 'consent_update'
			});
		}
	}else if($("#analyticalconsent:checked").length >0){
		eraseCookie("ANALYTICALCONSENT");
		eraseCookie("MARKETINGCONSENT");
		createCookie("ANALYTICALCONSENT","1",365,true);
		createCookie("CONSENTSHOWN","yes",365,true);
		loadScriptsBasedOnConsent('analytical');
		if($("#marketingconsent:checked").length >0){
			createCookie("MARKETINGCONSENT","1",365,true);
			loadScriptsBasedOnConsent('marketing');
			gtag('consent', 'update', {
				analytics_storage: "granted",
				ad_storage: 'granted',
				ad_personalization: 'granted',
				ad_user_data: 'granted'
			});
			window.dataLayer.push({
				event: "marketing_consent"
			});
			window.dataLayer.push({
				event: "analytical_consent"
			});
			window.dataLayer.push({	
				'event': 'consent_update'
			});
		}else{
			createCookie("MARKETINGCONSENT","0",365,true);
			gtag('consent', 'update', {
				analytics_storage: "granted",
				ad_storage: 'denied',
				ad_personalization: 'denied',
				ad_user_data: 'denied'
			});
			window.dataLayer.push({	
				'event': 'consent_update'
			});
		}
	}else{
		if(readCookie('CONSENTSHOWN') == 'yes'){
			document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
			eraseCookie("ANALYTICALCONSENT");
      		eraseCookie("MARKETINGCONSENT");
			createCookie("MARKETINGCONSENT","0",365,true);
			createCookie("ANALYTICALCONSENT","0",365,true);
			createCookie("CONSENTSHOWN","yes",365,true);
			location.reload();
		}else{
			document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
			eraseCookie("ANALYTICALCONSENT");
      		eraseCookie("MARKETINGCONSENT");
			createCookie("MARKETINGCONSENT","0",365,true);
			createCookie("ANALYTICALCONSENT","0",365,true);
			createCookie("CONSENTSHOWN","yes",365,true);
		}
	}

	loadScriptsBasedOnConsent('consentshown');

	$("#cookieconsent").hide();
	$("#cookieconsent").removeClass("open");
	$(".cookiechoices:first").removeClass("hidden");
	$(".cookiedetails").text("Show details");
	$(".cookiedetails").removeClass("active");
	if(!$(".cookieinformation").hasClass("hidden")){$(".cookieinformation").addClass("hidden");}
	checkCompliance();
});
var checkCompliance = function(){
    
	if(readCookie('ANALYTICALCONSENT') == '1'){
		loadScriptsBasedOnConsent('analytical');
	}
	if(readCookie('MARKETINGCONSENT') == '1'){
		loadScriptsBasedOnConsent('marketing');
	}
	loadScriptsBasedOnConsent('consentshown');
}
$(document).ready(function() {
	
    if(window.location.hostname != "localhost")
    {
	checkCompliance();
    }
});
$(".showcookies").on("click",function() {
			$("#cookieconsent").show();
		});
});

