function gup(name) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function getAbsoluteLeft(objectId) {
	var o = document.getElementById(objectId); var oLeft = o.offsetLeft ;
	while(o.offsetParent!=null) { oParent = o.offsetParent; oLeft += oParent.offsetLeft; o = oParent; }
	return oLeft; }
function getAbsoluteTop(objectId) {
	var o = document.getElementById(objectId); var oTop = o.offsetTop;
	while(o.offsetParent!=null) { oParent = o.offsetParent; oTop += oParent.offsetTop; o = oParent; }
	return oTop; }

function overLocations(obj,clas) { 
	outLocationDrop = 0;
	if (clas!='!') { document.getElementById(obj.id).className=clas+'over'; }
	if (obj.id=='location_choice') { 
		document.getElementById('location_choice_drop').style.left=getAbsoluteLeft(obj.id)+"px";
		document.getElementById('location_choice_drop').style.top=getAbsoluteTop(obj.id)+"px";
		document.getElementById('location_choice_drop').style.display='block';
	}
}
function overLanguages(obj,clas) { 
	outLanguageDrop = 0;
	if (clas!='!') { document.getElementById(obj.id).className=clas+'over'; }
	if (obj.id=='language_choice') { 
		document.getElementById('language_choice_drop').style.left=getAbsoluteLeft(obj.id)+"px";
		document.getElementById('language_choice_drop').style.top=getAbsoluteTop(obj.id)+"px";
		document.getElementById('language_choice_drop').style.display='block';
	}
}
var outLocationDrop = 0;
var outLanguageDrop = 0;

function outLocations(obj,clas) { 
	if (clas!='!') { document.getElementById(obj.id).className=clas+'normal'; }
	if (obj=='closelocationdrop') { if (outLocationDrop==0) { outLocationDrop = 2; } }
}
function outLanguages(obj,clas) { 
	if (clas!='!') { document.getElementById(obj.id).className=clas+'normal'; }
	if (outLanguageDrop==0) {outLanguageDrop = 2;}
}
function closeLocations() {
	if (outLocationDrop>0) {
		outLocationDrop--;
		if (outLocationDrop==0) {
			if (document.getElementById('location_choice').className.indexOf('normal')<0) { 
			document.getElementById('location_choice').className='location_choice_normal';	}
			document.getElementById('location_choice_drop').style.display='none';
		}
	}
	closeLanguages();
}
function closeLanguages() {
	if (outLanguageDrop>0) {
		outLanguageDrop--;
		if (outLanguageDrop==0) {
			if (document.getElementById('language_choice').className.indexOf('normal')<0) { 
			document.getElementById('language_choice').className='language_choice_normal';	}
			document.getElementById('language_choice_drop').style.display='none';
		}
	}
}
window.setInterval('closeLocations()',100);

var locationList = new Array();
var languageList = new Array();
var officeConvert = new Array();
officeConvert[1] = 0;
officeConvert[2] = 5;
officeConvert[3] = 2;
officeConvert[4] = 1;
officeConvert[5] = 3;
officeConvert[6] = 4;
officeConvert[0] = 6;


var selectACountry = 'Select a country';

var myDomain = document.domain;
var pageid = gup('id');
if (pageid == '') {
	pageid = 1;
}
var lang = gup('L');
var office = gup('office');
var wanted = 6;
var wantedlang = 0;
var apple = 1;

var officeurl = '&office=';
if (office == '') {
	officeurl = '';
} else {
	officeurl += office;
}

