﻿ 
// ************************************************************************************
//							Bibliotheque LIB_UTILS.JS
//
// Regroupe des fonctions javascripts pour Syfadis
//
// * Bibliotheque NAVIGATION
// <Nom>			findUpperFrame
// <Nom>			AllerPage, AllerLettre
// <Nom>			addId2List, delId2List
//
// * Bibliotheque AFFICHAGE
// <Nom>			AffBulle
// <Nom>			dockOnChange
//
// * Bibliotheque standardisation d'ouverture de FENETRES
// <Nom>			openWindow
// <Nom>			openMessagerie
// <Nom>			ouvrirAide
// <Nom>			openStatsExport
// <Nom>			openFichierCSV
// <Nom>			openChat
// <Nom>			openHistorique
// <Nom>			openForum
// <Nom>			popupDate
//
// * Bibliotheque ROLL-OVER
// <Nom>			MM_swapImgRestore
// <Nom>			MM_preloadImages
// <Nom>			MM_swapImages
// <Nom>			MM_KeepBtnState
// <Nom>			RockImgNStyle
//
// * Bibliotheque CONTENU HTML
// <Nom>			findWIN
// <Nom>			getWIN
// <Nom>			launchNextRess
//
// * Bibliotheque GESTION DES URLS
// <Nom>			getSecuredURL
// <Nom>			getInformationURL
// <Nom>			replaceServernameTag
//
// * Bibliotheque DIVERS
// <Nom>			fnTrapKD, enter_key_trap
//
// * Bibliotheque MAIL
// <Nom>            SendSMTPMailToN
//
// * Bibliothèques URL
// <Nom>            ConvertUrl
//
// <Date Creation> 17 Mai 2002
// ************************************************************************************


// ************************************************************************************
//							Bibliotheque NAVIGATION
//
// Regroupe des appels de fonctions standard necessaires a la navigation sur Syfadis
//
// <Nom>			findUpperFrame
// <Nom>			AllerPage, AllerLettre
// <Nom>			addId2List, delId2List
//
// <Date Creation> 17 Mai 2002
// ************************************************************************************


	//--------------------------------------------------------------------------------------
	// Nom de la fonction : findUpperFrame
	// 
	// Description :
	//
	// Parametres : nom : 
	//				upperWindow : 
	//--------------------------------------------------------------------------------------

		function findUpperFrame(nom,upperWindow) {
			if (upperWindow==null) upperWindow=window.parent;
			
			if (upperWindow.frames[nom] != null)
				return upperWindow.frames[nom];
			else if (upperWindow != window.top)
				return findUpperFrame(nom,upperWindow.parent);
			else 
				return null;
		}	




	//---------------------------------------------------------------------------
	// <Nom>          AllerPage
	// <Description>  Permet de se rendre a la page [iPage] lors d'une navigation
	//				  par page. L'emploi de cette fonction suppose l'existence
	//				  d'un formulaire frmNavigation.
	// <Parametres>   (I) iPage : Numero de la page que l'on souhaite afficher
	// <Resultats>	  
	//---------------------------------------------------------------------------

		function AllerPage(iPage) {
			document.frmNavigation.pg.value = iPage;
			document.frmNavigation.submit();
		}




	//---------------------------------------------------------------------------
	// <Nom>          AllerLettre
	// <Description>  Permet de selectionner une lettre commencant un mot ou un nom
	//				  qui permettra de filtrer l'affichage de la page de destination.
	//				  L'emploi de cette fonction suppose l'existence d'un formulaire 
	//                frmNavigation.
	// <Parametres>   (I) sLettre : Lettre permettant de filtrer l'affichage
	// <Resultats>	  
	//---------------------------------------------------------------------------

		function AllerLettre(sLettre) {
			document.frmNavigation.pg.value = 1;
			document.frmNavigation.Lettre.value = sLettre;
			document.frmNavigation.submit();
		}


	//--------------------------------------------------------------------------------------
	// Nom de la fonction : addId2List
	// 
	// Description : Fonction d'ajout d'elements dans une chaine
	//
	// Parametres : myObject : l'objet contenant la liste d'elements
	//				myId	 : l'ID a ajouter
	// 
	// Date de dermiere mise a jour : * - *
	//--------------------------------------------------------------------------------------

		function addId2List(myObject, myId)
		{
			//Ajouter l'id a la liste
			var liste = myObject.value;
			if (liste!="") liste += ";";
			liste += myId;
			
			myObject.value = liste;
		}


	//--------------------------------------------------------------------------------------
	// Nom de la fonction : delId2List
	// 
	// Description : Fonction de suppression d'elements dans une chaine
	//
	// Parametres : myObject : l'objet contenant la liste d'elements
	//				myId	 : l'ID a supprimer
	// 
	// Date de dermiere mise a jour : * - *
	//--------------------------------------------------------------------------------------

		function delId2List(myObject, myId)
		{
			var ecart=0;
			var liste=myObject.value;
			var cpt;
			
			//enlever de listeProfil la ligne ligne-1
			var tabListe = liste.split(";");
			var tabTmp = new Array();
				
			for (cpt=0;cpt<tabListe.length;cpt++)
			{
				if (tabListe[cpt]==myId)
					ecart += 1;
				else
					tabTmp[cpt-ecart] = tabListe[cpt];
				
			}
			myObject.value = tabTmp.join(";");
		}


	
	

