function majImgCopy()
{
	var aCollectionsImagesRandoms = $$('img.collectionsImageRandom');	
	aCollectionsImagesRandoms.each(function(img) {
	  var imgNom = img.src;
	  var nomAbrege = imgNom.substring(imgNom.lastIndexOf('/')+1,imgNom.indexOf('.jpg'));
	  var data = $H({
		'nomAbrege': nomAbrege
	  }).toQueryString();
      var sCopy;
	  new Ajax.Request ( '/reqAjax/collectionsImageCopy.aspx', {
	    postBody: data,
		  onSuccess: function (transport)
		  {
		    sCopy = transport.responseText;
		    sCopy = sCopy.sub(/\s/,''); // Suppression des espaces internes
		    sCopy = sCopy.gsub(/<!--.*-->/,''); // Suppression des commentaires
			sCopy = sCopy.strip(); // Suppression des espaces externes;
			img.title = sCopy;
		  }
	  });
	});
}
function afficheCollection(v) 
{
	var fiche = v;
	if (!fiche.blank()) {
	  if ($('collectionsFiche')) {
	    var data = $H({
		  'fiche': fiche
	    }).toQueryString();
	    if ($('collectionsFicheNom')) {
			new Ajax.Updater('collectionsFicheNom','/reqAjax/collectionsFicheTitre.aspx', {
				postBody: data
			});
		}
	    new Ajax.Updater('collectionsFiche','/reqAjax/collectionsFiche.aspx', {
		  postBody: data
	    });
	  }
	  else {
	    window.location.replace("/collectionsFiche.aspx?fiche="+fiche);
	  }
	}
	else {
	    window.location.replace("/collectionsFiche.aspx?fiche=LAG");
	}
}// Req Ajax mettant à jour le contenu de la div collectionFiche
function afficheCollectionFromEvent(evt)
{
	var elt = Event.findElement(evt, 'select');
	var fiche = $F(elt.id) || '';
	afficheCollection(fiche); // Execution afficheCollection
	var eSlcCollectionsAutres = $$('#gauche select.slcCollections');
    eSlcCollectionsAutres.each(function(elt2) {
      if (elt !== elt2) {
	    elt2.selectedIndex = 0;
	  }
	});// Mise à jour des boites de choix
}// Fct appellée si une collection est selectionnée dans les listes de choix
function afficheCollectionFromUrl(v,id) 
{
	var fiche = v || '';
    var ficheid = id || 0;
	afficheCollection(fiche);// Execution afficheCollection
	var eSlcCollectionsOptions = $$('#gauche select.slcCollections option');
    eSlcCollectionsOptions.each(function(elt) {
      if (fiche == elt.value) {
		  var collectionSelect = elt.up('select');
		  collectionSelect.selectedIndex = ficheid;
	  }
	});// Mise à jour des boites de choix
}// Fct appellée lorsqu'un lien d'une collection est cliqué sur la page collections.aspx 
function initFct(e) 
{
	var eSlcCollections = $$('#gauche select.slcCollections');
	eSlcCollections.each(function(elt) {
		addEventIfExists(elt.id, 'change', afficheCollectionFromEvent);
	});
	var frm = window.location.href.toQueryParams();
	if (frm['fiche']) {
	  var fiche = frm['fiche'];
	  var ficheid = frm['ficheid'];
	  afficheCollectionFromUrl(fiche,ficheid);
	}
}// Association de la fct de mise à jour : soit en fonction de l'observateur d'évènement 'change' sur les boites de choix / soit en fonction de la présence de 'fiche' dans l'url
Event.observe(window, 'load', majImgCopy, false);
Event.observe(window, 'load', initFct, false);
