/**
 * @FileFR » Gestion d'un calendrier
 * @FileEN » Management of a calendar
 */

/**
 * @FunctionFR getDayName » Retourne le nom du jour correspondant à la date
 * @FunctionEN getDayName » Return the name of the day corresponding to the date
 * @ParamFR asDateValue String / » Date saisie dans le champs de texte
 * @ParamEN asDateValue String / » Typing date in the textbox
 * @ParamFR aeLanguageFormat Enum / » Langage de la date (FR = JJ/MM/AAAA, EN = MM/JJ/AAAA)
 * @ParamEN aeLanguageFormat Enum / » Language of the date (FR = DD/MM/YYYY, EN = MM/DD/YYYY)
 * @ParamFR abSearch Boolean / » Recherche ou non (caractères autorisés : > < =)
 * @ParamEN abSearch Boolean / » Search or not (authorised characters > < =)
 * @ReturnFR String » Nom du jour correspondant à la date
 * @ReturnEN String » Name of the day corresponding to the date
 */
function getDayName(asDateValue, aeLanguageFormat, abSearch)
{
   if (asDateValue == '')
   {
      return '';
   }
   if (eval(abSearch))
   {
      if (asDateValue.substr(0,2) == "<=" || asDateValue.substr(0,2) == ">=" || asDateValue.substr(0,2) == "<>")
      {
         asDateValue = asDateValue.substr(2,asDateValue.length-2);
      }
      else if (asDateValue.substr(0,1) == "<" || asDateValue.substr(0,1) == ">" || asDateValue.substr(0,1) == "=")
      {
         asDateValue = asDateValue.substr(1,asDateValue.length-1);
      }
   }
   if (aeLanguageFormat == "EN")
   {
      ldDate = new Date(asDateValue.substring(6,10), asDateValue.substring(0,2)-1, asDateValue.substring(3,5));
   }
   else
   {
      ldDate = new Date(asDateValue.substring(6,10), asDateValue.substring(3,5)-1, asDateValue.substring(0,2));
   }
   var lsDayName = '';
   if (ldDate.getDay() >= 0 && ldDate.getDay() <= 6)
   {
      lsDayName = DivioLang["daysFull"][ldDate.getDay()];
   }
   return lsDayName;
}


/**
 * @FunctionFR equalBeginDate » Affecte la valeur de la date de début dans la date de fin
 * @FunctionEN equalBeginDate » Set the value of the date beginning in the end date
 * @ParamFR asBeginDateField String / » Champ de la date de début
 * @ParamEN asBeginDateField String / » Field of the beginning date
 */
function equalBeginDate(asBeginDateField)
{
   document.principal.elements[asBeginDateField+"End"].value = document.principal.elements[asBeginDateField].value;
   if (document.principal.elements[asBeginDateField+"DayName"])
   {
      document.principal.elements[asBeginDateField+"EndDayName"].value = document.principal.elements[asBeginDateField+"DayName"].value;
   }
}


/*******************************************************************************
                          Partie Affichage du calendrier
*******************************************************************************/


/**
 * @FunctionFR showCalendar » Affiche le calendrier
 * @FunctionEN showCalendar » Display the calendar 
 * @ParamFR asDatefield String / » Nom du champ calendrier
 * @ParamEN asDatefield String / » Name of the calendar field
 * @ParamFR asDateValue String / » Date saisie dans le champs de texte
 * @ParamEN asDateValue String / » Typing date in the textbox
 * @ParamFR asCurrentdate String / » Date choisie par la navigation dans le calendrier
 * @ParamEN asCurrentdate String / » Date choosen by the browsing in the calendar
 * @ParamFR aeDateFormat Enum / » Format de la date (D = JJ/MM/AAAA, T = JJ/MM/AAAA HH:MI:SS)
 * @ParamEN aeDateFormat Enum / » Format of the date (D = DD/MM/YYYY, T = DD/MM/YYYY HH:MI:SS)
 * @ParamFR aeLanguageFormat Enum / » Langage de la date (FR = JJ/MM/AAAA, EN = MM/JJ/AAAA)
 * @ParamEN aeLanguageFormat Enum / » Language of the date (FR = DD/MM/YYYY, EN = MM/DD/YYYY)
 * @ParamFR abSearch Boolean / » Recherche ou non (caractères autorisés : > < =)
 * @ParamEN abSearch Boolean / » Search or not (authorised characters > < =)
 */