// ************************************************************************************
//							Bibliotheque AFFICHAGE
//
// Regroupe des appels de fonctions standard d'ouverture en pop-up de certains fonctionnalites 
//  Syfadis
//
// <Nom>			AffBulle
// <Nom>			dockOnChange
//
// <Date Creation> 21 Janvier 2004
// ************************************************************************************


	//-----------------------------------------------------------------------------------
	// <Nom>			AffBulle
	// <Description>	Ouvre une bulle d'aide
	// <Parametres>		
	// <Resultats>		
	// <Auteur>			AB - 22.05.2002
	//
	// <Source>			http:// www.toutjavascript.com
	// Auteur original :Olivier Hondermarck  <webmaster@toutjavascript.com>
	// Modifs compatibilite Netscape 6/Mozilla : Cedric Lamalle 09/2001 <cedric@cpac.embrapa.br>
	//-----------------------------------------------------------------------------------

		var posX = 0; posY = 0;
		var xOffset = 10; yOffset = 10;
		
		function AffBulle(texte) {
		
		  contenu = "<TABLE border=0 cellspacing=0 cellpadding=1 class='BulleContour'><TR>";
		  contenu = contenu + "<TD><TABLE border=0 cellpadding=2 cellspacing=0 class='BulleFond'>";
		  contenu = contenu + "<TR><TD class='BulleTexte'>" + texte + "</TD>";
		  contenu = contenu + "</TR></TABLE></TD>";
		  contenu = contenu + "</TR></TABLE>";
		  
		  var finalPosX=posX-xOffset;
		  if (finalPosX<0) finalPosX=0;
		  if (document.layers) {
		    document.layers["bulle"].document.write(contenu);
		    document.layers["bulle"].document.close();
		    document.layers["bulle"].top=posY+yOffset;
		    document.layers["bulle"].left=finalPosX;
		    document.layers["bulle"].visibility="show";}
		  if (document.all) {
		    bulle.innerHTML=contenu;
		    document.all["bulle"].style.top=posY+yOffset;
		    document.all["bulle"].style.left=finalPosX;//f.x-xOffset;
		    document.all["bulle"].style.visibility="visible";
		  }
		  //modif 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
		  else if (document.getElementById) {
		    document.getElementById("bulle").innerHTML=contenu;
		    document.getElementById("bulle").style.top=posY+yOffset;
		    document.getElementById("bulle").style.left=finalPosX;
		    document.getElementById("bulle").style.visibility="visible";
		  }		  
		}
		
		function getMousePos(e) {
		  if (document.all) {
		  posX=event.x+document.body.scrollLeft; //modifs 09/2001 - IE : regrouper l'evenement
		  posY=event.y+document.body.scrollTop;
		  }
		  else {
		  posX=e.pageX; //modifs 09/2001 - NS6 : celui-ci ne supporte pas e.x et e.y
		  posY=e.pageY; 
		  }
		}
		
		function HideBulle() {
			if (document.layers) {document.layers["bulle"].visibility="hide";}
			if (document.all) {document.all["bulle"].style.visibility="hidden";}
			else if (document.getElementById){document.getElementById("bulle").style.visibility="hidden";}
		}

		function InitBulle() {
			if (document.layers) {
				window.captureEvents(Event.MOUSEMOVE);window.onMouseMove=getMousePos;
				document.write("<LAYER name='bulle' top=0 left=0 visibility='hide'></LAYER>");
			}
			if (document.all) {
				document.write("<DIV id='bulle' style='z-index:200;position:absolute;top:0;left:0;visibility:hidden'></DIV>");
				document.onmousemove=getMousePos;
			}
			//modif 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
			else if (document.getElementById) {
			        document.onmousemove=getMousePos;
			        document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
			}
		}


	//-----------------------------------------------------------------------------------
	// <Nom>			dockOnChange
	// <Description>	Permet d'afficher/cacher un block de données
	// <Parametres>		
	// <Resultats>		
	// <Auteur>			AB - 05.09.2005
	//-----------------------------------------------------------------------------------
			
		function dockOnChange(id, bIsTable) {
		
			var sDockDisplay = document.getElementById('dock'+id).style.display;
			var sEtat;
			var sArgDisplay;
					
			if (document.all)
				sArgDisplay = 'block'		// Navigateur IE
			else
				sArgDisplay = 'table-row';	// Autres navigateurs
		
			if (sDockDisplay=='none' || sDockDisplay=='undefined') {
				if (bIsTable)
					sEtat = sArgDisplay
				else
					sEtat = 'block'
			} else {
				sEtat = 'none'
			}		
			document.getElementById('dock'+id).style.display = sEtat;
		}

	
	