switch(myDomain) {
case 'www.finalyse.fr':
case 'www.finalyse.fr.t3.finalyse.hu':
  (office == '') ? office = '4' : apple = 0;
  (lang == '') ? lang = '4' : apple = 0;
  wanted = officeConvert[office];
  break;
case 'www.finalyse.hu':
case 'www.finalyse.hu.t3.finalyse.hu':
  (office == '') ? office = '6' : apple = 0;
  (lang == '') ? lang = '8' : apple = 0;
  wanted = officeConvert[office];
  break;
case 'www.finalyse.pl':
case 'www.finalyse.pl.t3.finalyse.hu':
  (office == '') ? office = '5' : apple = 0;
  (lang == '') ? lang = '7' : apple = 0;
  wanted = officeConvert[office];
  break;
case 'www.finalyse.be':
case 'www.finalyse.be.t3.finalyse.hu':
  (office == '') ? office = '1' : apple = 0;
  (lang == '') ? lang = '4' : apple = 0;
  wanted = officeConvert[office];
  break;
case 'www.finalyse-amsterdam.com':
case 'www.finalyse-amsterdam.com.t3.finalyse.hu':
  (office == '') ? office = '2' : apple = 0;
  (lang == '') ? lang = '0' : apple = 0;
  wanted = officeConvert[office];
  break;
case 'www.finalyse.lu':
case 'www.finalyse.lu.t3.finalyse.hu':
  (office == '') ? office = '3' : apple = 0;
  (lang == '') ? lang = '4' : apple = 0;
  wanted = officeConvert[office];
  break;
default:
  (office == '') ? office = '0' : apple = 0;
  (lang == '') ? lang = '0' : apple = 0;
  wanted = officeConvert[office];
}

var langurl = '&L=';
langurl += lang;

var targetDomainList = new Array();
if (0) {
targetDomainList[1] = 'https://www.finalyse.be.t3.finalyse.hu';
targetDomainList[2] = 'https://www.finalyse-amsterdam.com.t3.finalyse.hu';
targetDomainList[3] = 'https://www.finalyse.lu.t3.finalyse.hu';
targetDomainList[4] = 'https://www.finalyse.fr.t3.finalyse.hu';
targetDomainList[5] = 'https://www.finalyse.pl.t3.finalyse.hu';
targetDomainList[6] = 'https://www.finalyse.hu.t3.finalyse.hu';
targetDomainList[7] = 'https://www.finalyse.com.t3.finalyse.hu';
}
targetDomainList[1] = 'http://www.finalyse.be';
targetDomainList[2] = 'http://www.finalyse-amsterdam.com';
targetDomainList[3] = 'http://www.finalyse.lu';
targetDomainList[4] = 'http://www.finalyse.fr';
targetDomainList[5] = 'http://www.finalyse.pl';
targetDomainList[6] = 'http://www.finalyse.hu';
targetDomainList[7] = 'http://www.finalyse.com';

var labelList = new Array();
var languageLabelList = new Array();

