// namespace
var ETM = {};

//gestion du background fixe
ETM.fixBg = {
	init: function(select,offX,offY){
		if(offX.lastIndexOf('%') != -1){
			var img = new Image();
			img.src = select.currentStyle.backgroundImage.substring(5,Number(select.currentStyle.backgroundImage.length-2));
			var tempX = Number(offX.substring(0,offX.lastIndexOf('%')));
			tempX = Number((((document.documentElement.clientWidth-img.width)*tempX)/100)+document.documentElement.scrollLeft-select.offsetLeft)+'px';
		}
		else{
			var tempX = Number(offX.split("px")[0]);
			tempX = Number(tempX+document.documentElement.scrollLeft-select.offsetLeft)+'px';
		}
		if(offY.lastIndexOf("%") != -1){
			var img = new Image();
			img.src = select.currentStyle.backgroundImage.substring(5,Number(select.currentStyle.backgroundImage.length-2));
			var tempY = Number(offY.substring(0,offY.lastIndexOf('%')));
			tempY = Number((((document.documentElement.clientHeight-img.height)*tempY)/100)+document.documentElement.scrollTop-select.offsetTop)+'px';
		}
		else{
			var tempY = Number(offY.split('px')[0]);
			tempY = Number(tempY+document.documentElement.scrollTop-select.offsetTop)+'px';
		}
		return tempX+' '+tempY;
	}
};

// gestion position:fixed;
ETM.fixPos = {
	init: function(){
		var DE = document.documentElement,
			top = (DE && DE.scrollTop) || document.body.scrollTop,
			max = document.getElementById('page').scrollHeight,
			win = window.innerHeight || (DE && DE.clientHeight) || document.body.clientHeight;
		if((top + win) > max) {top = max - win;}
		return top;
	}
};

//affichage des layers
ETM.DisplayLayer = {
	init: function(bloc){
		var div = document.getElementById(bloc);
		if(!bloc) {return;}
		if((div.style.display=='none')||(div.style.display=='')){
			if((bloc=='world-map')&&(document.location.href.indexOf('/en/')!= -1)){
				var img = div.getElementsByTagName('img');
				img[img.length - 1].src = img[img.length - 1].src.replace('/fr/', '/en/');
			}
			div.style.display='block';
		}
		else{
			div.style.display='none';
		}
	}
};



//fermeture des fenetres
ETM.CloseWindow = {
	init: function(){
		if (navigator.appName.indexOf("Netscape") != -1){
			window.open('','_parent','');
			window.close()
		}
		else if (navigator.appName.indexOf("Microsoft") != -1){
			window.opener=self;
			self.close();
		}
	}
};

//ouverture popup
ETM.OpenPopup = {
	init: function(page,target,larg,haut,scraul){
		var posXpop = (screen.availWidth-larg)/2;
		var posYpop = (screen.availHeight-haut)/2;
		param = "width="+larg+",height="+haut+",left="+posXpop+",top="+posYpop+",scrollbars="+scraul;
		popup = window.open(page,target,param);
	}
};
//ouverture popup
function openWindow(url, _w, _h, scroll){
 	posX = (screen.width) ? (screen.width - _w)/ 2 : 0;
	posY = (screen.height) ? (screen.height - _h)/ 2 : 0;	
	window.focus();
	try{if( typeof(msgWindow)=='object') msgWindow.close();}catch(e){}
	msgWindow = open('','window1','top='+posY+', left='+posX+', width='+_w+', height='+_h+', menubar=no, status=yes, location=no, toolbar=no, scrollbars='+scroll);
	msgWindow.location.href = url;
	if(msgWindow.opener==null) msgWindow.opener=self;
	msgWindow.focus();
};