// ************************************************************************************
//							Bibliotheque FENETRES
//
// Regroupe des appels de fonctions standard d'ouverture en pop-up de certains fonctionnalites 
//  Syfadis
//
// <Nom>			openWindow
// <Nom>			openMessagerie
// <Nom>			ouvrirAide
// <Nom>			openStatsExport
// <Nom>			openChat
// <Nom>			openHistorique
// <Nom>			openForum
// <Nom>			popupDate
//
// <Date Creation> 03 Decembre 2003
// ************************************************************************************



	//-----------------------------------------------------------------------------------
	// <Nom>			openWindow
	// <Description>	Ouvre une pop-up
	// <Parametres>		url		: l'URL a ouvrir
	//					name	: nom de la fenetre
	//					settings: parametres complementaires
	// <Resultats>		
	// <Auteur>			AB - 21.12.2001
	//-----------------------------------------------------------------------------------

			function openWindow(url,name,settings) {

				window.open(url,name,'location=no'+settings);
			}
		


	//-----------------------------------------------------------------------------------
	// <Nom>			openMessagerie
	// <Description>	Ouvre la messagerie en pop-up
	// <Parametres>		url : l'URL a ouvrir
	//					name : nom de la fenetre
	// <Resultats>		
	// <Auteur>			AB - 06.02.2003
	//-----------------------------------------------------------------------------------

			function openMessagerie(url) {

				window.open (url+'&stnav=2', 'MailBD', 'toolbar=no,location=no,directories=no,scrollbars=yes,menubar=no,status=no,copyhistory=no,resizable=yes,width=850,height=550');

			}	

		
	//-----------------------------------------------------------------------------------
	// <Nom>			openAide
	// <Description>	Ouvre l'aide en pop-up
	// <Parametres>		url : l'URL a ouvrir
	//					name : nom de la fenetre
	// <Resultats>		
	// <Auteur>			AB - 23.04.2003
	//-----------------------------------------------------------------------------------

			
		function OuvrirAide (sURL) {
			window.open (sURL, 'AideImport', 'toolbar=no,location=no,directories=no,scrollbars=yes,menubar=no,status=no,copyhistory=no,resizable=yes,width=450,height=500');
		}

		
	//-----------------------------------------------------------------------------------
	// <Nom>			openStatsExport
	// <Description>	Ouvre l'export de statistiques en pop-up
	// <Parametres>		sURL : l'URL a ouvrir
	// <Resultats>		
	// <Auteur>			AB - 14.11.2003
	//-----------------------------------------------------------------------------------

			
		function openStatsExport (sURL,bDepassement) {
			window.open (sURL, 'Reporting', 'toolbar=yes,location=no,directories=no,scrollbars=yes,menubar=yes,status=yes,copyhistory=no,resizable=yes,width=610,height=400');
			window.close();
		}

	//-----------------------------------------------------------------------------------
	// <Nom>			openFichierCSV
	// <Description>	Ouvre un fichier CSV dans une pop-up
	// <Parametres>		sURL : l'URL a ouvrir
	// <Resultats>		
	// <Auteur>			CS - Mars 2005
	//-----------------------------------------------------------------------------------

			
		function openFichierCSV (sURL) {
			window.open (sURL, 'CSV', 'toolbar=yes,location=no,directories=no,scrollbars=yes,menubar=yes,status=yes,copyhistory=no,resizable=yes,width=610,height=400');
			window.close();
		}
		
	//-----------------------------------------------------------------------------------
	// <Nom>			openChat
	// <Description>	Ouvre la fenetre de l'applet de Chat
	// <Parametres>		sURL : l'URL a ouvrir (chat tout seul ou chat+tracking)
	
	// <Resultats>		
	// <Auteur>			03.12.2003
	//-----------------------------------------------------------------------------------

		function openChat(sURL) {
			var sWidth = 740;
			var sHeight =550;
			LeftPosition= (screen.width) ? (screen.width-sWidth)/2 : 0;
			TopPosition = (screen.height) ? (screen.height-sHeight)/2 :0;
			settings = 'height='+sHeight+',width='+sWidth+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,resizable=yes,toolbar=no,location=no,directories=no,menubar=no,status=no,copyhistory=no';
			window.open (sURL, 'UnChat', settings);
		}

		
	//-----------------------------------------------------------------------------------
	// <Nom>			openHistorique
	// <Description>	Ouvre la fenetre de l'historique d'une ressource
	// <Parametres>		
	
	// <Resultats>		
	// <Auteur>			AB - 12.01.2004
	//-----------------------------------------------------------------------------------

		function openHistorique(sURL) {
			window.open (sURL, "Historique", 'width=600, height=450, resizable=yes,scrollbars=yes');
		}

		
	//-----------------------------------------------------------------------------------
	// <Nom>			openForum
	// <Description>	Ouvre la fenetre de lancement d'un forum
	// <Parametres>		sURL		: URL a ouvrir
	//					sTypeAction	: Action a executer
	// <Resultats>		
	// <Auteur>			AB - 29.01.2004
	//-----------------------------------------------------------------------------------

		function openForum(sURL, sTypeAction) {
			var settings;
			
			switch (sTypeAction) {
				case 'Nouveau' :
					settings = 'toolbar=no,location=no,directories=no,scrollbars=no,menubar=no,status=no,copyhistory=no,resizable=yes';
					settings+= ',width=712,height=550';
					break;
					
				case 'Moderer' :
					settings = 'toolbar=no,location=no,directories=no,scrollbars=no,menubar=no,status=no,copyhistory=no,resizable=yes';
					settings+= ',width=500,height=250';
					break;
			}
			
			window.open(sURL, 'DonneesForum', settings);
		}
		
		
		
	//-----------------------------------------------------------------------------------
	// <Nom>			popupDate
	// <Description>	Ouvre un calendrier en pop-up
	// <Parametres>		sURLRacine, SessionID
	//					sChamp : nom du champ 'appelant'
	// <Resultats>		
	// <Auteur>			AB - 13.05.2003
	//-----------------------------------------------------------------------------------

			
		function popupDate (sURLRacine, SessionID, sChamp) {
			var sURL;
			sURL = sURLRacine+"Planning/popup_planning.asp?SessionID="+SessionID+"&Champ="+sChamp+"&DateAgenda="+eval('document.'+sChamp+'.value');
			window.open (sURL, 'popupDate', 'toolbar=no,location=no,directories=no,scrollbars=no,menubar=no,status=no,copyhistory=no,resizable=yes,width=283,height=166');
		}




