// JavaScript Document

/*////////////////////////////////////////////////////////////
/	function afficherEtats() (adapté par B. Lirette, 2007-11-07)
/	Fonction qui affiche les images de survol
/	strNomImage		=	nom de l'image à modifier					ie. btn_image_
/	strChemin		=	chemin vers l'image à afficher				ie. medias/images/
/	strEtat			=	nom de l'état à afficher					ie. rl, up
/	strFormat		=	nom de l'extension du fichier à afficher	ie. jpg, gif
////////////////////////////////////////////////////////////*/

function afficherEtats(strNomImage, strChemin, strEtat, strFormat)
	{
	// permet de gérer les mêmes occurrences se répétant dans la page
	strNomFichier = strNomImage.substring(0, strNomImage.length -1);

	// changement d'image
	document.images[strNomImage].src=strChemin+strNomFichier+strEtat+"."+strFormat;
	}

//
function gallerieImages(strNomImageCible, strCheminImageAfficher)
	{
	//alert(strChemin+strNomImage+strEtat+"."+strFormat);
	//document.images[strNomImage].src=strChemin+strNomImage+strEtat+"."+strFormat;
	
	//alert(strNomImageCible+" * "+strCheminImageAfficher);
	document.images[strNomImageCible].src=strCheminImageAfficher;
	}

//
function openpopup(urlnouv,intWidth,intHeight)
	{
	winpops = window.open(urlnouv,"","width="+intWidth+",height="+intHeight+",");
	}

// gestion des tables d'intersection

var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
	{
	var newOpt = new Option(theText, theValue);
	var selLength = theSel.length;
	theSel.options[selLength] = newOpt;
	}

function deleteOption(theSel, theIndex)
	{	
	var selLength = theSel.length;
	if(selLength>0)
		{
		theSel.options[theIndex] = null;
		}
	}

function deplacer_valeurs(theSelFrom, theSelTo)
	{
	var selLength = theSelFrom.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectedCount = 0;
	
	var i;
	
	// Find the selected Options in reverse order
	// and delete them from the 'from' Select.
	for(i=selLength-1; i>=0; i--)
		{
		if(theSelFrom.options[i].selected)
			{
			selectedText[selectedCount] = theSelFrom.options[i].text;
			selectedValues[selectedCount] = theSelFrom.options[i].value;
			deleteOption(theSelFrom, i);
			selectedCount++;
			}
		}
	
	// Add the selected text/values in reverse order.
	// This will add the Options to the 'to' Select
	// in the same order as they were in the 'from' Select.
	for(i=selectedCount-1; i>=0; i--)
		{
		addOption(theSelTo, selectedText[i], selectedValues[i]);
		}

	if(NS4) history.go(0);
	}

function enregistrerElements(champtxtActives, champTxtArchives, listeActives, listeArchives, txtSeparateur)
	{
	var txtInfo = "";
	for(var i = 0; i < listeActives.options.length; i++)
		{
		if (txtInfo == "")
			{
			txtInfo = listeActives.options[i].value;
			}
			else
			{
			txtInfo = txtInfo + txtSeparateur + listeActives.options[i].value;
			}
		}
	champtxtActives.value = txtInfo;
	
	txtInfo = "";
	for(var i = 0; i < listeArchives.options.length; i++)
		{
		if(txtInfo == "")
			{
			txtInfo = listeArchives.options[i].value;
			}
			else
			{
			txtInfo = txtInfo + txtSeparateur + listeArchives.options[i].value;
			}
		}
	champTxtArchives.value = txtInfo;
	}

// fonction servant à annuler la soumission d'un formulaire avec la touche « retour »
// Merci à : http://www.w3schools.com/jsref/jsref_onkeypress.asp
function ignorerRetour(e)
	{
	var characterCode;
	
	if(window.event)
		{
		// IE
		characterCode = e.keyCode;
		}
		else if(e.which)
		{
		// Netscape/Firefox/Opera
		characterCode = e.which;
		};
	
	if(characterCode == 13)
		{
		return false;
		}
		else
		{
		return true;
		}
	}