﻿/* Scrip has to be included before the closing body-tags of the site 
 - ChannelInfo
    press 1,5
    entry 1,6
    about 1,7
    contact 1,8
    responsibility 1,9
    corp    1,10
*/
var MetrixLab_ForceData='1,10';
var loc = location.href.split("/");

//MetrixLab_BasePath keeps location of the overlay.js
var MetrixLab_BasePath = '';
// MetrixLab language. 'en' ist default
var MetrixLab_LangId = PAGE_LANG == 'de'?'de':'en' ;  

// change path to the site id file for different environments
switch (window.location.host) {
	// #### dev server ####
	case 'edit.siemens.dev.publicis.de':
		MetrixLab_BasePath = '/cc/corp_nwa/root/framework/metrix_lab/' + MetrixLab_LangId + '/';
		break;

	// #### stage server ####
	case 'stage.siemens.com':
		MetrixLab_BasePath = '/cc/corp/nwa/framework/metrix_lab/' + MetrixLab_LangId + '/';
		break;
		
	// #### backstage server ####
	case 'backstage.siemens.com':
		MetrixLab_BasePath = 'https://backstage.siemens.com/cc/corp/nwa/framework/metrix_lab/' + MetrixLab_LangId + '/';
		break;
		
	// #### path defaults to live configuration ####
	default:
		MetrixLab_BasePath = '/corp/framework/metrix_lab/' + MetrixLab_LangId + '/';
		break;
}


function metrixlab_onready(el, func){
	this.args = new Array(el, func);
	this.doTry = function(){try{var el = eval(this.args[0]);el.onload = this.args[1];el.onload();clearInterval(this.args[2]);}catch(e){}}
	this.doTry.bind = function(object){	var method = this;	return function(){method.apply(object);	}}
	this.args[2] = setInterval(this.doTry.bind(this), 250);
	return this;
}

new metrixlab_onready("document", function(){
	if(top != self) return;
	var metrixlab_body = top.document.getElementsByTagName('body').item(0);
	var metrixlab_script = top.document.createElement('script');
	metrixlab_script.setAttribute('defer','defer');
	metrixlab_script.src = MetrixLab_BasePath+'overlay.js';
	metrixlab_script.type='text/javascript';
	metrixlab_body.insertBefore(metrixlab_script, metrixlab_body.childNodes[0]);
});