function showCalendar(asDatefield, asDatevalue, asCurrentdate, aeDateFormat, aeLanguageFormat, abSearch)
{
   var lsFieldDayName = "";
   var lsValueDayName;
   if (parent.document && parent.document.principal[asDatefield])
   {
      var lsId = parent.document.principal[asDatefield].id;
      loWindowOpener = parent;
      lsWindowOpener = "parent";
      windowClose = "parent.document.getElementById('"+parent.document.principal[asDatefield].id+"Calendar').style.display='none'";
      if (parent.document && parent.document.principal[asDatefield+"DayName"])
      {
         lsFieldDayName = "javascript:parent.document.principal."+asDatefield+"DayName.value = ";
      }
   }
   else if (window.document && window.document.principal[asDatefield])
   {
      var lsId = window.document.principal[asDatefield].id;
      loWindowOpener = window;
      lsWindowOpener = "window";
      windowClose = "parent.document.getElementById('"+window.document.principal[asDatefield].id+"Calendar').style.display='none'";
      if (window.document && window.document.principal[asDatefield+"DayName"])
      {
         lsFieldDayName = "javascript:parent.document.principal."+asDatefield+"DayName.value = ";
      }
   }
   
   
   if (abSearch && (asDatevalue == asCurrentdate))
   {
      if (asDatevalue.substr(0,2) == "<=" || asDatevalue.substr(0,2) == ">=" || asDatevalue.substr(0,2) == "<>")
      {
         asDatevalue = asDatevalue.substr(2,asDatevalue.length-2);
      }
      else if (asDatevalue.substr(0,1) == "<" || asDatevalue.substr(0,1) == ">" || asDatevalue.substr(0,1) == "=")
      {
         asDatevalue = asDatevalue.substr(1,asDatevalue.length-1);
      }
      asCurrentdate = asDatevalue;
   }
   
   if (asDatevalue == null || asDatevalue =="")
   {
      asDatevalue = getDatetime(new Date(), aeDateFormat, aeLanguageFormat);
   }
   var ldDatevalue = (asDatevalue == null || asDatevalue =="" ?  new Date() : str2Date(asDatevalue, aeLanguageFormat, false));
   

   var ldCurrentdate = (asCurrentdate == null || asCurrentdate =="" ?  new Date() : str2Date(asCurrentdate, aeLanguageFormat, true));
   ldCurrentdate.setDate(1);
   var ldPrevYear  = new Date(ldCurrentdate);
       ldPrevYear.setYear(ldCurrentdate.getFullYear()-1);
   var ldPrevMonth = new Date(ldCurrentdate);
       ldPrevMonth.setMonth(ldCurrentdate.getMonth()-1);
   var ldNextMonth = new Date(ldCurrentdate);
       ldNextMonth.setMonth(ldCurrentdate.getMonth()+1)
   var ldNextYear  = new Date(ldCurrentdate);
       ldNextYear.setYear(ldDatevalue.getFullYear()+1);
   var ldFirstDay  = new Date(ldCurrentdate);
       ldFirstDay.setDate(1);
       ldFirstDay.setDate(1-(7+ldFirstDay.getDay()-DivioLang["weekStart"])%7);
   var liMonth;
   var liYear;
   var ldSelected;

   var lsSelectBuffer = "<select class=\"calendarListBox\" name=\"lbDate\" onChange=\"javascript:parent.showCalendar('"+asDatefield+"','"+asDatevalue+"', this.options[this.selectedIndex].value + ' ' + document.cal.time.value, '"+aeDateFormat+"', '"+aeLanguageFormat+"', "+abSearch+");\">\n";
   for (var nbMonths = -12 ; nbMonths <= 12 ; nbMonths++)
   {
      if (ldCurrentdate.getMonth()+nbMonths < 0)
      {
         liMonth = 12 + (ldDatevalue.getMonth()+nbMonths);
         liYear = ldCurrentdate.getFullYear()-1;
      }
      else if (ldCurrentdate.getMonth()+nbMonths > 11)
      {
         liMonth = ldCurrentdate.getMonth()+nbMonths-12;
         liYear = ldCurrentdate.getFullYear()+1;
      }
      else
      {
         liMonth = ldCurrentdate.getMonth()+nbMonths;
         liYear = ldCurrentdate.getFullYear();
      }
      ldSelected = new Date(ldCurrentdate);
      ldSelected.setDate(1);
      ldSelected.setMonth(ldCurrentdate.getMonth()+nbMonths)
      lsSelectBuffer += "<option value=\""+date2Str(ldSelected,aeLanguageFormat)+"\"";
      if (nbMonths == 0)
      {
         lsSelectBuffer += " selected ";
      }
      lsSelectBuffer += ">"+DivioLang["months"][liMonth]+" "+liYear+"</option>\n";
   }
   lsSelectBuffer += "</select>\n";
   
   // Génération en HTML

   // Affichage de l'entête du calendrier
   var lsBufferBegin = new String (
      "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"+
      "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n"+
      "<head>\n"+
      "   <title>"+DivioLang["calendar"]+"</title>\n"+
      "   <link href=\""+ CSS_URL +"calendar.css\" rel=\"stylesheet\" type=\"text/css\" />\n"+
      "</head>\n"+
      "<body class=\"calendarBody\" onLoad=\"setTimeout('self.focus()', 500);resizeIframe();resizeIframe();\">\n" +
         "<form name=\"cal\" action=\"\">\n"+
            "<div id=\"calendarTable\">\n");
   var lsBuffer = new String (
            "<table class=\"calendarTable\" align=\"center\" cellspacing=\"0\">\n"+
               "<tr>\n"+
                  "<td>\n"+
                     "<table class=\"intoCalendarTable\" cellspacing=\"1\" cellpadding=\"3\">\n"+
                        "<tr>\n"+
                           "<td class=\"calendarNavigation\" colspan=\"7\" width=\"100%\">\n"+
                              "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n"+
                                 "<tr>\n"+
                                    "<td width=\"43\">\n"+
                                       "<a href=\"javascript:parent.showCalendar('"+asDatefield+"','"+asDatevalue+"', '"+date2Str(ldPrevYear,aeLanguageFormat)+" '+document.cal.time.value, '"+aeDateFormat+"', '"+aeLanguageFormat+"', "+abSearch+");\" title=\""+DivioLang["prevYear"]+"\">"+
                                          "<img class=\"calendarImage\" src=\""+IMG_URL+"calendar-first.gif\" border=\"0\" alt=\""+DivioLang["prevYear"]+"\"/></a>\n"+
                                       "<a href=\"javascript:parent.showCalendar('"+asDatefield+"','"+asDatevalue+"', '"+date2Str(ldPrevMonth,aeLanguageFormat)+" '+document.cal.time.value, '"+aeDateFormat+"', '"+aeLanguageFormat+"', "+abSearch+");\" title=\""+DivioLang["prevMonth"]+"\">"+
                                          "<img class=\"calendarImage\" src=\""+IMG_URL+"calendar-previous.gif\" border=\"0\" alt=\""+DivioLang["prevMonth"]+"\"/></a>\n"+
                                    "</td>\n"+
                                    "<td align=\"center\">\n"+
                                       lsSelectBuffer+
                                    "</td>\n"+
                                    "<td align=\"right\" width=\"43\">\n"+
                                       "<a href=\"javascript:parent.showCalendar('"+asDatefield+"','"+asDatevalue+"', '"+date2Str(ldNextMonth,aeLanguageFormat)+" '+document.cal.time.value, '"+aeDateFormat+"', '"+aeLanguageFormat+"', "+abSearch+");\" title=\""+DivioLang["nextMonth"]+"\">"+
                                       "<img class=\"calendarImage\" src=\""+IMG_URL+"calendar-next.gif\" border=\"0\" alt=\""+DivioLang["nextMonth"]+"\"/></a>\n"+
                                       "<a href=\"javascript:parent.showCalendar('"+asDatefield+"','"+asDatevalue+"', '"+date2Str(ldNextYear,aeLanguageFormat)+" '+document.cal.time.value, '"+aeDateFormat+"', '"+aeLanguageFormat+"', "+abSearch+");\" title=\""+DivioLang["nextYear"]+"\">"+
                                       "<img class=\"calendarImage\" src=\""+IMG_URL+"calendar-last.gif\" border=\"0\" alt=\""+DivioLang["nextYear"]+"\"/></a>\n"+
                                    "</td>\n"+
                                 "</tr>\n"+
                              "</table>\n"+
                           "</td>\n"+
                        "</tr>\n");

   var ldCurrentDay = new Date(ldFirstDay);

   // Titres des jours de la semaine
   lsBuffer += "<tr>\n";
   for (var nbDays=0; nbDays<7; nbDays++)
   {
      lsBuffer += "<td class=\"calendarHeader\" width=\"14%\" align=\"center\" colspan=\"1\">\n"+
                       DivioLang["days"][(DivioLang["weekStart"]+nbDays)%7]+"\n";
                    "</td>\n";
   }
   // Tableau Calendrier
   lsBuffer += "</tr>\n";
   while (ldCurrentDay.getMonth() == ldCurrentdate.getMonth() || ldCurrentDay.getMonth() == ldFirstDay.getMonth())
   {
      // Affichage d'une ligne
      lsBuffer += "<tr>\n";
      for (var nbDays=0; nbDays<7; nbDays++)
      {
         if (ldCurrentDay.getDate() == ldDatevalue.getDate() && ldCurrentDay.getMonth() == ldDatevalue.getMonth() && ldCurrentDay.getFullYear() == ldDatevalue.getFullYear())
         {
            // Date courante
            lsBuffer += "<td class=\"currentDate";
         }
         else if (ldCurrentDay.getDay() == 0 || ldCurrentDay.getDay() == 6)
         {
            // Jours de week-end
            lsBuffer += "<td  class=\"weekendDate";
         }
         else
         {
            // Jours travaillés du mois courant
            lsBuffer += "<td class=\"weekDate";
         }
         if (ldCurrentDay.getMonth() != ldCurrentdate.getMonth())
         {
            // Jours travaillés du mois courant
            lsBuffer += " otherMonthDate";
         }
         lsBuffer += "\">";
         

         lsValueDayName = '';
         if (lsFieldDayName != "")
         {
            lsValueDayName = lsFieldDayName + "'" + getDayName(date2Str(ldCurrentDay,aeLanguageFormat)) + "'";
         }

         lsBuffer += "<a href=\"javascript:parent.document.principal."+asDatefield+".value='"+getDatetime(ldCurrentDay, aeDateFormat, aeLanguageFormat)+"'; "+lsValueDayName+";parent.checkControls(new Array(new Array('Date', '"+lsId+"', '"+aeDateFormat+"', '"+aeLanguageFormat+"', 'false', 'E', '"+lsId+"Span', '"+lsId+"')));"+ windowClose +"\">";
         lsBuffer += ldCurrentDay.getDate()+"</a>\n"+
                                                "</td>\n";
         ldCurrentDay.setDate(ldCurrentDay.getDate()+1);
      }
      lsBuffer += "</tr>\n";
   }

   // Affichage du pied du calendrier
   if (aeDateFormat == 'T') // DateTime  affichage de l'heure
   {
      lsBuffer +=
                           "<tr>\n"+
                              "<td colspan=\"7\" class=\"calendarFooter\">\n"+
                                    DivioLang["time"]+" <input class=\"timeTextBox\" type=\"text\" name=\"time\" value=\""+time2Str(ldCurrentdate,aeLanguageFormat)+"\" size=\""+(aeLanguageFormat == "FR" ? "8" : "14")+"\" maxlength=\""+(aeLanguageFormat == "FR" ? "8" : "13")+"\" "+
                                    "onChange=\"javascript:"+ lsWindowOpener +".showCalendar('"+asDatefield+"', '"+asDatevalue+"', '"+date2Str(ldCurrentdate,aeLanguageFormat)+" '+document.cal.time.value, '"+aeDateFormat+"', '"+aeLanguageFormat+"', "+abSearch+");\"/>"+
                              "</td>\n"+
                           "</tr>\n"+
                        "</table>\n";
   }
   else
   {
      lsBuffer +=     "</table>\n"+
                        " <input type=\"hidden\" name=\"time\" value=\""+time2Str(ldDatevalue,aeLanguageFormat)+"\"/>";
   }
   lsBuffer +=
                     "</td>\n"+
                  "</tr>\n"+
               "</table>\n";
   var lsBufferEnd = new String (
            "</div>\n"+
            "</form>\n"+
         "</body>\n"+
         "<script type=\"text/javascript\">\n"+
         "function resizeIframe() {\n"+
         "   aoIFrame = parent.document.getElementById('"+loWindowOpener.document.principal[asDatefield].id+"Calendar');\n"+
         "   aoIFrame.height = aoIFrame.contentWindow.document.body.scrollHeight;\n"+
         "}\n"+
         "</script>\n"+
      "</html>\n");
   var loCalendarDoc = loWindowOpener.document.getElementById(loWindowOpener.document.principal[asDatefield].id+"Calendar").contentWindow.document;
   if (loCalendarDoc.getElementById('calendarTable') != null)
   {
      loCalendarDoc.getElementById('calendarTable').innerHTML = lsBuffer;
      resizeIframe(loWindowOpener.document.getElementById(loWindowOpener.document.principal[asDatefield].id+"Calendar"));
      // Pour Firefox, faire un 2nd appel pour bien redimensionner l'iframe
      resizeIframe(loWindowOpener.document.getElementById(loWindowOpener.document.principal[asDatefield].id+"Calendar"));
   }
   else
   {
      loCalendarDoc.write (lsBufferBegin + lsBufferEnd);
      loCalendarDoc.close();
      loCalendarDoc.getElementById('calendarTable').innerHTML = lsBuffer;
      resizeIframe(loWindowOpener.document.getElementById(loWindowOpener.document.principal[asDatefield].id+"Calendar"));
      // Pour Firefox, faire un 2nd appel pour bien redimensionner l'iframe
      resizeIframe(loWindowOpener.document.getElementById(loWindowOpener.document.principal[asDatefield].id+"Calendar"));
   }
}