switch(lang) {
case '4':
  labelList[1] = 'Finalyse Bruxelles';
  labelList[2] = 'Finalyse Amsterdam';
  labelList[3] = 'Finalyse Luxembourg';
  labelList[4] = 'Finalyse Paris';
  labelList[5] = 'Finalyse Varsovie';
  labelList[6] = 'Finalyse Budapest';
  labelList[7] = 'Finalyse Group';
  languageLabelList[0] = 'anglais';
  languageLabelList[4] = 'fran&#231;ais';
  languageLabelList[5] = 'allemand';
  languageLabelList[7] = 'polonais';
  languageLabelList[8] = 'hongrois';
  wantedlang = 1;
  selectACountry = 'Select a counrty [fr]';
  break;
case '5':
  labelList[1] = 'Finalyse Brüssel';
  labelList[2] = 'Finalyse Amsterdam';
  labelList[3] = 'Finalyse Luxemburg';
  labelList[4] = 'Finalyse Paris';
  labelList[5] = 'Finalyse Warschau';
  labelList[6] = 'Finalyse Budapest';
  labelList[7] = 'Finalyse Group';
  languageLabelList[0] = 'englisch';
  languageLabelList[4] = 'französisch';
  languageLabelList[5] = 'deutsch';
  languageLabelList[7] = 'polnisch';
  languageLabelList[8] = 'ungarisch';
  wantedlang = 2;
  selectACountry = 'W&#228;hlen Sie ein Land';
  break;
case '8':
  labelList[1] = 'Finalyse Brüsszel';
  labelList[2] = 'Finalyse Amszterdam';
  labelList[3] = 'Finalyse Luxemburg';
  labelList[4] = 'Finalyse Párizs';
  labelList[5] = 'Finalyse Varsó';
  labelList[6] = 'Finalyse Budapest';
  labelList[7] = 'Finalyse Csoport';
  languageLabelList[0] = 'angol';
  languageLabelList[4] = 'francia';
  languageLabelList[5] = 'német';
  languageLabelList[7] = 'lengyel';
  languageLabelList[8] = 'magyar';
  wantedlang = 3;
  selectACountry = 'Válasszon egy országot';
  break;
case '7':
  labelList[1] = 'Finalyse Bruksela';
  labelList[2] = 'Finalyse Amsterdam';
  labelList[3] = 'Finalyse Luksemburg';
  labelList[4] = "Finalyse Pary&#380;";
  labelList[5] = 'Finalyse Warszawa';
  labelList[6] = 'Finalyse Budapeszt';
  labelList[7] = 'Finalyse Group';
  languageLabelList[0] = 'angielski';
  languageLabelList[4] = 'francuski';
  languageLabelList[5] = 'niemiecki';
  languageLabelList[7] = 'polski';
  languageLabelList[8] = 'w&#281;gierski';
  wantedlang = 2;
  selectACountry = 'Select a counrty [pl]';
  break;
default:
  labelList[1] = 'Finalyse Brussels';
  labelList[2] = 'Finalyse Amsterdam';
  labelList[3] = 'Finalyse Luxembourg';
  labelList[4] = 'Finalyse Paris';
  labelList[5] = 'Finalyse Warsaw';
  labelList[6] = 'Finalyse Budapest';
  labelList[7] = 'Finalyse Group';
  languageLabelList[0] = 'English';
  languageLabelList[4] = 'French';
  languageLabelList[5] = 'German';
  languageLabelList[7] = 'Polish';
  languageLabelList[8] = 'Hungarian';
  wantedlang = 0;
  selectACountry = 'Select a counrty';
}

tmpList = new Array(); tmpList.name = 'be'; tmpList.text = labelList[1]; tmpList.url = targetDomainList[1] + '/index.php?id='+pageid+langurl+'&office=1';
locationList.push(tmpList);
tmpList = new Array(); tmpList.name = 'fr'; tmpList.text = labelList[4]; tmpList.url = targetDomainList[4] + '/index.php?id='+pageid+langurl+'&office=4';
locationList.push(tmpList);
tmpList = new Array(); tmpList.name = 'lu'; tmpList.text = labelList[3]; tmpList.url = targetDomainList[3] + '/index.php?id='+pageid+langurl+'&office=3';
locationList.push(tmpList);
tmpList = new Array(); tmpList.name = 'pl'; tmpList.text = labelList[5]; tmpList.url = targetDomainList[5] + '/index.php?id='+pageid+langurl+'&office=5';
locationList.push(tmpList);
tmpList = new Array(); tmpList.name = 'hu'; tmpList.text = labelList[6]; tmpList.url = targetDomainList[6] + '/index.php?id='+pageid+langurl+'&office=6';
locationList.push(tmpList);
tmpList = new Array(); tmpList.name = 'eu'; tmpList.text = labelList[2]; tmpList.url = targetDomainList[2] + '/index.php?id='+pageid+langurl+'&office=2';
locationList.push(tmpList);
tmpList = new Array(); tmpList.name = 'com'; tmpList.text = labelList[7]; tmpList.url = targetDomainList[7] + '/index.php?id='+pageid+langurl+'&office=0';
locationList.push(tmpList);

tmpList = new Array(); tmpList.name = 'en'; tmpList.text = languageLabelList[0]; tmpList.url = 'http://'+myDomain+'/index.php?id='+pageid+'&L=0'+officeurl;
languageList.push(tmpList);
tmpList = new Array(); tmpList.name = 'fr'; tmpList.text = languageLabelList[4]; tmpList.url = 'http://'+myDomain+'/index.php?id='+pageid+'&L=4'+officeurl;
languageList.push(tmpList);
//tmpList = new Array(); tmpList.name = 'de'; tmpList.text = languageLabelList[5]; tmpList.url = 'http://'+myDomain+'/index.php?id='+pageid+'&L=5'+officeurl;
//languageList.push(tmpList);
tmpList = new Array(); tmpList.name = 'pl'; tmpList.text = languageLabelList[7]; tmpList.url = 'http://'+myDomain+'/index.php?id='+pageid+'&L=7'+officeurl;
languageList.push(tmpList);
tmpList = new Array(); tmpList.name = 'hu'; tmpList.text = languageLabelList[8]; tmpList.url = 'http://'+myDomain+'/index.php?id='+pageid+'&L=8'+officeurl;
languageList.push(tmpList);

