// V1.0 du 06/09/04 par jfc
// V2.0 du 25/01/06 par jfc
// V2.1 du 08/02/06 par jfc

//alert ("bonjour");

// variables globales d'environnement
// Mac ou pas Mac
var MAC = (navigator.userAgent.indexOf('Mac') >= 0);
// Navigateur
var IE = NS4 = NS5 = false;
if (document.all) 
	{IE = true;}
else if (document.layers)
	{NS4 = true;}
else
	{NS5 = true;}
// Langue navigateur
if (IE)
	{LgNav = navigator.userLanguage;}
else
	{
	LgNav = navigator.language;
	tab = LgNav.split("-");
	LgNav = tab[0];
	}

// langue primaire (français ou anglais) pour les messages d'erreur
var FR = EN = false;
if (window.location.pathname.indexOf('/fr/') >= 0)
	{FR = true;}
else if (window.location.pathname.indexOf('/en/') >= 0)
	{EN = true;}
else if (window.location.pathname.indexOf('/nl/') >= 0)
	{EN = true;}
else if (window.location.pathname.indexOf('/it/') >= 0)
	{EN = true;}
else if (window.location.pathname.indexOf('/es/') >= 0)
	{EN = true;}
else if (window.location.pathname.indexOf('/de/') >= 0)
	{EN = true;}
else
	{FR = true;}

function redim_fen(type, largeur, hauteur, marge_gauche, marge_haut)
	{
	// formats habituels 640x480, 800x600, 1024x768, 1280x1024
	// types proposés F=full screen, C=centré, A=adapté
//alert(type + " ; " + largeur + " ; " + hauteur + " ; " + marge_gauche + " ; " + marge_haut);
	// Adaptation de la taille de la fenêtre au format spécifié...mais action réalisée que si nécessaire
	if (type == "A")
		{
		if (isNaN(largeur) || isNaN(hauteur)) {return;}
		if (IE) 
			{
			var redim = false;
			if ((document.body.clientWidth+25) < largeur) {redim = true;}
			if ((document.body.clientHeight+135) < hauteur) {redim = true;}
			if (redim) {window.resizeTo(largeur, hauteur);}
			}
		else
			{
			if (window.outerWidth < largeur) window.outerWidth = largeur;
			if (window.outerHeight < hauteur) window.outerHeight = hauteur;
			}
		return;
		}
	// mise au format plein écran
	if ((type == "F") || (largeur > screen.availWidth) || (hauteur > screen.availHeight))
		{
		window.moveTo(0,0);
		if (IE) 
			{window.resizeTo(screen.availWidth, screen.availHeight);}
		else 
			{
			window.outerHeight = screen.availHeight;
			window.outerWidth = screen.availWidth;
			}
		return;
		}
	//  Mise à la dimension largeur, hauteur
	if (isNaN(largeur) || isNaN(hauteur)) {return;}
	if (largeur > screen.availWidth) {largeur = screen.availWidth;}
	if (hauteur > screen.availHeight) {hauteur = screen.availHeight;}
	if (IE) 
		{window.resizeTo(largeur, hauteur);}
	else
		{
		window.outerWidth = largeur;
		window.outerHeight = hauteur;
		}
	//  positionnement de la fenêtre
	if (type == "C")
		{
		if (isNaN(largeur) || isNaN(hauteur)) {return;}
		marge_gauche = (screen.availWidth - largeur) / 2;
		marge_haut = (screen.availHeight - hauteur) / 2;
		}
	if (isNaN(marge_gauche) || isNaN(marge_haut)) {return;}
	if (marge_gauche < 0) {marge_gauche = 0;}
	if (marge_haut < 0) {marge_haut = 0;}
	window.moveTo(marge_gauche, marge_haut);
	}

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;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function imprimer()
	{
	if (MAC)
		{
		if (FR) alert("Cette fonction n'est pas disponible sur MacIntosh,\nutilisez la fonction impression de votre navigateur");
		else alert("Sorry, not possible on MacIntosh,\nplease use the print button of your browser");
		}
	else {self.print();}
	}

function ferme()
	{
	window.close();
	}
	
function retour_site(url_cible)
	{
	window.opener.document.location = url_cible;
	window.opener.focus();
	window.close();
	}