// Redimensionne l'iframe
// Id iframe à redimensionner
function resizeIframe(aoIFrame) {
   aoIFrame.height = aoIFrame.contentWindow.document.body.scrollHeight;
}

/**
 * @FunctionFR str2Date » Transforme une chaîne en une date et la retourne
 * @FunctionEN str2Date » Transform a string into a date and return it
 * @ParamFR asDateValue String / » Date saisie dans le champs de texte
 * @ParamEN asDateValue String / » Typing date in the textbox
 * @ParamFR aeLanguageFormat Enum / » Langage de la date (FR = JJ/MM/AAAA, EN = MM/JJ/AAAA)
 * @ParamEN aeLanguageFormat Enum / » Language of the date (FR = DD/MM/YYYY, EN = MM/DD/YYYY)
 * @ParamFR abShowMessage Boolean / » Affichage ou non du message d'erreur
 * @ParamEN abShowMessage Boolean / » Display or not of the error message
 * @ReturnFR Date » Date correspondante
 * @ReturnEN Date » Corresponding date
 */
function str2Date(asDatevalue, aeLanguageFormat, abShowMessage)
{
   if (aeLanguageFormat == "FR")
   {
      var reDate = /^(\d+)\/(\d+)\/(\d+)\ +(\d+)\:(\d+)\:(\d+)$/;
   }
   else
   {
      var reDate = /^(\d+)\/(\d+)\/(\d+)\ +(\d+)\:(\d+)\:(\d+)\ (.+)$/;
   }
   if (!reDate.exec(asDatevalue))
   {
      var reDate = /^(\d+)\/(\d+)\/(\d+)$/;
      if (!reDate.exec(asDatevalue))
      {
         if (abShowMessage)
         {
            alert(DivioLang["msgErrorDateFormat"] + asDatevalue);
         }
         return new Date();
      }
      if (aeLanguageFormat == "FR")
      {
         return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1));
      }
      else
      {
         return (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2));
      }
   }
   if (aeLanguageFormat == "FR")
   {
      return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
   }
   else
   {
      if (RegExp.$7 != "a.m." && RegExp.$7 != "p.m.")
      {
         formatTime = "a.m.";
      }
      else
      {
         formatTime = RegExp.$7;
      }
      hour = RegExp.$4;
      if (formatTime == "a.m." && hour == 12)
      {
         hour = "00";
      }
      if (formatTime == "p.m.")
      {
         hour = hour + 12;
         if (hour == 24)
         {
            hour = 12;
         }
      }
      return (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2, hour, RegExp.$5, RegExp.$6));
   }
}


