function onBlur(o , e)
{
	window.alert('TOTO');
	//o.value='TOTO';
}

// Cette fonction permet de mettre le focus sur le champ de recherche
function recherche_focus()
{
	if (document.formRechercheRapide && document.formRechercheRapide.novalisAction)
		document.formRechercheRapide.novalisAction.focus();
}

// cette fonction sert à récupérer les valeurs des options d'une sélection, dans une chaîne de caractère (séparé par ';')
function lireElementSelectionne(aobjSelect)
{
	// chaîne de caractère contenant les éléments sélectionnés séparés par des ','
	str = '';
	
	// nombre d'éléments de la sélection
	nbElt = aobjSelect.options.length;
	
	// on parcours tous les éléments du SELECT
	for (cpt = 0; cpt < nbElt; cpt++)
	{
		// si l'élément est sélectionné, alors on met sa valeur dans la chaîne de caractères 'str'
		if (aobjSelect.options[cpt].selected == true)
		{
			// s'il n'y a pas encore d'éléments, on en ajoute un
			if (str == '')
			{
				str += aobjSelect.options[cpt].value;
			}
			// s'il y en a, on en ajoute un précédé d'une virgule
			else 
			{
			 str += ',' + aobjSelect.options[cpt].value;
			}
		}
	}
	// on renvoie la chaîne de caractères contenant les valeurs des éléments sélectionnés, séparés par des ';'
	return str;
}

function onClick(o, E)
{
	window.alert('handler onClick');
}

// This function gets called when the end-user clicks on some date.
function selected(cal, date) 
{
	cal.sel.value = date; // just update the date in the input field.
	// if (cal.sel.id == "sel1" || cal.sel.id == "sel3")
	// if we add this call we close the calendar on single-click.
	// just to exemplify both cases, we are using this only for the 1st
	// and the 3rd field, while 2nd and 4th will still require double-click.
	cal.callCloseHandler();
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) 
{
  cal.hide();                        // hide the calendar
}