function autoConfigLocations() {
	var url = document.location.href;
	var htmlChoice = '';
	var htmlDrop = '';
	for (var i = 0; i < locationList.length; i++) {
		if (
			/*(document.location.href.indexOf(locationList[i].url)>-1) ||*/
			( (i == wanted) && (htmlChoice=='') ) ) { 
			htmlChoice = '<a href="'+locationList[i].url+'" id="location_choice_link" class="location_choice_'+locationList[i].name+'">'+locationList[i].text+'</a>';
		} else {
			if (htmlDrop=='') { htmlDrop+='<div class="header"></div><div class="content">'; }
			htmlDrop+='<div id="location_choice_drop-'+locationList[i].name+'" class="location_drop_normal"';
			htmlDrop+=' onMouseOver="overLocations(this,\'location_drop_\')" onMouseOut="outLocations(this,\'location_drop_\')">';
			htmlDrop+='<a href="'+locationList[i].url+'" class="location_choice_'+locationList[i].name+'">'+locationList[i].text+'</a>';
			htmlDrop+='</div>';
		}
	}
	if (htmlDrop!='') { htmlDrop+='</div>'; }
	document.getElementById('location_choice').innerHTML=htmlChoice;
	document.getElementById('location_choice_drop').innerHTML=htmlDrop;
}

function autoLanguageMenu() {
	var url = document.location.href;
	var htmlChoice = '';
	var htmlDrop = '';
	for (var i = 0; i < languageList.length; i++) {
		if (
			( (i == wantedlang) && (htmlChoice=='') ) ) { 
			htmlChoice = '<a href="'+languageList[i].url+'" id="language_choice_link" class="language_choice_'+languageList[i].name+'">'+languageList[i].text+'</a>';
		} else {
			if (htmlDrop=='') { htmlDrop+='<div class="header"></div><div class="content">'; }
			htmlDrop+='<div id="language_choice_drop-'+languageList[i].name+'" class="language_drop_normal"';
			htmlDrop+=' onMouseOver="overLanguages(this,\'language_drop_\')" onMouseOut="outLanguages(this,\'language_drop_\')">';
			htmlDrop+='<a href="'+languageList[i].url+'" class="language_choice_'+languageList[i].name+'">'+languageList[i].text+'</a>';
			htmlDrop+='</div>';
		}
	}
	if (htmlDrop!='') { htmlDrop+='</div>'; }
	document.getElementById('language_choice').innerHTML=htmlChoice;
	document.getElementById('language_choice_drop').innerHTML=htmlDrop;
}

function officeContactMenu() {
  var htmlSelect = '<option value="" selected>'+selectACountry+'</option>';
  htmlSelect+='<option value="/index.php?id=101'+langurl+officeurl+'#c250">'+labelList[7]+'</option>';
  htmlSelect+='<option value="/index.php?id=101'+langurl+officeurl+'#c186">'+labelList[1]+'</option>';
  htmlSelect+='<option value="/index.php?id=101'+langurl+officeurl+'#c189">'+labelList[4]+'</option>';
  htmlSelect+='<option value="/index.php?id=101'+langurl+officeurl+'#c188">'+labelList[3]+'</option>';
  htmlSelect+='<option value="/index.php?id=101'+langurl+officeurl+'#c187">'+labelList[6]+'</option>';
  htmlSelect+='<option value="/index.php?id=101'+langurl+officeurl+'#c190">'+labelList[5]+'</option>';
  htmlSelect+='<option value="/index.php?id=101'+langurl+officeurl+'#c185">'+labelList[2]+'</option>';
	document.getElementById('map_dropdown').innerHTML=htmlSelect;
}