// ************************************************************************************
//							Bibliotheque ROLL-OVER
//
// Regroupe des fonctions de roll-over sur les images de la navigation de Syfadis
//
// <Nom>			MM_swapImgRestore
// <Nom>			MM_preloadImages
// <Nom>			MM_swapImages
// <Nom>			MM_KeepBtnState
// <Nom>			RockImgNStyle
//
// <Date Creation> 17 Mai 2002
// ************************************************************************************



	//--------------------------------------------------------------------------------------
	// Nom de la fonction : MM_swapImgRestore
	// 
	// Description : Permet de restaurer l'image du bouton remplacee lors du passage du curseur
	// Cas d'utilisation: <A href="..." onMouseOut="MM_swapImgRestore()" onMouseOver="...">
	//
	// Parametres : Aucun
	//				
	// Date de creation : 10/03/2000 - Francois-Xavier
	// 
	// Date de derniere mise a jour : * - *
	//--------------------------------------------------------------------------------------

		function MM_swapImgRestore() {
		  if (document.MM_swapImgData != null)
		    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
		      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
		}
		
		

	//--------------------------------------------------------------------------------------
	// Nom de la fonction : MM_preloadImages
	// 
	// Description : Permet de charger en memoire les images avec lesquelles
	//				 on veut swapper lors du passage de la souris sur un bouton
	//
	// Parametres : Obligatoires: - Le(s) nom(s) de(s) image(s) a pre-loader,
	//			   l'appel est en general fait suite a un:
	//					 onLoad="MM_preloadImages('image1','image2',...)"
	//	
	// Remarque: Le test : charAt(0)!="#" ne sert que lorsque l'on passe un 
	//			parametre supplementaire de la forme #?????? resultant d'une 
	//			mise en forme automatique avec un outil specialise (inutile 
	//			dans le cas d'une utilisation faite main)
	//				
	// Date de creation : 10/03/2000 - Francois-Xavier
	// 
	// Date de derniere mise a jour : * - *
	//--------------------------------------------------------------------------------------

		function MM_preloadImages() {
		  if (document.images) {
		    var imgFiles = MM_preloadImages.arguments;
		    if (document.preloadArray==null) document.preloadArray = new Array();
		    var i = document.preloadArray.length;
		    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
		      preloadArray[i] = new Image;
		      preloadArray[i++].src = imgFiles[j];
		  } }
		}
		
		

	//--------------------------------------------------------------------------------------
	// Nom de la fonction : MM_swapImages
	// 
	// Description : Permet de remplacer l'image d'un bouton par celle passee en parametre
	// Cas d'utilisation: <A href="..." onMouseOut="..." onMouseOver="MM_swapImages('NomBoutonNetscape','NomBoutonIE','image')">
	//
	// Parametres : Obligatoires:	le nom du bouton image a modifier sous Netscape
	//								le nom du bouton image a modifier sous un autre Navigateur
	//								le nom de l'image qui remplace la precedente
	//				
	// Date de creation : 10/03/2000 - Francois-Xavier
	// 
	// Date de derniere mise a jour : * - *
	//--------------------------------------------------------------------------------------

		function MM_swapImages() { 
		  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
		  for (i=0; i < (MM_swapImages.arguments.length-2); i+=3) {
		    objStr = MM_swapImages.arguments[(navigator.appName == 'Netscape')?i:i+1];
		    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
		        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
		      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
		    obj = eval(objStr);
		    if (obj != null) {
		      swapArray[j++] = obj;
		      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
		      obj.src = MM_swapImages.arguments[i+2];
		  } }
		  document.MM_swapImgData = swapArray; //used for restore
		}
		
		

	//--------------------------------------------------------------------------------------
	// Nom de la fonction : MM_KeepBtnState
	// 
	// Description : Une fois qu'on a clique sur un bouton en roll-over, laisse celui-ci dans l'etat specifie en parametre,
	//				 et supprime le lien '<A Href=' pour que le lien ne soit plus cliquable et imbrique l'image dans un '<Span>'
	//
	// Parametres : Obligatoires:	ID du Span
	//								Adresse de l'image à afficher
	//				
	// Date de creation : AB - 19/01/2004
	//--------------------------------------------------------------------------------------
		
		function MM_KeepBtnState(sCteImg, sIMG, sTXT) {
			if( sTXT == null )
			{
				document.getElementById('SPAN_'+sCteImg).innerHTML = '<img src="'+sIMG+'" border="0">';
			}
			else
			{
				document.getElementById('SPAN_'+sCteImg).innerHTML = '<a class="BoutonNavig_Over"><img src="'+sIMG+'" border="0"><span>' + sTXT + '</span></a>';
			}		
		}
		
	//--------------------------------------------------------------------------------------
	// Nom de la fonction : RockImgNStyle
	// 
	// Description : Bascule l'image (et éventuellement le style) d'un bouton de navigation 
	//					en mode ON ou OFF
	//
	// Parametres : a: élément javascript
	//				
	// Date de creation : AB - 28/08/2006
	//--------------------------------------------------------------------------------------
		
		function RockImgNStyle(a, sImg) {
			var img = a.getElementsByTagName('img');
			if ( a.className.indexOf('_Over')!=-1 ) {
				a.className = a.className.replace('_Over','');
			} else {
				a.className = a.className + '_Over';
			}
			if(img!=null) img[0].src = sImg;
		}
		