function ajouterSelection()
{
	result = false;
	do
	{
		document.getElementById('formSauvegarde').nomSelection.value = prompt('Veuillez entrer le nom de la nouvelle sélection.', '');
		if (document.getElementById('formSauvegarde').nomSelection.value == '')
		{
			alert('Le nom de la sélection ne peut pas être vide !');
		}
	} while (document.getElementById('formSauvegarde').nomSelection.value == '');
	if (document.getElementById('formSauvegarde').nomSelection.value != 'null')
	{
		result = confirm(document.getElementById('formSauvegarde').nomSelection.value);
	}
	return result;
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, format) 
{
  var el = document.getElementById(id);

  if (calendar != null) {
    // we already have some calendar created
    calendar.hide();                 // so we hide it first.
  } 
  else 
  {
    // first-time call, create the calendar.
    var cal = new Calendar(false, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    calendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  calendar.setDateFormat(format);    // set the specified date format
  calendar.parseDate(el.value);      // try to parse the text in field
  calendar.sel = el;                 // inform it what input field we use
  calendar.showAtElement(el);        // show the calendar below it

  return false;
}

var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;

// If this handler returns true then the "date" given as
// parameter will be disabled.  In this example we enable
// only days within a range of 10 days from the current
// date.
// You can use the functions date.getFullYear() -- returns the year
// as 4 digit number, date.getMonth() -- returns the month as 0..11,
// and date.getDate() -- returns the date of the month as 1..31, to
// make heavy calculations here.  However, beware that this function
// should be very fast, as it is called for each day in a month when
// the calendar is (re)constructed.
function isDisabled(date) 
{
  var today = new Date();
  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}

function flatSelected(cal, date) 
{
  var el = document.getElementById("preview");
  el.innerHTML = date;
}

function showFlatCalendar() 
{
  var parent = document.getElementById("displaycalendar");

  // construct a calendar giving only the "selected" handler.
  var cal = new Calendar(false, null, flatSelected);

  // hide week numbers
  cal.weekNumbers = false;

  // We want some dates to be disabled; see function isDisabled above
  cal.setDisabledHandler(isDisabled);
  cal.setDateFormat("DD, M d");

  // this call must be the last as it might use data initialized above; if
  // we specify a parent, as opposite to the "showCalendar" function above,
  // then we create a flat calendar -- not popup.  Hidden, though, but...
  cal.create(parent);

  // ... we can show it here.
  cal.show();
}

function cColor1(o) 
{
    o.style.backgroundColor = "#ffff99"
    if (o.id=="lastItem") {cCorner1()}
}

function cColor2(o) 
{
    o.style.backgroundColor = "#FFFFFF"
        if (o.id=="lastItem") {cCorner2()}
}

function cellOver(cell)
{
	cell.className = 'line-over';
	return true;
}

function cellOut(cell, css)
{
	cell.className = 'line-' + css + '';
	return true;
}

function cache_tri()
{
	document.getElementById('affichage_tri').style.display = "none";
}

function affiche_tri()
{
	document.getElementById('affichage_tri').style.display = "block";
}

function cache_recherche()
{
	document.getElementById('affichage_recherche').style.display = "none";
}

function affiche_recherche()
{
	document.getElementById('affichage_recherche').style.display = "block";
}

function majCode(code)
{
	document.getElementById('formSuppression').codeAction.value = code;
}

function majCodeTrack(numeroGalette,numero)
{
	document.getElementById('formSuppression').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formSuppression').numeroAction.value = numero;
}

function majId(id)
{
	document.getElementById('formSuppression').idAction.value = id;
}

function majIdArtiste(id)
{
	document.getElementById('formFiche').idAction.value = id;
}

function majIdObjet(id)
{
	document.getElementById('formFiche').idAction.value = id;
}

function activerSuppr()
{
	var x=window.confirm("Confirmez vous la suppression ?")
	if (x)
	{
		return true;
	}
	else
	{
		window.alert("Action annulée");
		return false;
	}
}

function activerModif(id, code, valeur)
{
  document.getElementById('formAjoutModification').idAction.value = id;
  document.getElementById('formAjoutModification').codeAction.value = code;
  document.getElementById('formAjoutModification').valeurAction.value = valeur;
  document.getElementById('formAjoutModification').action.value = 'actionParamSimpleModification';
}

function activerModifCompositeur(code, nom, prenom, nationalite)
{
  document.getElementById('formAjoutModification').codeAction.value = code;
  document.getElementById('formAjoutModification').nomAction.value = nom;
  document.getElementById('formAjoutModification').prenomAction.value = prenom;
  document.getElementById('formAjoutModification').nationaliteAction.value = nationalite;
  document.getElementById('formAjoutModification').action.value = 'actionParamObjetCompositeurModification';
}

function activerModifEditeur(code, raisonSociale, statutVideo, statutDisque)
{
  document.getElementById('formAjoutModification').codeAction.value = code;
  document.getElementById('formAjoutModification').raisonSocialeAction.value = raisonSociale;
  document.getElementById('formAjoutModification').statutVideoAction.value = statutVideo;
  document.getElementById('formAjoutModification').statutDisqueAction.value = statutDisque;
  document.getElementById('formAjoutModification').action.value = 'actionParamObjetEditeurModification';
}



function activerModifPays(id, code, valeur, libelleLangue, libelleHabitant)
{
  document.getElementById('formAjoutModification').idAction.value = id;
  document.getElementById('formAjoutModification').codeAction.value = code;
  document.getElementById('formAjoutModification').valeurAction.value = valeur;
  document.getElementById('formAjoutModification').libelleLangueAction.value = libelleLangue;
  document.getElementById('formAjoutModification').libelleHabitantAction.value = libelleHabitant;
  document.getElementById('formAjoutModification').action.value = 'actionParamComplexePaysModification';
}

function activerModifSousTitre(id, code,langue)
{
  document.getElementById('formAjoutModification').idAction.value = id;
  document.getElementById('formAjoutModification').codeAction.value = code;
  document.getElementById('formAjoutModification').langueAction.value = langue;
  document.getElementById('formAjoutModification').action.value = 'actionParamObjetSousTitreModification';
}


function activerModifChampDynamique(id, code, valeur, type, codeParam, unite)
{
	document.getElementById('formAjoutModification').idAction.value = id;
	document.getElementById('formAjoutModification').codeAction.value = code;
	document.getElementById('formAjoutModification').valeurAction.value = valeur;
	document.getElementById('formAjoutModification').typeAction.value = type;
	document.getElementById('formAjoutModification').paramAction.value = codeParam;
	document.getElementById('formAjoutModification').uniteAction.value = unite;
	document.getElementById('formAjoutModification').action.value = 'actionParamComplexeChampDynamiqueModification';
}

function annulerModifChampDynamique()
{
	document.getElementById('formAjoutModification').idAction.value = '';
	document.getElementById('formAjoutModification').codeAction.value = '';
	document.getElementById('formAjoutModification').valeurAction.value = '';
	document.getElementById('formAjoutModification').typeAction.value = '';
	document.getElementById('formAjoutModification').paramAction.value = '';
	document.getElementById('formAjoutModification').uniteAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamComplexeChampDynamiqueAjout';
}


function annulerModifParamTrackListingGalette()
{
	document.getElementById('formAjoutModification').numeroGaletteAction.value = '';
	document.getElementById('formAjoutModification').libelleAction.value = '';
	document.getElementById('formAjoutModification').numeroAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetTrackListingAjoutGalette';
}

function annulerModifTelephoneFax()
{
	document.getElementById('formAjoutModification').correspondantAction.value = '';
	document.getElementById('formAjoutModification').numeroAction.value = '';
	document.getElementById('formAjoutModification').typeTelAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetTelephoneFaxAjout';
}

function annulerModifDateParution()
{
	document.getElementById('formAjoutModification').dateAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamDateParutionAjout';
}

function annulerModifParamTrackListingTrack()
{
	//document.getElementById('formAjoutModification').numeroGaletteAction.value = '';
	document.getElementById('formAjoutModification').numeroAction.value = '';
	document.getElementById('formAjoutModification').libelleAction.value = '';
	document.getElementById('formAjoutModification').dureeAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetTrackListingAjoutTrack';
}
function annulerModifParamObjetPisteAudio()
{
	document.getElementById('formAjoutModification').idAction.value = '';
	document.getElementById('formAjoutModification').codeAction.value = '';
	document.getElementById('formAjoutModification').langueAction.value = '';
	document.getElementById('formAjoutModification').typeCanalAction.value = '';
	document.getElementById('formAjoutModification').standardAudioAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetPisteAudioAjout';
}


function annulerModif()
{
	document.getElementById('formAjoutModification').id.value = '';
	document.getElementById('formAjoutModification').codeAction.value = '';
	document.getElementById('formAjoutModification').valeurAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamSimpleAjout';
}

function annulerModifPays()
{
	document.getElementById('formAjoutModification').idAction.value = '';
	document.getElementById('formAjoutModification').codeAction.value = '';
	document.getElementById('formAjoutModification').valeurAction.value = '';
	document.getElementById('formAjoutModification').libelleLangueAction.value = '';
	document.getElementById('formAjoutModification').libelleHabitantAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamComplexePaysAjout';
}

function annulerModifSousTitre()
{
	document.getElementById('formAjoutModification').idAction.value = '';
	document.getElementById('formAjoutModification').codeAction.value = '';
	document.getElementById('formAjoutModification').langueAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetSousTitreAjout';
}


function annulerModifCompositeur()
{
	document.getElementById('formAjoutModification').codeAction.value = '';
	document.getElementById('formAjoutModification').nomAction.value = '';
	document.getElementById('formAjoutModification').prenomAction.value = '';
	document.getElementById('formAjoutModification').nationaliteAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetCompositeurAjout';
}

function annulerModifEditeur()
{
	document.getElementById('formAjoutModification').codeAction.value = '';
	document.getElementById('formAjoutModification').raisonSocialeAction.value = '';
	document.getElementById('formAjoutModification').statutVideoAction.value = '';
	document.getElementById('formAjoutModification').statutDisqueAction.value = '';
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetEditeurAjout';
}

function activerFiche(action,id)
{
	document.getElementById('formFiche').action.value=action; 
	document.getElementById('formFiche').idAction.value = id;
	document.formFiche.submit();
}

function activerFicheSupport(action,position)
{
	document.getElementById('formSuppression').action.value=action; 
	document.getElementById('formSuppression').positionAction.value = position;
	document.formSuppression.submit();
}

function activerFicheParPosition(action,position)
{
	document.getElementById('formFiche').action.value=action; 
	document.getElementById('formFiche').positionAction.value = position;
	document.formFiche.submit();
}


function activerModifParamTrackListingGalette(numeroGalette, libelle)
{
	document.getElementById('formAjoutModification').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formAjoutModification').libelleAction.value = libelle;
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetTrackListingModificationGalette';
}



function activerModifParamObjetPisteAudio(standardAudio,code,langue,canal)
{
	document.getElementById('formAjoutModification').standardAudioAction.value = standardAudio;
	document.getElementById('formAjoutModification').codeAction.value = code;
	document.getElementById('formAjoutModification').langueAction.value = langue;
	document.getElementById('formAjoutModification').canalAction.value = canal;
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetPisteAudioModification';
}

function activerModifParamTrackListingTrack(numeroGalette,numero,libelle,duree)
{
	document.getElementById('formAjoutModification').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formAjoutModification').numeroAction.value = numero;
	document.getElementById('formAjoutModification').libelleAction.value = libelle;
	document.getElementById('formAjoutModification').dureeAction.value = duree;
	document.getElementById('formAjoutModification').action.value = 'actionParamObjetTrackListingModificationTrack';
}


function majIdActionDeplacerAscGalette(numeroGalette, action)
{
	document.getElementById('formSuppression').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formSuppression').action.value ='actionParamObjetTrackListingAscGalette'; 
	document.formSuppression.submit();
}

function majIdActionDeplacerDescGalette(numeroGalette, action)
{
	document.getElementById('formSuppression').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formSuppression').action.value ='actionParamObjetTrackListingDescGalette'; 
	document.formSuppression.submit();
}

function majIdActionDeplacerAscTrack(numeroGalette,numero, action)
{
	document.getElementById('formSuppression').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formSuppression').numeroAction.value = numero;
	document.getElementById('formSuppression').action.value ='actionParamObjetTrackListingAscTrack'; 
	document.formSuppression.submit();
}

function majIdActionDeplacerDescTrack(numeroGalette,numero, action)
{
	document.getElementById('formSuppression').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formSuppression').numeroAction.value = numero;
	document.getElementById('formSuppression').action.value ='actionParamObjetTrackListingDescTrack'; 
	document.formSuppression.submit();
}

function majCodeActionTrack(numeroGalette,numero,action)
{
	document.getElementById('formSuppression').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formSuppression').numeroAction.value = numero;
	document.getElementById('formSuppression').action.value ='actionParamObjetTrackListingSuppressionTrack'; 
}

function majIdActionPisteAudio(id, action)
{
	document.getElementById('formSuppression').idAction.value = id;

	document.getElementById('formSuppression').action.value ='actionParamObjetPisteAudioSuppression'; 
}

function majActionUtilisateurListe(login, action)
{
	document.getElementById('formFiche').loginAction.value = login;
	eval("document.getElementById('formFiche').universAction.value=document.formFiche.univers"+login+"[document.formFiche.univers"+login+".selectedIndex].value;");
	eval("if (document.formFiche.avecPouvoir"+login+".checked) document.getElementById('formFiche').avecPouvoirAction.value='1';");
	document.getElementById('formFiche').action.value = action;
	document.formFiche.submit();
}

function majIdActionSupport(position, action)
{
	document.getElementById('formSuppression').positionAction.value = position;

	document.getElementById('formSuppression').action.value ='actionParamObjetSupportSuppression'; 
}


function majCodeActionGalette(numeroGalette,action)
{
	document.getElementById('formSuppression').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formSuppression').action.value = 'actionParamObjetTrackListingSuppressionGalette';
}

//à mettre à jour avec le numéro de la galette
function majIdAction(id, action)
{
	document.getElementById('formSuppression').action.value='actionParamTrackListingModification'; 
	document.getElementById('formSuppression').id.value = id;
	document.formSuppression.submit();
}



/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

function OuvrirPopup(page,nom,option) 
{
	window.open(page,nom,option);
}


function majNumeroGaletteActionDeplacerAscGalette(numeroGalette, action)
{
	document.getElementById('formSuppression').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formSuppression').action.value ='actionParamObjetTrackListingAscGalette'; 
	document.formSuppression.submit();
}

function majNumeroGaletteActionDeplacerDescGalette(numeroGalette, action)
{
	document.getElementById('formSuppression').numeroGaletteAction.value = numeroGalette;
	document.getElementById('formSuppression').action.value ='actionParamObjetTrackListingDescGalette'; 
	document.formSuppression.submit();
}

function majNumeroGaletteAction(numeroGalette, action)
{
	document.getElementById('formSuppression').action.value='actionParamTrackListingModification'; 
	document.getElementById('formSuppression').numeroGalette.value = numeroGalette;
}

function majIdActionTelephoneFax(position)
{
	//document.getElementById('formSuppression').positionAction.value = position;
	document.forms.formSuppression.positionAction.value = position;
}

function majIdActionDateParution(position)
{
	//document.getElementById('formSuppression').positionAction.value = position;
	document.forms.formSuppression.positionAction.value = position;
}

function activerModifTelephoneFax(position, correspondant, numero, typeTel)
{
  document.getElementById('formAjoutModification').positionAction.value = position;
  document.getElementById('formAjoutModification').correspondantAction.value = correspondant;
  document.getElementById('formAjoutModification').numeroAction.value = numero;
  document.getElementById('formAjoutModification').typeTelAction.value = typeTel;
  document.getElementById('formAjoutModification').action.value = 'actionParamObjetTelephoneFaxModification';
}

function activerModifDateParution(position, date)
{
  document.getElementById('formAjoutModification').positionAction.value = position;
  document.getElementById('formAjoutModification').dateAction.value = date;
  document.getElementById('formAjoutModification').action.value = 'actionParamDateParutionModification';
}

function getSelectedValues (select) {
var r = '';
if(select.options.length == 1) return select.options[0].value;
for (var i = 0; i < select.options.length; i++)
{
if (i ==0) r = select.options[0].value;
else r += ','+select.options[i].value;
}
return r;
}

function getSelectedTexts (select) {
var r = '';
for (var i = 0; i < select.options.length; i++)
{
	if (i ==0) r = select.options[0].text;
	else r += ','+select.options[i].text;
}
return r;
}

function lireIdParValeur (select,valeur) {
  var r = new Array();
  for (var i = 0; i < select.options.length; i++){
    if (select.options[i].value == valeur)
		var id = i;
	}
  return id;
}

function supprimerOptionParId (select,optionIndex) {
	 select.options[optionIndex] = null;
}


function  initialiserListe(champInput)
{
	var val = opener.document.getElementById('frm_MedleyTool').champInput.value;
	var tableauValeur = val.split(",", -1);
	for (var i = 0; i < tableauValeur.length; i++){
		var valeur = tableauValeur[i];
		var id = lireIdParValeur(document.getElementById('frm_MedleyTool').LeftList,valeur);
		texte =document.getElementById('frm_MedleyTool').LeftList.options[id].text;
		var opt = new Option(texte,valeur);
		var sel = document.getElementById('frm_MedleyTool').RightList;
		sel.options[sel.options.length] = opt;
		supprimerOptionParId(document.getElementById('frm_MedleyTool').LeftList, id);
	}
}

// fonction de validation de la saisie d'un Login Utilisateur
function verifLoginUtilisateur(astrNomFormulaire, astrNomChampTexte)
{
	var lstrLoginSaisi = eval("document." + astrNomFormulaire + "." + astrNomChampTexte + ".value");
	if (lstrLoginSaisi.length < 8)
	{
		alert("Veuillez saisir un login d'utilisateur d'au moins 8 caractères.");
		return;
	}
	if (lstrLoginSaisi.search(/[^0-9a-zA-Z]+/) != -1)
	{
		alert("Veuillez saisir un login d'utilisateur contenant uniquement des chiffres ou des lettres.");
		eval("document." + astrNomFormulaire + "." + astrNomChampTexte + ".value = lstrLoginSaisi.replace(/[^0-9a-zA-Z]+/, '');");
		return;
	}
	return 1;
}

// fonction de validation de la saisie d'un nouveau mot de passe
function verifMotDePasseUtilisateur(astrNomFormulaire, astrNomChampAncienM2P, astrNomChampNouveauM2P, astrNomChampConfirmationM2P)
{
	var lstrAncienM2P = eval("document." + astrNomFormulaire + "." + astrNomChampAncienM2P + ".value");
	var lstrNouveauM2P = eval("document." + astrNomFormulaire + "." + astrNomChampNouveauM2P + ".value");
	var lstrConfirmationM2P = eval("document." + astrNomFormulaire + "." + astrNomChampConfirmationM2P + ".value");
	if (lstrAncienM2P == lstrNouveauM2P)
	{
		alert("Veuillez saisir un nouveau mot de passe différent de l'ancien.");
		return;
	}
	if (lstrNouveauM2P.length < 8)
	{
		alert("Veuillez saisir un nouveau mot de passe d'au moins 8 caractères.");
		return;
	}
	if (lstrNouveauM2P.search(/[^0-9a-zA-Z]+/) != -1)
	{
		alert("Veuillez saisir un nouveau mot de passe contenant uniquement des chiffres ou des lettres.");
		eval("document." + astrNomFormulaire + "." + astrNomChampNouveauM2P + ".value = lstrNouveauM2P.replace(/[^0-9a-zA-Z]+/, '');");
		eval("document." + astrNomFormulaire + "." + astrNomChampConfirmationM2P + ".value = '';");
		return;
	}
	if (lstrNouveauM2P != lstrConfirmationM2P)
	{
		alert("Veuillez saisir une confirmation identique à votre nouveau mot de passe.");
		eval("document." + astrNomFormulaire + "." + astrNomChampConfirmationM2P + ".value = '';");
		return;
	}
	eval("document." + astrNomFormulaire + ".submit();");
}

// fonction qui met les dates saisies au bon format
function formatage_date(arefChampTexte)
{
	var separateur = '/';
	var lstrDateSaisie = arefChampTexte.value;
	if (lstrDateSaisie.search(/[^0-9\-\/]/) != -1)
		lstrDateSaisie = lstrDateSaisie.replace(/[^0-9\-\/]+/, '');
	var lintLongueurSaisie = lstrDateSaisie.length;
	if (lintLongueurSaisie < 4 || lintLongueurSaisie > 10)
		return '';
	var today = new Date();
	switch(lintLongueurSaisie)
	{
		case 4:
		case 5:
			lstrDateSaisie = lstrDateSaisie.replace(/^([0-9]{2}).?([0-9]{2})$/, "$1" + separateur + "$2" + separateur + today.getYear());
		break;
		case 6:
			lstrDateSaisie = lstrDateSaisie.replace(/^([0-9]{2})([0-9]{2})([0-9]{2})$/, "$1" + separateur + "$2" + separateur + today.getYear().toString().substring(0, 2) + "$3");
		break;
		case 8:
			lstrDateSaisie = lstrDateSaisie.replace(/^([0-9]{2})([0-9]{2})([0-9]{4})$/, "$1" + separateur + "$2" + separateur + "$3");
		break;
		case 10:
			lstrDateSaisie = lstrDateSaisie.replace(/^([0-9]{2}).?([0-9]{2}).?([0-9]{4})$/, "$1" + separateur + "$2" + separateur + "$3");
		break;
	}
	if (verif_date_exist(lstrDateSaisie.slice(0, 2), lstrDateSaisie.slice(3, 5), lstrDateSaisie.slice(6, 10)) == false)
		return '';
	return lstrDateSaisie;
}

// #######################################################################################################			
// fonctions utilisées pour controler la touche entrée sur le site

// détermine l'index du champ actuellement sélectionné
var gintChampSelectionne = -1;
// définit le nom du formulaire de saisie
var gstrNomFormulaireFiche = 'form';

// définit la liste des type des champs non pris en compte par la touche entrée
var garrTypeChampIgnore = new Array
	(
		'radio',
		'checkbox',
		'image',
		'submit',
		'file',
		'button',
		'hidden'
	)

// détermine si une valeur se trouve ou non parmi les valeurs d'un tableau
function in_array(amixValeur, aarrTableauDeValeur)
{
	for (lintCompteur=0; lintCompteur<aarrTableauDeValeur.length; lintCompteur++)
		if (aarrTableauDeValeur[lintCompteur] == amixValeur)
			return true;
	return false;
}

// retourne la référence du champ suivant à sélectionner
function numeroChampSuivant(astrNomFormulaire, aintNumeroChamp)
{
	aintNumeroChamp++;
	if (aintNumeroChamp == document.forms[astrNomFormulaire].length)
		aintNumeroChamp = 0;
	return aintNumeroChamp;
}

// sélectionne le champs de saisie suivant dans un formulaire
function selectionnerChampSuivant(astrNomFormulaire)
{
	if (gintChampSelectionne != -1)
		document.forms[astrNomFormulaire][gintChampSelectionne].className = '';
	var lintNumeroChamp = numeroChampSuivant(astrNomFormulaire, gintChampSelectionne);
	while (document.forms[astrNomFormulaire][lintNumeroChamp].readOnly
		|| in_array(document.forms[astrNomFormulaire][lintNumeroChamp].type, garrTypeChampIgnore)
		)
		lintNumeroChamp = numeroChampSuivant(astrNomFormulaire, lintNumeroChamp);
	
	document.forms[astrNomFormulaire][lintNumeroChamp].focus();
	document.forms[astrNomFormulaire][lintNumeroChamp].className = 'styleChampCourant';
	return lintNumeroChamp;
}

// action associée à la touche entrée
function actionToucheEntree()
{
	if (window.event.type == "keypress" & window.event.keyCode == 13)
		gintChampSelectionne = selectionnerChampSuivant(gstrNomFormulaireFiche);
	return !(window.event.type == "keypress" & window.event.keyCode == 13); 
} 

// fonction excécuté dans les pages Fiche pour initialiser la sélection des champs à l'aide de la touche entrée
function initialisation()
{
	document.onkeypress = actionToucheEntree;
	gintChampSelectionne = selectionnerChampSuivant(gstrNomFormulaireFiche);
}

// #######################################################################################################			
// définition des fonctions de validation des formulaires.

// Retourne le nombre d'éléments d'un tableau
function array_size(aarrTableau)
{
	if (aarrTableau == null)
	{
		alert("[array_size]: Arguments invalides !!!\n"
			+ "\naarrTableau = null"
		);
		return false;
	}
	var lintNombreElement = 0;
	for (var lmixCle in aarrTableau)
		lintNombreElement++;
	return lintNombreElement;
}

// fonction qui renvoie tous les éléments d'un tableau sous forme d'une chaîne de caractères
// en les collant à l'aide d'un chaîne de caractères "glue"
function implode(aarrTableau, astrGlue)
{
	if (aarrTableau == null || array_size(aarrTableau) == 0)
	{
		alert("[implode]: Arguments invalides !!!\n"
			+ "\naarrTableau = " + (aarrTableau == null ? 'null' : 'Array(' + (array_size(aarrTableau) > 0 ? implode(aarrTableau, ', ') : '') + ')')
			+ "\nastrGlue = " + (astrGlue == null ? 'null' : '`' + astrGlue + '´')
		);
		return false;
	}
	var lstrChaineDeCaractere = '';
	var lintNumeroCle = 0;
	for (var lmixCle in aarrTableau)
	{
		lstrChaineDeCaractere += (astrGlue != null && lintNumeroCle > 0 ? astrGlue : '') + aarrTableau[lmixCle];
		lintNumeroCle++;
	}
	return lstrChaineDeCaractere;
}

// fonction qui supprime les espaces en début et en fin d'une chaîne de caractères

function trim(astrChaineDeCaractere)
{
	if (astrChaineDeCaractere == null)
	{
		alert("[trim]: Arguments invalides !!!\n"
			+ "\nastrChaineDeCaractere = " + (astrChaineDeCaractere == null ? 'null' : '`' + astrChaineDeCaractere + '´')
		);
		return false;
	}
	return astrChaineDeCaractere.replace(/^[ \n\r]*|[ \n\r]*$/g,'', '');
}

// Recherche dans un tableau la clé associée à une valeur
function array_search(aarrTableau, amixValeur)
{
	if (aarrTableau == null || amixValeur == null
		|| array_size(aarrTableau) == 0
		)
	{
		alert("[array_search]: Arguments invalides !!!\n"
			+ "\naarrTableau = " + (aarrTableau == null ? 'null' : 'Array(' + (array_size(aarrTableau) > 0 ? implode(aarrTableau, ', ') : '') + ')')
			+ "\namixValeur = " + (amixValeur == null ? 'null' : '`' + amixValeur + '´')
		);
		return false;
	}
	for (var lstrCle in aarrTableau)
		if (aarrTableau[lstrCle] == amixValeur)
			return lstrCle;
	return false;
}

// Récupère la valeur de l'élément n d'un tableau
function array_getElement(aarrTableau, aintNumeroElement)
{
	if (aarrTableau == null || aintNumeroElement == null
		|| array_size(aarrTableau) == 0 || aintNumeroElement < 1
		|| aintNumeroElement > array_size(aarrTableau)
		)
	{
		alert("[array_getElement]: Arguments invalides !!!\n"
			+ "\naarrTableau = " + (aarrTableau == null ? 'null' : 'Array(' + (array_size(aarrTableau) > 0 ? implode(aarrTableau, ', ') : '') + ')')
			+ "\naintNumeroElement = " + (aintNumeroElement == null ? 'null' : aintNumeroElement)
		);
		return false;
	}
	var lintNumeroElement = 1;
	for (var lstrCle in aarrTableau)
	{
		if (lintNumeroElement == aintNumeroElement)
			return aarrTableau[lstrCle];
		lintNumeroElement++;
	}
	return false;
}

// #######################################################################################################

// Teste si un champ donné est rempli
function testChampRempli(astrNomFormulaire, aarrNomLibelleChamp)
{
	var lstrNomChamp = array_search(aarrNomLibelleChamp, array_getElement(aarrNomLibelleChamp, 1));
	if (astrNomFormulaire == null || aarrNomLibelleChamp == null
		|| trim(astrNomFormulaire) == '' || array_size(aarrNomLibelleChamp) != 1 
		|| document.forms[astrNomFormulaire] == null
		|| document.forms[astrNomFormulaire][lstrNomChamp] == null
		)
	{
		alert("[testChampRempli]: Arguments invalides !!!\n"
			+ "\nastrNomFormulaire = " + (astrNomFormulaire == null ? 'null' : '`' + astrNomFormulaire + '´')
			+ "\naarrNomLibelleChamp = " + (aarrNomLibelleChamp == null ? 'null' : 'Array(' + (array_size(aarrNomLibelleChamp) > 0 ? implode(aarrNomLibelleChamp, ', ') : '') + ')')
			+ "\ndocument.forms[`" + astrNomFormulaire + "´] = " + (document.forms[astrNomFormulaire] == null ? 'null' : 'instancié')
			+ "\ndocument.forms[`" + astrNomFormulaire + "´][`" + lstrNomChamp +"´] = " + (document.forms[astrNomFormulaire][lstrNomChamp] == null ? 'null' : 'instancié')
		);
		return false;
	}
	if (trim(document.forms[astrNomFormulaire][lstrNomChamp].value) == '')
	{
		var lstrVerbeErreur = '';
		switch(document.forms[astrNomFormulaire][lstrNomChamp].type)
		{
			case 'file':
				lstrVerbeErreur = 'sélectionner';
			break;
			case 'text':
			default:
				lstrVerbeErreur = 'saisir';
			break;
		}
		alert("Veuillez " + lstrVerbeErreur + " " + aarrNomLibelleChamp[lstrNomChamp] + ".");
		return false;
	}
	return true;
}

// Teste si chaque champs de la liste donnée est rempli
// Dans le cas d'un sous tableau de champs dans le tableau "aarrListeChamp", elle teste si au moins l'un d'entre eux est rempli
function testSelectionChampRempli(astrNomFormulaire, aarrListeChamp)
{
	if (astrNomFormulaire == null || aarrListeChamp == null
		|| document.forms[astrNomFormulaire] == null
		|| trim(astrNomFormulaire) == '' || array_size(aarrListeChamp) == 0 
		)
	{
		alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
			+ "\nastrNomFormulaire = " + (astrNomFormulaire == null ? 'null' : '`' + astrNomFormulaire + '´')
			+ "\naarrListeChamp = " + (aarrListeChamp == null ? 'null' : 'Array(' + (array_size(aarrListeChamp) > 0 ? implode(aarrListeChamp, ', ') : '') + ')')
			+ "\ndocument.forms[`" + astrNomFormulaire + "´] = " + (document.forms[astrNomFormulaire] == null ? 'null' : 'instancié')
		);
		return false;
	}
	for(var lmixCleChamp in aarrListeChamp)
	{
		// si ce n'est pas un tableau
		if (!aarrListeChamp[lmixCleChamp].sort)
		{
			var larrNomLibelleChamp = new Array();
			larrNomLibelleChamp[lmixCleChamp] = aarrListeChamp[lmixCleChamp];
			if (testChampRempli(astrNomFormulaire, larrNomLibelleChamp) == false)
				return false;
		}
		else
		{
			var lintTotalChampRempli = 0;
			for(var lmixCleSousChamp in aarrListeChamp[lmixCleChamp])
			{
				if (document.forms[astrNomFormulaire][lmixCleSousChamp] == null)
				{
					alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
						+ "\ndocument.forms[`" + astrNomFormulaire + "´][`" + lmixCleSousChamp +"´] = null"
					);
					return false;
				}
				if (trim(document.forms[astrNomFormulaire][lmixCleSousChamp].value) != '')
					lintTotalChampRempli++;
			}
			if (lintTotalChampRempli == 0)
			{
				alert("Veuillez saisir au moins un des champs suivant : " + implode(aarrListeChamp[lmixCleChamp], ', ').replace(/(.*),{1}(.*)$/, "$1 ou$2") + ".");
				return false;
			}
		}
	}
	return true;
}