/**
 * @FunctionFR str2Date » Transforme une date en une chaîne et la retourne
 * @FunctionEN str2Date » Transform a date into a string and return it
 * @ParamFR adDateValue Date / » Date javascript
 * @ParamEN adDateValue Date / » Javascript date
 * @ParamFR aeLanguageFormat Enum / » Langage de la date (FR = JJ/MM/AAAA, EN = MM/JJ/AAAA)
 * @ParamEN aeLanguageFormat Enum / » Language of the date (FR = DD/MM/YYYY, EN = MM/DD/YYYY)
 * @ReturnFR String » Chaîne correspondante
 * @ReturnEN String » Corresponding string
 */
function date2Str(adDatevalue, aeLanguageFormat)
{
   if (aeLanguageFormat == "FR")
   {
      return (new String (
            (adDatevalue.getDate() < 10 ? "0" : "")+adDatevalue.getDate()+
            "/"+
            ((adDatevalue.getMonth()+1) < 10 ? "0" : "")+(adDatevalue.getMonth()+1)+
            "/"+
            adDatevalue.getFullYear()));
   }
   else
   {
      return (new String (
            ((adDatevalue.getMonth()+1) < 10 ? "0" : "")+(adDatevalue.getMonth()+1)+
            "/"+
            (adDatevalue.getDate() < 10 ? "0" : "")+adDatevalue.getDate()+
            "/"+
            adDatevalue.getFullYear()));
   }
}

