// ajout des fonctions du flash par patou le 26/06/07
// ajout des fonctions du menu CSS par patou le 12/06/07
// V1.0 du 06/09/04 par jfc

// variables globales d'environnement
var MAC = (navigator.userAgent.indexOf('Mac') >= 0);
var IE = NS4 = NS5 = false;
if (document.all) 
	{IE = true;}
else if (document.layers)
	{NS4 = true;}
else
	{NS5 = true;}

// 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_fen, largeur, hauteur, marge_gauche, marge_haut)
	{
	// formats habituels 640x480, 800x600, 1024x768, 1280x1024
	// types proposés F=full screen, C=centré, A=adapté
//alert(type_fen + " ; " + 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_fen == "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_fen == "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_fen == "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 == '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 {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=0 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=0');
	popupImage.document.open();
	popupImage.focus();
	popupImage.document.write(html);
	popupImage.document.close()
	};


//        fonctions pour le menu


function montreHaut(id) {
	var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenuHaut'+i)) {
			document.getElementById('smenuHaut'+i).style.display='none';
		}
	}
	  if (d) {
	   document.getElementById(id).style.display="block";
	 } else if (document.all) {
	   	if (document.all[id]) document.all[id].style.display="block";
	 } else if (document.layers) {
	   if (document.layers[id]) document.layers[id].display="block";
	 } 
} 

function cache(id) {
  if (document.getElementById(id)) {
   document.getElementById(id).style.display="none";
 } else if (document.all) {
   if (document.all[id])document.all[id].style.display="none";
 } else if (document.layers) {
   if (document.layers[id])document.layers[id].display="none";
 } } 
 
 
 function montreGauche(id) {
//alert("montre"+id);
var d = document.getElementById(id);
	for (var i = 0; i<=10; i++) {
		if (document.getElementById('smenuGauche'+i)) {document.getElementById('smenuGauche'+i).style.display='none';}
	}
	if (d) {d.style.display='block';}
}


/*****************************************************************************
* BackToTheHtml Command
*///**************************************************************************
function BackToTheHtml(node)
{
	if(node == null)
		this.node = document; 
	else
		this.node = node; 
};
BackToTheHtml.prototype.node = null;

BackToTheHtml.prototype.execute = function()
{
	this.activateObject();
}

BackToTheHtml.prototype.activateObject = function(domObject)
{
	var aDomObject = this.node.getElementsByTagName('object');
	var activationObject;
	for(var i=0; i<aDomObject.length; i++)
		if
		(
			aDomObject[i].getAttributeNode('BackToTheHtml') == null
			&&
			(activationObject = this.getActivationObject(aDomObject[i])) != null
		)
			activationObject.execute();
};

BackToTheHtml.prototype.getActivationObject = function(domObject)
{
	var classid = domObject.classid.toUpperCase().substr('clsid:'.length);
	var mimeType = domObject.type.toLowerCase();

	switch(true)
	{
		case 
			classid == 'D27CDB6E-AE6D-11CF-96B8-444553540000' 
			||
			mimeType == 'application/x-shockwave-flash'
		:
			return new ActivateObjectFlash(domObject);

		default :
			return null;
	}
};

BackToTheHtml.uniqueID = function(prefix)
{
	var sPrefix;
	if(prefix == null)
		sPrefix = 'uniqueId';
	else
		sPrefix = prefix;
		
	var i=0;
	while(document.getElementById(sPrefix + (i++)))
		;
	return sPrefix + (i-1);
};

BackToTheHtml.isParentOf = function(parent,child)
{
	var found = false;
	for(var i=0; i<parent.childNodes.length; i++)
		if(parent.childNodes[i] == child)
			return true;
		else
			found = arguments.callee(parent.childNodes[i],child);

	return found;
}

/*****************************************************************************
* ActivateObject Command
*///**************************************************************************
function ActivateObject(domObject)
{
	this.domObject = domObject;
}

ActivateObject.prototype.domObject = null;
ActivateObject.prototype.classid = null;
ActivateObject.prototype.aHtmlAttribute = ['accessKey','align','alt','archive','border','code','codeBase','codeType','declare','dir','height','hideFocus','hspace','lang','language','name','standby','tabIndex','title','useMap','vspace','width'];
ActivateObject.prototype.aObjectProperty = null;