// teste si l'extension d'un fichier sélectionné appartient bien a la liste des extensions autorisées donnée
function testExtensionFichier(astrNomFormulaire, astrNomChamp, aarrListeExtensionAutorise, astrLibelleErreur)
{
	var lintNombreExtension = array_size(aarrListeExtensionAutorise);
	if (astrNomFormulaire == null || astrNomChamp == null || aarrListeExtensionAutorise == null
		|| document.forms[astrNomFormulaire] == null || document.forms[astrNomFormulaire][astrNomChamp] == null
		|| trim(astrNomFormulaire) == '' || lintNombreExtension == 0
		)
	{
		alert("[testExtensionFichier]: Arguments invalides !!!\n"
			+ "\nastrNomFormulaire = " + (astrNomFormulaire == null ? 'null' : '`' + astrNomFormulaire + '´')
			+ "\nastrNomChamp = " + (astrNomChamp == null ? 'null' : '`' + astrNomChamp + '´')
			+ "\naarrListeExtensionAutorise = " + (aarrListeExtensionAutorise == null ? 'null' : 'Array(' + (array_size(aarrListeExtensionAutorise) > 0 ? implode(aarrListeExtensionAutorise, ', ') : '') + ')')
			+ "\nastrLibelleErreur = " + (astrLibelleErreur == null ? 'null' : '`' + astrLibelleErreur + '´')
			+ "\ndocument.forms[`" + astrNomFormulaire + "´] = " + (document.forms[astrNomFormulaire] == null ? 'null' : 'instancié')
			+ "\ndocument.forms[`" + astrNomFormulaire + "´][`" + astrNomChamp +"´] = " + (document.forms[astrNomFormulaire][astrNomChamp] == null ? 'null' : 'instancié')
		);
		return false;
	}
	var lstrImplodeExtension = implode(aarrListeExtensionAutorise, ' .');
	if (lstrImplodeExtension.search(document.forms[astrNomFormulaire][astrNomChamp].value.replace(/.*\.{1}(.*)$/, "$1")) == -1)
	{
		alert("Veuillez sélectionner un fichier " + (astrLibelleErreur != null ? astrLibelleErreur : '') + " au" + (lintNombreExtension > 1 ? 'x' : '') + " format" + (lintNombreExtension > 1 ? 's' : '') + " : " + lstrImplodeExtension.replace(/(.*)\.{1}(.*)$/, "$1" + (lintNombreExtension > 1 ? 'ou ' : '') + "$2").replace(/ \./g, ', '));
		return false;
	}
	return true;
}

