// Ce fichier contient le JavaScript nécessaire pour faire les rollovers,
// la fenêtre DHTML pour la liste des pays, et
// aussi régler quelques bogues de fureteurs de la page d'accueil

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

window.isOldGecko = (
		!document.readyState &&
		!window.opera &&
		!window.find &&
		window.home &&
		document.getElementsByTagName &&
		navigator.product &&
		(navigator.product == 'Gecko')
);
window.isIE5Mac = (!window.showModelessDialog && window.ActiveXObject && document.getElementById);
window.isNotFXable = (
			document.all || 
			window.isOldGecko ||
			navigator.userAgent.toLowerCase().indexOf('safari') != -1
);


function MM_showHideLayers() { //v6.0
  // this function has been modified to allow browser fix
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (window.isIE5Mac) { fixIE5Mac(obj); }
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function fixIE5Mac(obj)
{
	obj.innerHTML = '';
	if (window.isFixed) { return; }
	ta = document.getElementById('texte-accueil').style;
	ta.position = 'absolute';
	ta.top = '0px';
	ta.left = '220px';
	be = document.getElementById('bureau-etranger').style;
	be.position = 'absolute';
	be.top = '227px';
	be.left = '211px';
//	pp = document.getElementById('piedpage').style;
//	pp.position = 'absolute';
//	pp.top = '617px';
//	pp.left = '0px';
	window.isFixed = true;
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

// code pour liste des pays
function injectFX()
{
	if (window.isNotFXable) return;
	document.writeln('<script src="'+FXsrc1+'" type="text/javascript"><\/script>');
	document.writeln('<script src="'+FXsrc2+'" type="text/javascript"><\/script>');
}

var outFX = [
//	'Fade'
//	'Puff',
	'BlindUp'
//	'SwitchOff',
//	'SlideUp',
//	'DropOut',
//	'Squish',
//	'Fold',
//	'Shrink'
];
var inFX = [
//	'Grow',
//	'Appear'
	'BlindDown'
//	'SlideDown'
];

function writeBIQStyle()
{
	if (!document.getElementById) return;
	document.writeln('');
	document.writeln('<style type="text/css">');
//	document.writeln('body div#piedpage {');
//	document.writeln('	position: static !important;');
//	document.writeln('	background-color: transparent !important;');
//	document.writeln('}');
	document.writeln('#tous-les-biqs {');
	document.writeln('	width: 500px;');
	document.writeln('	height: 180px;');
	document.writeln('	overflow: auto;');
	document.writeln('	position: absolute;');
	document.writeln('	z-index: 100;');
	document.writeln('	top: 100px;');
	document.writeln('	left: 30px;');
	document.writeln('	border: 1px solid #c8e0ff;');
	document.writeln('	background-color: #fff;');
//	document.writeln('	background-color: #c8e0ff');
//	document.writeln('	background: white url("cercle00.gif") no-repeat scroll left -7px;');
//	document.writeln('	background: white url("cercle0c.gif") no-repeat scroll left top;');
//	document.writeln('	_background: white url("cercle00.gif") no-repeat fixed left -7px;');
	document.writeln('}');
	document.writeln('#tous-les-biqs li {');
	document.writeln('	list-style: none outside url("../images/iu/utilitaires/points/vert1.gif");');
	document.writeln('}');
	document.writeln('#fermer-biqs {');
	document.writeln('	display: none;');
	document.writeln('	width: 90px;');
	document.writeln('	height: 15px;');
	document.writeln('	position: absolute;');
	document.writeln('	z-index: 1000;');
	document.writeln('	top: 115px;');
	document.writeln('	left: 430px; ');
	document.writeln('}');
	document.writeln('/* \\*/');
	document.writeln('#tous-les-biqs {');
	document.writeln('	top: 110px;');
	document.writeln('}');
	document.writeln('* html #tous-les-biqs {');
	document.writeln('	top: 115px;');
	document.writeln('}');
	document.writeln('#fermer-biqs {');
	document.writeln('	top: 120px;');
	document.writeln('}');
	document.writeln('* html #fermer-biqs {');
	document.writeln('	top: 125px;');
	document.writeln('}');
	document.writeln('#tous-les-biqs ul {');
	document.writeln('	padding-top: 7px;');
	document.writeln('}');
	document.writeln('* html #tous-les-biqs ul {');
	document.writeln('	padding: 7px 0 0px 0;');
	document.writeln('	margin-left: 25px;');
	document.writeln('}');
	document.writeln('* html #tous-les-biqs li a {');
	document.writeln('	vertical-align: 20%;');
	document.writeln('}');
	document.writeln('/* */');
	document.writeln('</style>');
}


function writeCloseBIQs()
{
	if (!document.getElementById) return;
	document.write('<div id="fermer-biqs"><img id="X-img" src="'+coloredDotImg+'" alt="-" width="13" ');
	document.write('height="10" border="0" /><a id="X" href="javascript:;" ');
	document.write('onclick="hideBIQs(); return false">'+closeBIQs+'</a></div>');
}

function hideBIQs()
{
	if (typeof Effect == 'object')
	{
		eval('Effect.'+outFX[Math.floor(Math.random()*outFX.length)]+"('tous-les-biqs', {duration:1})")
	}
	else
	{
		document.getElementById('tous-les-biqs').style.display = 'none';
	}
	document.getElementById('fermer-biqs').style.display = 'none';
	if (!window.isNotFXable)
	{
		setTimeout(hideBIQsWait,1500);
	}
	else
	{
		hideBIQsWait();
	}
}

function hideBIQsWait()
{
	var tlp = document.getElementById('tous-les-pays').getElementsByTagName('A')[0];
	tlp.onclick = tlp.oldOnClick;
	tlp.disabled = false;
	tlp.oldOnClick = null;
	tlp.focus();
	if (!window.isIE5Mac) tlp.style.cursor = (document.all ? 'hand' : 'pointer');
}
function getContainerByTagName(containerTagName, containee)
{
        var tg = containerTagName.toLowerCase();
        var con = containee;
        while (1) {
                if (con && con.nodeName && (con.nodeName.toLowerCase() == tg)) { break; }
                else if (con == document.body) { alert('boucle infinie'); return false; }
                else { con = con.parentNode; }
        }
        return con;
}

function showBIQs()
{
	var biq = document.getElementById('tous-les-biqs');
	var x = document.getElementById('fermer-biqs');
	var tlp = document.getElementById('tous-les-pays').getElementsByTagName('A')[0];
	if (!tlp.oldOnClick)
	{
		if (!window.isIE5Mac) tlp.style.cursor = 'default';
		tlp.oldOnClick = tlp.onclick;
		tlp.disabled = true;
		tlp.onclick = function(){return false}
	}
	else
	{
		tlp.onclick = tlp.oldOnClick;
		tlp.disabled = false;
		tlp.oldOnClick = null;
		if (!window.isIE5Mac) tlp.style.cursor = (document.all ? 'hand' : 'pointer');
		return false;
	}
	if (typeof Effect == 'object')
	{
		eval('Effect.'+inFX[Math.floor(Math.random()*inFX.length)]+"('tous-les-biqs', {duration:1})")
		setTimeout(showX,1000);
	}
	else
	{
		biq.style.display = 'block';
		showX();
	}
	return false;
}

function showX()
{
	document.getElementById('fermer-biqs').style.display = 'block';
	document.getElementById('X').focus();
}

function openWithJS(url)
{
/*
This function fixes a weird bug with IE5Mac where
all the text in the opener's page gets selected
after a normal (non-JS) click on a country link,
and it's impossible to deselect it without reloading
the page. This function works in all browser but it
is called only for IE5Mac at the moment.
*/	
	if (!window.isIE5Mac) return true;
	window.open(url,'_blank');
	return false;
}

function writeTousLesPays(p)
{
	document.writeln('<div id="tous-les-biqs"><ul>');
	for (var i=0; i<p.length; i++)
	{
		document.writeln(
			'<li><a target="_blank" href="' +
			rel_to_page.replace(/\/$/,'') + p[i].url +
			'" onclick="return openWithJS(this.href)">' +
			p[i].txt + '</a>' +
			(
				typeof p[i].warn == 'string' ?
				'<span style="color:red;font-size:11px"> - ' + p[i].warn + '</span>' :
				''
			) + '</li>'
		);
	}
	document.writeln('</ul></div>');
	if (typeof Effect == 'object')
	{
		Effect.Fade('tous-les-biqs', {duration:0});
	}
	else if (document.getElementById)
	{
		document.getElementById('tous-les-biqs').style.display = 'none';
	}
}

