
	  // We initialize the associative array that this file will feed and send over to the LMS
      var CDSData = {};
      // We set a first key right away because it may be needed before startPROGRESSION() is called (in the add() function).
      CDSData.CDS_BaseURL = document.URL.replace(/[^\/\\]+\.[^\/\\]*$/,"").replace(/([\\\/])common[\\\/]/i,'$1');
	  CDSData.CDS_LaunchPage = document.URL.substring(CDSData.CDS_BaseURL.length);
	  
	  
      CDSData.CDS_BaseURL = CDSData.CDS_BaseURL.replace(/[\\]/g,"/");
      //CDSData.CDS_BaseURL = CDSData.CDS_BaseURL.replace(/http[s]?:/,"http:");
      if(/^file:\/+/.test(CDSData.CDS_BaseURL)) CDSData.CDS_BaseURL=CDSData.CDS_BaseURL.replace(/^file:\/+/,'').replace(/\//g,'\\');
      // This function will add an 'available aus' array to the current CDS definition.
      // We also automatically add corresponding diagnosis and 'aide-mémoire' units.
      function R(ReCle,LaCle,ReTitre,ReSouTit,ReLib,ReDesc,aMoCles,RcModObl,RcSai,RcSaiPeu,RcSeuMin,RcSeuMax,RcAffSol){
        eval('CDSData.CDS["' + ReCle + '"].AUs = aMoCles');
        if(aMoCles.length){
          eval('CDSData.CDS["' + ReCle + '"].AUs[CDSData.CDS["' + ReCle + '"].AUs.length] = aMoCles[0].substr(0,5) + "_AM"');
          eval('CDSData.CDS["' + ReCle + '"].AUs[CDSData.CDS["' + ReCle + '"].AUs.length] = aMoCles[0].substr(0,5) + "_DIAG"');
        }
      }

      // This function is called from the init file and appends location declarations to the CDSData associative array.
      // A call is also made to the R function if the content is from iProgress. This call is made by including
      // appropriate metadata.
      function add(locationid, proprietarycontent, support, detail) {
        if (!CDSData.CDS) CDSData.CDS = {};
        eval('CDSData.CDS["' + locationid + '"] = {}');
        eval('CDSData.CDS["' + locationid + '"].Detail = (support == "CD" ? detail : (!detail.length ? CDSData.CDS_BaseURL : normalizePath(detail)))');
        eval('CDSData.CDS["' + locationid + '"].Support = support');
        if (false && proprietarycontent) {
          switch(support) {
            case 'CDS':
              document.write('<script src=\"' + normalizePath(eval('CDSData.CDS["' + locationid + '"].Detail')) + 'metadata\/' + locationid + '.js\"><\/script>');
              break;
            case 'HD':
              var htm=('<script src=\"file:///' + normalizePath(eval('CDSData.CDS["' + locationid + '"].Detail')) + 'metadata\/' + locationid + '.js\"><\/script>');
			  document.write(htm);
              break;
            default:
              document.write('<script src=\"metadata\/' + locationid + '.js\"><\/script>');
          }
        }
      }

      // This function will, as its name suggests, normalize a path (URL or file). 
      // It will add '/' or '\' at the end if needed.
      function normalizePath(path) {
        if (path.charAt(path.length-1) == '/' || path.charAt(path.length-1) == '\\' || path.search(/\.[0-9a-z]+$/) != -1)
          return path;
        else
          return path + path.match(/[\/\\]/);
      }

      // This function is called on the page load event and does the required work to start the application
      function startPROGRESSION() {
	    /*
        // We make sure that the user is using IE4 or later
        if (!/Firefox\//.test(navigator.userAgent) && msieversion() < 4) {
          alert ("Votre ordinateur doit disposer d'une version 4.0 ou ultérieure de Microsoft Internet Explorer pour que vous puissiez accéder à PROGRESSION®."+
		  "\nuserAgent="+navigator.userAgent);
          return false;
        }
		*/
        
        // We make sure that the init file defines the URL of the LMS
        if (typeof(LMS_URL) == 'undefined' || !LMS_URL) {
          alert("Une erreur s'est produite:\n\nLe fichier d'initialisation ne contient pas l'adresse URL de l'application (LMS_URL).");
          return false;
        }

        // We make sure that the init file defines the CDS version
        if (typeof(Version) == 'undefined' || !Version) {
          alert("Une erreur s'est produite:\n\nLe fichier d'initialisation ne contient pas la version du serveur de contenu.");
          return false;
        }

        // We check the integrity of the init file's content location definition
        for (member in CDSData.CDS) {
          for (submember in eval('CDSData.CDS["' + member + '"]')) {
            if (typeof(eval('CDSData.CDS["' + member + '"].Detail')) == 'undefined') {
              alert("Une erreur s'est produite:\n\nLe fichier d'initialisation contient une incohérence dans la déclaration de l'emplacement des contenus.");
              return false;
            }
          }
        }
        
        // We feed the CDSData associative array with the information provided in the init file
        // We also add extra information that the LMS will need to work properly
        // (CDSData.CDS_BaseURL and CDSData.CDS_LaunchPage are set at the top of the file)
		if(typeof Client!='string'||!Client.length){
			var m=/[?&](Client|CliCode)=([^&]+)/i.exec(location.search);
			if(m) {
				Client=unescape(m[2]);
			}
		}
		if(typeof AuthToken!='string'||!AuthToken.length){
			var m=/[?&]AuthToken=([^&]+)/i.exec(location.search);
			if(m) {
				CDSData.AuthToken = unescape(m[1]);
			}
		}
		CDSData.Client = ((typeof(Client) != 'undefined' && Client) ? Client : -1);
        CDSData.LMS_BaseURL = LMS_URL.substring(0, LMS_URL.search(/[^\/]*$/));
        CDSData.LMS_LaunchPage = LMS_URL.substring(LMS_URL.search(/[^\/]*$/), LMS_URL.length);
        CDSData.Def_CDSDetail = CDSData.LMS_BaseURL.replace(/[\/]lms[\/]/, '/cds/');
        CDSData.Version = Version;

        // We try to create a WDDX packet from the CDSData associative array and show an error message on failure
        var WDDX_CDSData = new WddxSerializer().serialize(CDSData);
        if (WDDX_CDSData == null) {
          alert("Une erreur s'est produite:\n\nLe fichier d'initialisation contient une incohérence.");
          return false;
        }

        // We initialize the form ...
        var form = eval(document.CDSData);
        form.action = LMS_URL;
        form.CDSData.value = WDDX_CDSData;
        
        // and submit it
        form.submit();

        return true;
      }

      // This function returns the version number of Internet Explorer
      function msieversion() {
        var ua = window.navigator.userAgent;
        var msie = ua.indexOf("MSIE ");

        if (msie > 0)      // If Internet Explorer, return version number
          return parseInt (ua.substring(msie+5, ua.indexOf(".", msie)));
        else               // If another browser, return 0
          return 0;
      }