// test au moins 2 champ de saisie sur n sont remplis alors qu'un seul d'entre eux ne doit l'être
function testChampIncompatible(astrNomFormulaire, aarrListeChamp, aarrListeLibelleChamp)
{
	if (astrNomFormulaire == null || aarrListeChamp == null
		|| document.forms[astrNomFormulaire] == null
		|| trim(astrNomFormulaire) == '' || array_size(aarrListeChamp) < 2
		|| (aarrListeLibelleChamp != null && array_size(aarrListeChamp) != array_size(aarrListeLibelleChamp))
		)
	{
		alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
			+ "\nastrNomFormulaire = " + (astrNomFormulaire == null ? 'null' : '`' + astrNomFormulaire + '´')
			+ "\naarrListeChamp = " + (aarrListeChamp == null ? 'null' : 'Array(' + (array_size(aarrListeChamp) > 0 ? implode(aarrListeChamp, ', ') : '') + ')')
			+ "\naarrListeLibelleChamp = " + (aarrListeLibelleChamp == null ? 'null' : 'Array(' + (array_size(aarrListeLibelleChamp) > 0 ? implode(aarrListeLibelleChamp, ', ') : '') + ')')
			+ "\ndocument.forms[`" + astrNomFormulaire + "´] = " + (document.forms[astrNomFormulaire] == null ? 'null' : 'instancié')
		);
		return false;
	}
	var lintNombreChampRempli = 0;
	for (lmixCleChamp in aarrListeChamp)
	{
		if (document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]] == null)
		{
			alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
				+ "\ndocument.forms[`" + astrNomFormulaire + "´][`" + aarrListeChamp[lmixCleChamp] +"´] = null"
			);
			return false;
		}
		if (trim(document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]].value) != '')
		{
			if (aarrListeLibelleChamp == null)
				document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]].focus();
			else
				lintNombreChampRempli++;
		}
	}
	if (aarrListeLibelleChamp != null && lintNombreChampRempli > 1)
	{
		alert("Les champs suivant ne peuvent pas être remplis en même temps : `" + (implode(aarrListeLibelleChamp, '´, `')).replace(/(.*),{1}(.*)$/, "$1 et$2") + '´');
		return false;
	}
	else if (aarrListeLibelleChamp != null && lintNombreChampRempli == 0)
	{
		alert("Veuillez remplir au moins l'un des champs suivants : `" + (implode(aarrListeLibelleChamp, '´, `')).replace(/(.*),{1}(.*)$/, "$1 ou$2") + '´');
		return false;
	}
	return true;
}