/**
 * @FunctionFR time2Str » Transforme une date en une chaîne pour l'heure et la retourne
 * @FunctionEN time2Str » Transform a date into a string  for the time and return it
 * @ParamFR adDateValue Date / » Date javascript
 * @ParamEN adDateValue Date / » Javascript date
 * @ParamFR aeLanguageFormat Enum / » Langage de la date (FR = JJ/MM/AAAA, EN = MM/JJ/AAAA)
 * @ParamEN aeLanguageFormat Enum / » Language of the date (FR = DD/MM/YYYY, EN = MM/DD/YYYY)
 * @ReturnFR String » Chaîne correspondante
 * @ReturnEN String » Corresponding string
 */
function time2Str(adDatevalue, aeLanguageFormat)
{
   if (aeLanguageFormat == "FR")
   {
      return (new String (
            (adDatevalue.getHours() < 10 ? "0" : "")+adDatevalue.getHours()+
            ":"+
            (adDatevalue.getMinutes() < 10 ? "0" : "")+adDatevalue.getMinutes()+
            ":"+
            (adDatevalue.getSeconds() < 10 ? "0" : "")+adDatevalue.getSeconds()));
   }
   else
   {
      var hour = adDatevalue.getHours();
      var hoursFormat = "";
      if (adDatevalue.getHours() == 0)
      {
         hour = "12";
         hoursFormat = " P.M.";
      }
      else if (adDatevalue.getHours() < 13)
      {
         hoursFormat = " A.M.";
      }
      else if (adDatevalue.getHours() > 12)
      {
         hour = hour - 12;
         hoursFormat = " P.M.";
      }
      return (new String (
            (hour < 10 ? "0" : "")+hour+
            ":"+
            (adDatevalue.getMinutes() < 10 ? "0" : "")+adDatevalue.getMinutes()+
            ":"+
            (adDatevalue.getSeconds() < 10 ? "0" : "")+adDatevalue.getSeconds()+hoursFormat));
   }
}

