var gtmContainerId = "GTM-M38KXZW";
if(isProduction()) {
	gtmContainerId = "GTM-T46X3R7";
}

function isProduction() {
	if(window.location.origin == 'https://www.cignaglobal.com')
		return true;
	if(window.location.origin == 'https://de.cignaglobal.com')
		return true;
	if(window.location.origin == 'https://es.cignaglobal.com')
		return true;
	if(window.location.origin == 'https://fr.cignaglobal.com')
		return true;
	if(window.location.origin == 'https://nl.cignaglobal.com')
		return true;
	return false;
}

(function() {
    function async_load(){
        var s = document.createElement('script');
        s.type = 'text/javascript';
        
		var gtmScript1 = '(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':new Date().getTime(),event:\'gtm.js\'});'
		+'var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=\'https://www.googletagmanager.com/gtm.js?id=\'+i+dl;f.parentNode.insertBefore(j,f);})(window,document,\'script\',\'dataLayer\',\''+ gtmContainerId +'\');'
		s.innerHTML = gtmScript1;
		
        var firstScriptElement = document.getElementsByTagName('script')[0];
        firstScriptElement.parentNode.insertBefore(s, firstScriptElement);
		
		var gtmNoScript = document.createElement('noscript');
		var gtmIframe = document.createElement('iframe');
		gtmIframe.src = "https://www.googletagmanager.com/ns.html?id="+gtmContainerId;
		gtmIframe.height = 0;
		gtmIframe.width = 0;
		gtmIframe.frameBorder = 0;
		gtmIframe.style = "display:none;visibility:hidden";
		gtmNoScript.appendChild(gtmIframe);
		var body = document.getElementsByTagName('body')[0];
		body.insertBefore(gtmNoScript, body.childNodes[0]);
    }
	if(!gtmContainerId || gtmContainerId.length === 0) {
		console.error("GTM Container Id is null");
	} else {
	    if (window.attachEvent)
			window.attachEvent('onload', async_load);
		else
			window.addEventListener('load', async_load, false);
	}
})();