// Active et/ou désactive tous les autres champs d'une liste de champs incompatibles lorsque l'un d'eux est rempli.
// Il faut vider ce dernier champ pour réactiver tous les champs.
function activeDesactiveChampIncompatible(astrNomFormulaire, aarrListeChamp, amixChampActuel)
{
	if (astrNomFormulaire == null || aarrListeChamp == null || amixChampActuel == null
		|| document.forms[astrNomFormulaire] == null
		|| trim(astrNomFormulaire) == '' || array_size(aarrListeChamp) < 2
		)
	{
		alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
			+ "\nastrNomFormulaire = " + (astrNomFormulaire == null ? 'null' : '`' + astrNomFormulaire + '´')
			+ "\naarrListeChamp = " + (aarrListeChamp == null ? 'null' : 'Array(' + (array_size(aarrListeChamp) > 0 ? implode(aarrListeChamp, ', ') : '') + ')')
			+ "\ndocument.forms[`" + astrNomFormulaire + "´] = " + (document.forms[astrNomFormulaire] == null ? 'null' : 'instancié')
			+ "\namixChampActuel = " + (amixChampActuel == null ? 'null' : 'instancié')
		);
		return false;
	}
	if (!amixChampActuel.readOnly && !amixChampActuel.desabled)
	{
		if(trim(amixChampActuel.value) != '')
		{
			for(var lmixCleChamp in aarrListeChamp)
			{
				if (document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]] == null)
				{
					alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
						+ "\ndocument.forms[`" + astrNomFormulaire + "´][`" + aarrListeChamp[lmixCleChamp] +"´] = null"
					);
					return false;
				}
				if (document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]].name != amixChampActuel.name)
				{
					document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]].readOnly = true;
					document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]].desabled = true;
					document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]].className = 'champLectureSeule';
				}
			}
		}
		else
		{
			for(var lmixCleChamp in aarrListeChamp)
			{
				if (document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]] == null)
				{
					alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
						+ "\ndocument.forms[`" + astrNomFormulaire + "´][`" + aarrListeChamp[lmixCleChamp] +"´] = null"
					);
					return false;
				}
				if (document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]] != amixChampActuel)
				{
					amixChampActuel.readOnly = false;
					amixChampActuel.desabled = false;
					amixChampActuel.className = '';
				}
			}
		}
	}
	return true;
}