// ************************************************************************************
//							Bibliotheque CONTENU HTML
//
// Regroupe les fonctions javascripts necessaires aux fonctionnement des contenus HTML
//  crees par l'Editeur HTML
//
// <Nom>	findWIN, getWIN	(fonctions derivees des fonctions findAPI et getAPI pour SCORM)
//
// <Date Creation> 25 Fevrier 2004
// ************************************************************************************


	// Constante de debug
	var _Debug = false;

	/******************************************************************************************
	**
	** Function findWIN(win)
	** Inputs:	win - a Window Object
	** Return:	win - the Window Object searched
	**
	** Description:
	** This function looks for an object named "sURLRacine" in the supported window hierarchy, 
	** 
	******************************************************************************************/
	function findWIN(win) {
	 
	   // Search the window hierarchy for an object named "sURLRacine"  
	   // Look in the current window (win) and recursively look in any child frames
	    
	   //if (_Debug) alert("win is: "+win.location.href);
	 
	   if (win.sURLRacine != null) {
	      if (_Debug) alert("found WIN in this window");
	      
	      return win;
	   }

	   // does the window have frames?
	   if (win.length > 0) {
	      if (_Debug) alert("looking for 'sURLRacine' in windows frames"); 
	      
	      for (var i=0;i<win.length;i++) {
	 
	         if (_Debug) alert("looking for 'sURLRacine' in frames["+i+"]");
	         
	         var theWIN = findWIN(win.frames[i]);
	         if (theWIN != null) return theWIN;
	      }
	   }
	 
	   if (_Debug) alert("didn't find 'sURLRacine' in this window (or its children)\n"+win.location.href);
	   return null;
	 
	}
	 
	 
	/******************************************************************************************
	**
	** Function getWIN()
	** Inputs:	none
	** Return:	win - the Window Object searched
	**
	** Description:
	** This function looks for an object named 'sURLRacine', first in the current window's hierarchy, 
	**  and then, if necessary, in the current window's opener window hierarchy (if there is
	**  an opener window).
	******************************************************************************************/
	 
	function getWIN() {
	 
	   // start at the topmost window - findWIN will recurse down through
	   // all of the child frames
	   var theWIN = findWIN(this.top);
	 
	   if (theWIN == null) {
	      // the window wasn't found in the current window's hierarchy.  If the
	      // current window has an opener (was launched by another window),
	      // check the opener's window hierarchy. 
	      if (_Debug) alert("checking to see if this window has an opener\nwindow.opener typeof is : "+typeof(window.opener));
	 
	      if (typeof(this.opener) != "undefined") {
	         if (_Debug) alert("checking this windows opener");
	         
	         if (this.opener != null) {
	            if (_Debug) alert("this windows opener is NOT null - looking there");
	            
	            theWIN = findWIN(this.opener.top);
	         }
	         else {
	            if (_Debug) alert("this windows opener is null");
	         }
	      }
	   }
	 
	   return theWIN;
	}
	 
	 
	/******************************************************************************************
	**
	** Function launchNextRess(RessId)
	** Inputs:	RessId : ID de la ressource
	** Return:	Lancement du tracking de la ressource suivante + la ressource
	**
	******************************************************************************************/
	
	function launchNextRess(RessId) {

		var topURL = new String(window.top.location);
			topURL = topURL.toLowerCase();
		
		// On est en mode tracking ou pas?
		var uploadStringPos = 0;
			uploadStringPos = topURL.indexOf('/upload/');

		var defaultStringPos = 0;
			defaultStringPos = topURL.indexOf('default.asp');

		if (defaultStringPos>0) {
			// on se trouve dans la frame principale => on va remonter les frames
			var oWIN = getWIN();
		} else {
		    //On cherche le fenetre parent
		    //Si on est en mode visualisation, on va simplement eviter une erreur javascript et ne rien faire ...
			try
			{	
			    // on se trouve dans une nouvelle fenetre => on doit d'abord pointer la bonne fenetre,
			    //	 puis on pointe sur la frame la plus haute.
    			var oWIN = findWIN(window.top.opener.top);
    		}
    		catch(erreur) { return; }
		}

		// On recupere les champs necessaires au lancement de la ressource suivante.
		var sURLRacine	= oWIN.sURLRacine;
		var sSessionID	= oWIN.SessionID;
		var sNavig		= oWIN.Navig;
		var sSuiviID	= oWIN.SuiviID;
		var sAction		= oWIN.sAction;
				
		// On prepare le lancement de la ressource demandee par le contenu via l'editeur HTML.
		var sURL = sURLRacine+'Lancement/LanceurRessource.asp?SessionID='+sSessionID+'&SuiviID='+sSuiviID+'&Navig='+sNavig+'&RessLancement=2&RessourceID='+RessId+'&PrecAction='+sAction;

		if (defaultStringPos>0) {
			// La page html est ouverte dans la frame
			findUpperFrame('principal',null).location = sURL;
		} else {
			// La page html est ouverte dans une nouvelle fenetre
			window.top.opener.location = sURL;
			// on doit retarder la fermeture car celle-ci actualise la frame Principal parent ... 
			//	et le contenu suivant n'a pas forcement eu le temps de se lancer
			setTimeout('top.close()', 1500);
		}
	}


	
	