/**
 * @FunctionFR dateTime2Str » Transforme une date en une chaîne pour la date et l'heure et la retourne
 * @FunctionEN dateTime2Str » Transform a date into a string  for the date and the time and return it
 * @ParamFR adDateValue Date / » Date javascript
 * @ParamEN adDateValue Date / » Javascript date
 * @ParamFR aeLanguageFormat Enum / » Langage de la date (FR = JJ/MM/AAAA HH:MI:SS, EN = MM/JJ/AAAA HH:MI:SS AM/PM)
 * @ParamEN aeLanguageFormat Enum / » Language of the date (FR = DD/MM/YYYY HH:MI:SS, EN = MM/DD/YYYY HH:MI:SS AM/PM)
 * @ReturnFR String » Chaîne correspondante
 * @ReturnEN String » Corresponding string
 */
function dateTime2Str(adDatevalue, aeLanguageFormat)
{
   return (new String (date2Str(adDatevalue, aeLanguageFormat)+" "+time2Str(adDatevalue, aeLanguageFormat)));
}

/**
 * @FunctionFR getDatetime » Appelle les fonctions qui transforment une date en une chaîne et la retourne
 * @FunctionEN getDatetime » Call the functions which transform a date into a string and return it
 * @ParamFR adDateValue Date / » Date javascript
 * @ParamEN adDateValue Date / » Javascript date
 * @ParamFR aeDateFormat Enum / » Format de la date (D = JJ/MM/AAAA, T = JJ/MM/AAAA HH:MI:SS)
 * @ParamEN aeDateFormat Enum / » Format of the date (D = DD/MM/YYYY, T = DD/MM/YYYY HH:MI:SS)
 * @ParamFR aeLanguageFormat Enum / » Langage de la date (FR = JJ/MM/AAAA HH:MI:SS, EN = MM/JJ/AAAA HH:MI:SS a.m./p.m.)
 * @ParamEN aeLanguageFormat Enum / » Language of the date (FR = DD/MM/YYYY HH:MI:SS, EN = MM/DD/YYYY HH:MI:SS a.m./p.m.)
 * @ReturnFR String » Chaîne correspondante
 * @ReturnEN String » Corresponding string
 */
function getDatetime(adDatevalue, aeDateFormat, aeLanguageFormat)
{
    if (aeDateFormat == 'T')
    {
       return dateTime2Str(adDatevalue, aeLanguageFormat);
    }
    if (aeDateFormat == 'D')
    {
       return date2Str(adDatevalue, aeLanguageFormat);
    }
}