// Colorie et vide tous les autres champs d'une liste de champs incompatibles lorsque l'un d'eux est sélectionné.
function colorieChampIncompatible(astrNomFormulaire, aarrListeChamp, amixChampActuel)
{
	if (astrNomFormulaire == null || aarrListeChamp == null || amixChampActuel == null
		|| document.forms[astrNomFormulaire] == null
		|| trim(astrNomFormulaire) == '' || array_size(aarrListeChamp) < 2
		)
	{
		alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
			+ "\nastrNomFormulaire = " + (astrNomFormulaire == null ? 'null' : '`' + astrNomFormulaire + '´')
			+ "\naarrListeChamp = " + (aarrListeChamp == null ? 'null' : 'Array(' + (array_size(aarrListeChamp) > 0 ? implode(aarrListeChamp, ', ') : '') + ')')
			+ "\ndocument.forms[`" + astrNomFormulaire + "´] = " + (document.forms[astrNomFormulaire] == null ? 'null' : 'instancié')
			+ "\namixChampActuel = " + (amixChampActuel == null ? 'null' : 'instancié')
		);
		return false;
	}
	for(var lmixCleChamp in aarrListeChamp)
	{
		if (document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]] == null)
		{
			alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
				+ "\ndocument.forms[`" + astrNomFormulaire + "´][`" + aarrListeChamp[lmixCleChamp] +"´] = null"
			);
			return false;
		}
		if (document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]] != amixChampActuel)
		{
			document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]].className = 'champLectureSeule';
			document.forms[astrNomFormulaire][aarrListeChamp[lmixCleChamp]].value = '';
		}
		else
			amixChampActuel.className = '';
	}
	return true;
}