// ************************************************************************************
//							Bibliotheque GESTION DES URLS
//
// 
//
// <Nom> getSecuredURL
// <Nom> getInformationURL
// <Nom> replaceServernameTag
//
// <Date Creation> Juin 2005
// ************************************************************************************


	// -----------------------------------------------------------------------------
	// <Nom>         getSecuredURL
	// <Description> recontruit une url en https a partir d'une url en http. Si l'url
	//	n'est pas en http, l'url d'origine est renvoyee
	// <Parametres>  (I) obj
	// <Resultats>   Booleen
	// -----------------------------------------------------------------------------
	
		function getSecuredURL(sUnsecureURL) {
			var newUrl=new String(sUnsecureURL);
			if (sUnsecureURL.length < 6) 
			{ 
				alert("Invalid hyperlink entered: " + newUrl); 
				return; 
			} 
			var sProtocol = newUrl.substring(0,6); 
			if (sProtocol == 'http:/') return 'https:/' + newUrl.substring(6);
			return sUnsecureURL;
		}
		

	// -----------------------------------------------------------------------------
	// <Nom>         getInformationURL
	// <Description> extrait les informations sur l'url a savoir le protocole, le nom
	//	de domaine, le port
	// <Parametres>  (I) sURL = URL complete, souvent le document.location
	// <Resultats>   Tableau contenant 
	//		- en position 0 le protocole http ou https
	//		- en position 1 le nom du server
	//		- en position 2 le port utilise, avec 80 si rien n est precise. si on voulait etre exact, il faudrait mettre egalement 443 si on est en https.
	// -----------------------------------------------------------------------------
	
		function getInformationURL(sURL) {
		
			var m_aResult=new Array(3);
			var m_sUrl=new String(sURL);
			
			if (sURL.length < 6) 
			{ 
				alert("Invalid hyperlink entered: " + sURL); 
				return; 
			}
			//recherche du protocole pour le premier parametre
			var m_sProtocol = m_sUrl.substring(0,6); 
			switch(m_sProtocol) 
			{
				case 'http:/' :
					m_aResult[0]='http';
					break;
				case 'https:' :
					m_aResult[0]='https';
					break;
			}
			var m_iPosSlash, m_iPosColon, m_sDomain;
			//recherche du domaine pour le deuxieme parametre
			//	on ajoute la longueur de '://' à la longueur du protocole trouvé (donc + 3)
			m_sUrl=m_sUrl.substring(m_aResult[0].length + 3);
			m_iPosColon=m_sUrl.indexOf(':'); 
			m_iPosSlash=m_sUrl.indexOf('/');
			//si deux points est apres slash, on en tient pas compte
			if (m_iPosColon>m_iPosSlash) m_iPosColon=-1;
			if (m_iPosColon < 0)
			{
				m_aResult[1] = m_sUrl.substring(0, m_iPosSlash);
				m_aResult[2] = '80';
			}
			else
			{
				m_aResult[1] = m_sUrl.substring(0, m_iPosColon);
				m_aResult[2] = m_sUrl.substring(m_iPosColon + 1,  m_iPosSlash);
			}
				
			//alert('getInformationURL=' + m_aResult[0] + '://' + m_aResult[1] + ':' + m_aResult[2]);
			return m_aResult;
		}
		

	// -----------------------------------------------------------------------------
	// <Nom>         replaceServernameTag
	// <Description> remplace le servername dans les url relatives par la valeur ad hoc
	// fonction du contexte
	// <Parametres>  (I) psUrl = Url ou le tag servername est a remplacer
	//				 (I) paParamsUrl = Tableau des parametres issu de la fonction getInformation
	// <Resultats>   l urltransformee
	// -----------------------------------------------------------------------------
	
		function replaceServernameTag(psUrl,paParamsUrl) 
		{
			var m_sRes;
			//	replace avec urlencode
			m_sRes=psUrl.replace(/http%3A%2F%2F%5Bservername%5D/g,paParamsUrl[0] + '%3A%2F%2F' + paParamsUrl[1] + (paParamsUrl[2]=='80' ? '' : '%3A'+paParamsUrl[2]));
			//	replace sans urlencode
			m_sRes=m_sRes.replace(/http:\/\/\[servername\]/g,paParamsUrl[0] + '://' + paParamsUrl[1] + (paParamsUrl[2]=='80' ? '' : ':'+paParamsUrl[2]));
			//	quelquesfois, il n'y a pas de protocole specifie (cas des contenus aicc HORIZONS)
			m_sRes=psUrl.replace(/%5Bservername%5D/g,paParamsUrl[1] + (paParamsUrl[2]=='80' ? '' : '%3A'+paParamsUrl[2]));
			m_sRes=m_sRes.replace(/\[servername\]/g,paParamsUrl[1] + (paParamsUrl[2]=='80' ? '' : ':'+paParamsUrl[2]));
			return m_sRes;
		}
		
	
	