function TailleAuto()
	// pour ajuster la taille d'une fenetre en gardant la fonction site
	// rajouter ?w=XXX&h=XXX
	// ex : javascript:site('my_pop.htm?w=700&h=300','pop_640')
	// a rajouter dans la balise body de la pop up ONLOAD="javascript:TailleAuto();"
	{
	origine = window.location.search;
	infos_recues = origine.substring(1, origine.length);
		
	tab = infos_recues.split("&");
	width = tab[0];
	height = tab[1];
	
	tab = width.split("=");
	width = tab[1];
	
	tab = height.split("=");
	height = tab[1];
	
	self.resizeTo(width, height)
	//fenetre.focus();
	}

function site(ref_url, fen_nom)
	{
	if (fen_nom == 'pdf_640') {fen_param = 'width=640,height=480,left=10,top=10,toolbar=0,menubar=0,directories=0,scrollbars=1,status=1,location=0,resizable=1,copyhistory=0';}
	else if (fen_nom == 'pop_320') {fen_param = 'width=320,height=400,left=10,top=10,toolbar=0,menubar=0,directories=0,scrollbars=1,status=0,location=0,resizable=0,copyhistory=0';}
	else if (fen_nom == 'pop_480') {fen_param = 'width=480,height=440,left=10,top=10,toolbar=0,menubar=0,directories=0,scrollbars=1,status=0,location=0,resizable=0,copyhistory=0';}
	else if (fen_nom == 'pop_640') {fen_param = 'width=640,height=480,left=10,top=10,toolbar=0,menubar=0,directories=0,scrollbars=1,status=0,location=0,resizable=0,copyhistory=0';}
	else if (fen_nom == 'site_800') {fen_param = 'width=800,height=600,left=10,top=10,toolbar=1,menubar=1,directories=1,scrollbars=1,status=1,location=1,resizable=1,copyhistory=1';} 
	else if (fen_nom == 'site_1024') {fen_param = 'width=1024,height=768,left=10,top=10,toolbar=1,menubar=1,directories=1,scrollbars=1,status=1,location=1,resizable=1,copyhistory=1';} 
	else if (fen_nom == 'fen_pubs') {fen_param = 'width=800,height=600,left=10,top=10,toolbar=0,menubar=0,directories=0,scrollbars=1,status=0,location=0,resizable=1,copyhistory=1';} 
	else if (fen_nom == 'enews') {fen_param = 'width=800,height=600,left=10,top=10,toolbar=0,menubar=1,directories=0,scrollbars=1,status=0,location=0,resizable=1,copyhistory=1';} 
	else {fen_param = fen_nom; fen_nom = "fen_specif";}
	fenetre = window.open(ref_url, fen_nom, fen_param);	
	fenetre.focus();
	}

function change_lg(langue)
	{
	racine = "/"; // racine avant la langue
	protocole = window.location.protocol;
	domaine = window.location.host; // domaine + port
	url_page = window.location.pathname;
	infos_cpl = window.location.search;
	if (infos_cpl != "") {infos_cpl = "?" + infos_cpl;}
	ancre = window.location.hash;
	if (ancre != "") {ancre = "#" + ancre;}
	pos_url = 2 + racine.length; // longueur langue (2 car) + longuer racine
	url_sans_langue = url_page.substring(pos_url, url_page.length);
	url_cible = protocole + "//" + domaine + racine + langue + url_sans_langue + infos_cpl + ancre;
//	alert (url_cible);
	document.location.href = url_cible;
	}

function afficheVignette(cheminVignette,cheminMaxi)
	{
	document.write('<A HREF="javascript:afficheMaxi(\''+cheminMaxi+'\')"><IMG SRC="'+cheminVignette+'" HSPACE=0 VSPACE=0 BORDER=0 ALT="cliquez pour agrandir"></A>');
	}
	
function afficheMaxi(chemin)
	{
	i1 = new Image;
	i1.src = chemin;
	if (FR) {message = "cliquez pour fermer la fenêtre";} else {message = "click to close the window";}
	html = '<HTML><HEAD><TITLE></TITLE></HEAD><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0>';
	html = html + '<CENTER><A HREF="Javascript:OnClick=window.close()">';
	html = html + '<IMG SRC="' + chemin + '" BORDER=2 NAME=imageTest onLoad="window.resizeTo(document.imageTest.width+14,document.imageTest.height+32)" ALT="' + message + '">';
	html = html + '</A></CENTER></BODY></HTML>';
	popupImage = window.open('','fen','left=10,top=10,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
	popupImage.document.open();
	popupImage.focus();
	popupImage.document.write(html);
	popupImage.document.close()
	};

//-->