// Désactive les champs colorié d'un formulaire
function desactiveChampColorie(astrNomFormulaire, astrClasse)
{
	if (astrNomFormulaire == null || astrClasse == null
		|| document.forms[astrNomFormulaire] == null
		|| trim(astrNomFormulaire) == '' || trim(astrClasse) == ''
		)
	{
		alert("[testSelectionChampRempli]: Arguments invalides !!!\n"
			+ "\nastrNomFormulaire = " + (astrNomFormulaire == null ? 'null' : '`' + astrNomFormulaire + '´')
			+ "\astrClasse = " + (astrClasse == null ? 'null' : '`' + astrClasse + '´')
			+ "\ndocument.forms[`" + astrNomFormulaire + "´] = " + (document.forms[astrNomFormulaire] == null ? 'null' : 'instancié')
		);
		return false;
	}
	for(var lmixCleChamp in document.forms[astrNomFormulaire])
	{
//alert('document.forms['+astrNomFormulaire+']['+lmixCleChamp+']');
		if (lmixCleChamp.match(/.*(.{6})/) == 'Action' || lmixCleChamp.match(/.*(.{7})/) == 'Libelle')
		{
			if (document.forms[astrNomFormulaire][lmixCleChamp].className == astrClasse)
			{
				document.forms[astrNomFormulaire][lmixCleChamp].disabled = true;
				document.forms[astrNomFormulaire][lmixCleChamp.replace('Libelle', 'Action')].disabled = true;
			}
		}
	}
	return true;
}