ActivateObject.prototype.execute = function()
{
	this.xndObjectId = BackToTheHtml.uniqueID();
	this.setTextHtml();
	this.writeObject();

	this.xndObject = document.getElementById(this.xndObjectId);
	this.setSpecialProperties();
	this.removeOriginalObject();
}

ActivateObject.prototype.setTextHtml = function()
{
	var str = '';
	str += '<object BackToTheHtml ' + '\n';
	str += ' classid="clsid:' + this.classid + '" ' + '\n';

	//Add HTML attributes to the <object> tag
	for(var i=0; i<this.aHtmlAttribute.length; i++)
	{
		var name = this.aHtmlAttribute[i];
		if(typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '')
			str += '\t' + name + '="' + this.domObject[name].toString() + '" ' + '\n';
	}

	str += 'id="' + this.xndObjectId + '" ' + '\n';
	str += '>';

	for(var i=0; i<this.aObjectProperty.length; i++)
	{
		var name = this.aObjectProperty[i];
		if(typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '' )
			str += '\t<param name="' + name + '" value="' + this.domObject[name].toString() + '"></param>' + '\n';
	}
	str += '</object>';

	this.textHtml = str;
};

ActivateObject.prototype.writeObject = function()
{
	this.domObject.insertAdjacentHTML("afterEnd",this.textHtml);
};

ActivateObject.prototype.setSpecialProperties = function()
{
	if(typeof this.domObject.className != 'undefined' && this.domObject.className.toString() != '')
		this.xndObject.className = this.domObject.className

	if(typeof this.domObject.style.cssText != 'undefined' && this.domObject.style.cssText.toString() != '')
		this.xndObject.style.cssText = this.domObject.style.cssText;

	if(typeof this.domObject.SWRemote != 'undefined' && this.domObject.SWRemote.toString() != '')
		this.xndObject.FlashVars = this.domObject.SWRemote;

	if(typeof this.domObject.codebase == 'undefined' || this.domObject.codebase.toString() == '')
		this.xndObject.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0';

	if(typeof this.domObject.id != 'undefined' && this.domObject.id.toString() != '')
		this.xndObject.id = this.domObject.id;

};

ActivateObject.prototype.removeOriginalObject = function()
{
	this.domObject.parentNode.removeChild(this.domObject);
};

/*****************************************************************************
* ActivateObjectFlash Command
*///**************************************************************************
function ActivateObjectFlash(domObject)
{
	ActivateObject.call(this,domObject);
}
ActivateObjectFlash.prototype = new ActivateObject;
ActivateObjectFlash.prototype.aObjectProperty = ['FrameNum','Playing','Quality','Quality2','Scalemode','Scale','AlignMode','SAlign','BackgroundColor','BGColor','Loop','Movie','WMode','Base','DeviceFont','EmbedMovie','SWRemote','FlashVars','AllowScriptAccess'];
ActivateObjectFlash.prototype.classid = 'D27CDB6E-AE6D-11CF-96B8-444553540000';


/*****************************************************************************
* Script initialisation
*///**************************************************************************
if(typeof ActiveXObject != 'undefined' && typeof Function.call != 'undefined')
{
	var styleId = BackToTheHtml.uniqueID();
	document.write('<style id="' + styleId + '" ></style>');
	var domStyle = document.getElementById(styleId);

	var isHead = false;
	var aHead = document.getElementsByTagName('head');
	for(var i=0; i<aHead.length; i++)
		if(BackToTheHtml.isParentOf(aHead[i],domStyle))
			isHead = true;

	if(isHead)
	{
		document.write('<style type="text/css">OBJECT{visibility:hidden;}</style>');
		document.onreadystatechange = function()
		{
			if(document.readyState == 'complete')
			{
				new BackToTheHtml().execute();
				document.styleSheets[document.styleSheets.length-1].addRule("OBJECT","visibility:visible;");
				//alert('head');
				//alert(document.body.innerHTML);
			}
		}
	}
	else
	{
		new BackToTheHtml().execute();
		//alert('body');
		//alert(document.body.innerHTML);
	}
	
	domStyle.parentNode.removeChild(domStyle);
}


//-->