// ************************************************************************************
//							Bibliotheque DIVERS
//
// 
//
// <Nom>	fnTrapKD, enter_key_trap
//
// <Date Creation> 12 janvier 2005
// ************************************************************************************
		
	
	// -----------------------------------------------------------------------------
	// <Nom>         fnTrapKD
	// <Description> Identifie une pression sur la touche RETURN
	// <Parametres>  (I) obj
	// <Resultats>   Booleen
	// -----------------------------------------------------------------------------
		function fnTrapKD(obj, evt) {
		    var keyCode = evt.keyCode ? evt.keyCode :
                    evt.charCode ? evt.charCode :
		            evt.which ? evt.which : void 0;

		    if (keyCode == 13) {
				evt.returnValue = false; 
			    // execution
			    fnExecuteKD();
			}
		}
	// -----------------------------------------------------------------------------
	// <Nom>         fnTrapKDOld, enter_key_trap
	// <Description> Selon le navigateur, identifie une pression sur la touche RETURN
	// <Parametres>  (I) obj
	// <Resultats>   Booleen
	// -----------------------------------------------------------------------------
		function fnTrapKDOld(obj) {
			if (navigator.appName == "Microsoft Internet Explorer") {
			    if (event.keyCode == 13) {
					event.returnValue = false; 
				    // execution
				    fnExecuteKD();
				}
			} else {
				if (window.document.captureEvents != null) {
				    window.document.captureEvents(Event.KEYPRESS);
				    window.document.onkeypress = enter_key_trap;
				}
			}
		}
		
		function enter_key_trap(e) {
		    var keyPressed;

		    if (document.layers) {
		        keyPressed = String.fromCharCode(e.which);
		    } else if (document.all) {
		        keyPressed = String.fromCharCode(window.event.keyCode);
		    } else if (document.getElementById) {
		        keyPressed = String.fromCharCode(e.keyCode);
		    }
		    if ((keyPressed == "\r" || keyPressed == "\n")) {
				// Execution
				fnExecuteKD();
			}
		}
		
// ************************************************************************************
//							Bibliotheque MAIL
//
// 
//
// <Nom>	SendSMTPMailToN
//
// <Date Creation> 21 Octobre 2008
// ************************************************************************************

		function SendSMTPMailToN(sURLRacine, SessionID, hiddenInputID)
		{
            var sQryStr   = 'SessionID=' + SessionID + '&hiddenInputID=' + hiddenInputID;
		    window.open(sURLRacine + 'Mail/FicheMessage.asp?' + sQryStr, 'Message','location=no,scrollbars=auto,resizable=yes,width=600,height=500');
		}
	
	
	
// ************************************************************************************
//							Bibliotheque URL
//
// 
//
// <Nom>	convertUrl 
//          Objet ayant deux méthodes : encode et decode
// <Date Creation> 05 Decembre 2008
// ************************************************************************************
	
var convertUrl = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}  	