function que_nb_reel() {
	if (String.fromCharCode(event.keyCode).search(/[^0-9\.,]/) != -1) {
		event.returnValue = false;
	}
	if (String.fromCharCode(event.which).search(/[^0-9\.,]/) != -1) {
		return false;
	}
}

function que_chiffres() {
	if (String.fromCharCode(event.keyCode).search(/[^0-9]/) != -1) {
		event.returnValue = false;
	}
	if (String.fromCharCode(event.which).search(/[^0-9]/) != -1) {
		return false;
	}
}

function verif_date_exist(jj, mm, aaaa) {
       var d2 = new Date(aaaa, mm-1, jj);
       var j2 = d2.getDate();
       var m2 = d2.getMonth()+1;
       var a2 = d2.getYear();
       if (a2 <= 100)
		a2 = 1900 + a2;
       if (jj != j2 || mm != m2 || aaaa != a2)
	 	return(false);
	else
	 	return(true);
}

function testCodeBarre(astrCodeBarre)
{
	while (astrCodeBarre.length < 13)
		astrCodeBarre += '0';

	var aintCleValidation = parseInt(astrCodeBarre.slice(12, 13));
	astrCodeBarre = astrCodeBarre.slice(0, 12);

	var lintSommeTotale = 0;
	
	for(charPos = astrCodeBarre.length - 1; charPos >= 0; charPos--) 
	{
		if (charPos / 2 == parseInt(charPos / 2))
			lintSommeTotale = lintSommeTotale + (parseInt(astrCodeBarre.substring(charPos,charPos+1)));
		else
			lintSommeTotale = lintSommeTotale + (3 * parseInt(astrCodeBarre.substring(charPos,charPos+1)));
	}
	
	var lintCleValidation;
	
	var remainder = lintSommeTotale - parseInt(lintSommeTotale/10) * 10;
	if( remainder == 0 )
		lintCleValidation = '0';
	else
		lintCleValidation = 10 - remainder;
	
	if (lintCleValidation == aintCleValidation)
		return true;
	else
		return false;
}

// fonction qui met les durées des tracklistings au bon format
function formatage_dureeTrack(arefChampTexte)
{
	var lstrDureeTrack = arefChampTexte.value;
	if (lstrDureeTrack.search(/[^0-9]/) != -1)
		lstrDureeTrack = lstrDureeTrack.replace(/[^0-9]+/, '');
	var lintLongueurSaisie = lstrDureeTrack.length;
	if (lintLongueurSaisie != 4)
		return '';

	lstrDureeTrack = lstrDureeTrack.replace(/^([0-9]{2})([0-9]{2})$/, "$1'$2''");

	return lstrDureeTrack;
}
