// -------------------------------------------------------------------------
//  Gestion formulaire
//  PREFIXE : fexe0
// -------------------------------------------------------------------------

var shr_fexe0_gintSubmitCount = 0; // Compteur de validation formulaire

// Affichage des erreurs
var shr_fexe0_gobjFormErrorTip = null; // Objet tooltip
var shr_fexe0_gintDisplayErrorTimeoutID = null;
var shr_fexe0_gintClearErrorTimeoutID = null;
var shr_fexe0_gintErrorTipClientY = -1;
var shr_fexe0_gintErrorTipClientX = -1;
var shr_fexe0_gblnIsStopConfirm = false;

// -------------------------------------------------------------------------
//  Positionne le focus avant de débuter la saisie du formulaire.
// -------------------------------------------------------------------------

function shr_fexe0_SetBeginFocus(pstrFormName)
{
 var lobjForm = window.document.forms[pstrFormName];
 var lintI;
 var lintIMax;

 // Pour chaque element du formulaire
 for (lintI=0,lintIMax=lobjForm.elements.length ; lintI<lintIMax ; lintI++)
    {
     with (lobjForm.elements[lintI])
         {
          // Focus uniquement pour les zones textes modifiables (hors zones numeriques alignees a droite)
          if (  (disabled)
              ||(  (typeof readOnly != 'undefined')
                 &&(readOnly) )
              ||(type != 'text')
              ||(style.textAlign == 'right') )
            { continue; }

          // Donner le focus a cette zone
          window.onerror=shr_tool0_OnError;
          focus();
          window.onerror='';
          break;
         }
    }
}


// -------------------------------------------------------------------------
//  Constructeur classe clsFormInfo
// -------------------------------------------------------------------------
//  [IN] pstrFormName : Nom du formulaire
// -------------------------------------------------------------------------

function shr_fexe0_gclsFormInfo(pstrFormName)
{
 // Proprietes
 this.strFormName = pstrFormName;
 this.tstrListOptions = new Array();
 this.tclsFields = new Array();
 this.tclsMarkers = new Array();
}


// -------------------------------------------------------------------------
//  Ajout d'un champ.
// -------------------------------------------------------------------------

shr_fexe0_gclsFormInfo.prototype.AddField = function (pclsFormInfoField)
{
 this.tclsFields[pclsFormInfoField.objField.name] = pclsFormInfoField;
}


// -------------------------------------------------------------------------
//  Ajout d'un marker.
// -------------------------------------------------------------------------

shr_fexe0_gclsFormInfo.prototype.AddMarker = function (pclsFormInfoMarker)
{
 this.tclsMarkers[pclsFormInfoMarker.objField.name] = pclsFormInfoMarker;
}


// -------------------------------------------------------------------------
//  Validation du formulaire (partie dynamique).
// -------------------------------------------------------------------------
//  [RETURN] True/False, false pour interrompre la validation du formulaire.
// -------------------------------------------------------------------------

shr_fexe0_gclsFormInfo.prototype.OnSubmitBuild = function ()
{ return(true); }


// -------------------------------------------------------------------------
//  Validation du formulaire.
// -------------------------------------------------------------------------
//  [RETURN] True/False, false pour interrompre la validation du formulaire.
// -------------------------------------------------------------------------

shr_fexe0_gclsFormInfo.prototype.OnSubmit = function ()
{
 // Une seule validation de formulaire a la fois !
 if (shr_fexe0_gintSubmitCount != 0)
   { return(false); }

 // Bloquer la validation des autres formulaires
 shr_fexe0_gintSubmitCount++;
 this.SetDisabled(true);

 // Partie specifique au formulaire
 var lblnRC = this.OnSubmitBuild();

 // Abandon de la validation du formulaire
 if (!lblnRC)
   {
    // Autoriser la validation d'un autre formulaire
    shr_fexe0_gintSubmitCount = 0;
    this.SetDisabled(false);
   }

 return(lblnRC);
}


// -------------------------------------------------------------------------
//  Activer/Desactiver les boutons de validation d'un formulaire.
// -------------------------------------------------------------------------
//  [IN] pblnDisabled True pour désactiver, false pour activer.
// -------------------------------------------------------------------------

shr_fexe0_gclsFormInfo.prototype.SetDisabled = function (pblnDisabled)
{
 var lobjForm = window.document.forms[this.strFormName];
 var lintI;
 var lintIMax;

 // Pour chaque element du formulaire
 for (lintI=0,lintIMax=lobjForm.elements.length ; lintI<lintIMax ; lintI++)
    {
     with (lobjForm.elements[lintI])
         {
          if (type == 'submit')
            { disabled=pblnDisabled; }
         }
    }
}


// -------------------------------------------------------------------------
//  Chargement des options d'une combobox ou d'une listbox.
// -------------------------------------------------------------------------
//  [IN] pstrDivID Identifiant container Combobox ou Listbox
//  [IN] pintListOptionsID Identifiant liste des options
//  [IN] pstrValue Valeur sélectionnée
// -------------------------------------------------------------------------

shr_fexe0_gclsFormInfo.prototype.SetListOptions = function (pstrDivID, pintListOptionsID, pstrValue)
{
 var lintI;
 var lintIMax;

 // Recherche container
 var lobjDiv=shr_tool0_GetElementByID(pstrDivID);

 if (lobjDiv == null)
   { return; }

 // Mise en place de la selection
 lobjDiv.innerHTML = lobjDiv.innerHTML.replace(/<\/select>/gi,this.tstrListOptions[pintListOptionsID] + '</select>');

 // Valeur selectionnee ?
 if (  (pstrValue == '')
     ||(pstrValue == '-1') )
   { return; }

 // Recherche de la liste et mise a jour valeur selectionnee
 for (lintI=0,lintIMax=lobjDiv.childNodes.length ; lintI<lintIMax ; lintI++)
    {
     if (lobjDiv.childNodes[lintI].nodeName == 'SELECT')
       {
        lobjDiv.childNodes[lintI].value = pstrValue;
        break;
       }
    }
}


// -------------------------------------------------------------------------
//  Constructeur classe clsMarker
// -------------------------------------------------------------------------
//  [IN] pobjField : Champ
// -------------------------------------------------------------------------

function shr_fexe0_gclsFormInfoMarker(pobjField)
{
 // Proprietes
 this.objField = pobjField;
 this.fntOnMouseOver = null;
 this.fntOnMouseMove = null;
 this.objHTMLMarker = null;
}


// -------------------------------------------------------------------------
//  Constructeur classe clsFormInfoFieldDate
// -------------------------------------------------------------------------
//  [IN] pobjField : Champ date
//  [IN] pobjFieldFormat : Champ format date
//  [IN] pstrImageFormatID : ID image format date
// -------------------------------------------------------------------------

function shr_fexe0_gclsFormInfoFieldDate(pobjField, pobjFieldFormat, pstrImageFormatID)
{
 // Proprietes
 this.objField = pobjField;
 this.objFieldFormat = pobjFieldFormat;
 this.strImageFormatID = pstrImageFormatID;
 this.strRangeLinkFieldName = '';
 this.blnChangeFormatDate = false;
 this.strDayOfDate = 'D';
 this.strFormatDate = 'D';
 this.blnUsedFormatDate = true;
 this.blnUsedFormatMonth = true;
 this.blnUsedFormatWeek = true;
}


// -------------------------------------------------------------------------
//  Changement du format de saisie de la date.
// -------------------------------------------------------------------------

shr_fexe0_gclsFormInfoFieldDate.prototype.ChangeFormatDate = function ()
{
 // Nouveau format date
 switch (this.strFormatDate)
       {
        // Format mois
        case 'M':
            if (this.blnUsedFormatWeek)
              { this.strFormatDate = 'W'; }
            else
              {
               if (this.blnUsedFormatDate)
                 { this.strFormatDate = 'D'; }
              }

            break;

        // Format semaine
        case 'W':
            if (this.blnUsedFormatDate)
              { this.strFormatDate = 'D'; }
            else
              {
               if (this.blnUsedFormatMonth)
                 { this.strFormatDate = 'M'; }
              }

            break;

        // Format date
        default:
            if (this.blnUsedFormatMonth)
              { this.strFormatDate = 'M'; }
            else
              {
               if (this.blnUsedFormatWeek)
                 { this.strFormatDate = 'W'; }
              }

            break;
       }

 // Initialisation
 this.Initialize();
 this.objField.value = '';
 this.objFieldFormat.value = this.strFormatDate + this.strDayOfDate;
}


// -------------------------------------------------------------------------
//  Initialisation d'un champ date.
// -------------------------------------------------------------------------

shr_fexe0_gclsFormInfoFieldDate.prototype.Initialize = function ()
{
 var lstrDateFormatInput;
 var lstrDateFormatImage;

 // Suivant format date
 switch (this.strFormatDate)
       {
        // Format mois
        case 'M':
            // Format
            lstrDateFormatInput = shr_fexe0_gstrDateFormatMonthInput;
            lstrDateFormatInput = lstrDateFormatInput.replace('%m','11');
            lstrDateFormatInput = lstrDateFormatInput.replace('%Y','2222');

            // Tooltip
            this.objField.title = shr_fexe0_gstrDateTitleMonth;

            // Image format
            lstrDateFormatImage = shr_fexe0_gstrDateFormatMonthImage;
            break;

        // Format semaine
        case 'W':
            // Format
            lstrDateFormatInput = shr_fexe0_gstrDateFormatWeekInput;
            lstrDateFormatInput = lstrDateFormatInput.replace('%V','11');
            lstrDateFormatInput = lstrDateFormatInput.replace('%Y','2222');

            // Tooltip
            this.objField.title = shr_fexe0_gstrDateTitleWeek;

            // Image format
            lstrDateFormatImage = shr_fexe0_gstrDateFormatWeekImage;
            break;

        // Format date
        default:
            // Format
            lstrDateFormatInput = shr_fexe0_gstrDateFormatDateInput;
            lstrDateFormatInput = lstrDateFormatInput.replace('%d','00');
            lstrDateFormatInput = lstrDateFormatInput.replace('%m','11');
            lstrDateFormatInput = lstrDateFormatInput.replace('%Y','2222');

            // Tooltip
            this.objField.title = shr_fexe0_gstrDateTitleDate;

            // Image format
            lstrDateFormatImage = shr_fexe0_gstrDateFormatDateImage;
            break;
       }

 // Modification de l'image format
 var lobjImageFormat = shr_tool0_GetElementByID(this.strImageFormatID);

 if (lobjImageFormat != null)
   { lobjImageFormat.src = lstrDateFormatImage; }

 // Longueur de la zone de saisie
 this.objField.size = lstrDateFormatInput.length;
 this.objField.maxLength = lstrDateFormatInput.length;
}


// -------------------------------------------------------------------------
//  Activer/Desactiver un element du formulaire.
// -------------------------------------------------------------------------
//  [IN] pblnFormElem Element du formulaire.
//  [IN] pblnDisabled True pour désactiver, false pour activer.
// -------------------------------------------------------------------------

function shr_fexe0_SetElementDisabled(pobjFormElem, pblnDisabled)
{
 // Suivant le type d'element
 if (  (pobjFormElem.type == 'password')
     ||(pobjFormElem.type == 'text')
     ||(pobjFormElem.type == 'textarea') )
  { pobjFormElem.readOnly = pblnDisabled; }
 else
  { pobjFormElem.disabled = pblnDisabled; }

 // Style
 if (  (pobjFormElem.type != 'checkbox')
     &&(pobjFormElem.type != 'radio') )
   {
    if (pblnDisabled)
      { pobjFormElem.className = 'cssSFormInputReadOnly'; }
    else
      { pobjFormElem.className = 'cssSFormInput'; }
   }
}


// -------------------------------------------------------------------------
//  Modifier l'URL de validation du formulaire
// -------------------------------------------------------------------------
//  [IN] pobjForm       Formulaire
//  [IN] pstrFormAction URL de validation du formulaire
// -------------------------------------------------------------------------

function shr_fexe0_SetFormAction(pobjForm, pstrFormAction)
{
 if (typeof pobjForm.strFormAction != 'undefined')
   { pobjForm.strFormAction.value = pstrFormAction; }
 else
   { pobjForm.action = pstrFormAction; }
}


// -------------------------------------------------------------------------
//  Obtenir l'URL de validation du formulaire
// -------------------------------------------------------------------------
//  [IN] pobjForm Formulaire
//  [RETURN] URL de validation du formulaire
// -------------------------------------------------------------------------

function shr_fexe0_GetFormAction(pobjForm)
{
 if (typeof pobjForm.strFormAction != 'undefined')
   { return(pobjForm.strFormAction.value); }

 return(pobjForm.action);
}


// -------------------------------------------------------------------------
//  Incremente une valeur numerique de 1
//  Formate la valeur suivant le nombre de decimale transmis
//  Utilise le separateur de décimale localise
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
//  [IN] pintDecimalNumber : Nombre de decimales
//  [IN] pblnUnSigned : Non signee si true
//  [IN] pdblInputStep : Pas de saisie ou null
// -------------------------------------------------------------------------

function shr_fexe0_Add(pobjInput,pintDecimalNumber,pblnUnSigned,pdblInputStep)
{
 if (pobjInput.readOnly == false)
   { shr_fexe0_AddToNumeric(pobjInput,pintDecimalNumber,pblnUnSigned,'+',pdblInputStep,1); }
}


// -------------------------------------------------------------------------
//  Decremente une valeur numerique de 1
//  Formate la valeur suivant le nombre de decimale transmis
//  Utilise le separateur de décimale localise
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
//  [IN] pintDecimalNumber : Nombre de decimales
//  [IN] pblnUnSigned : Non signee si true
//  [IN] pdblInputStep : Pas de saisie ou null
// -------------------------------------------------------------------------

function shr_fexe0_Dec(pobjInput,pintDecimalNumber,pblnUnSigned,pdblInputStep)
{
 if (pobjInput.readOnly == false)
   { shr_fexe0_AddToNumeric(pobjInput,pintDecimalNumber,pblnUnSigned,'-',pdblInputStep,-1); }
}


// -------------------------------------------------------------------------
//  Force a une valeur numerique
//  Formate la valeur suivant le nombre de decimale transmis
//  Utilise le separateur de décimale localise
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
//  [IN] pdblMinValue : Valeur minimale ou null
//  [IN] pdblMaxValue : Valeur maximale ou null
//  [IN] pobjInput : Objet input
//  [IN] pintDecimalNumber : Nombre de decimales
//  [IN] pblnUnSigned : Non signee si true
//  [IN] pdblInputStep : Pas de saisie ou null
// -------------------------------------------------------------------------

function shr_fexe0_ToNumeric(pobjInput,pdblMinValue,pdblMaxValue,pintDecimalNumber,pblnUnSigned,pdblInputStep)
{
 if (typeof pobjInput == 'undefined')
   { return; }

 shr_fexe0_AddToNumeric(pobjInput,pintDecimalNumber,pblnUnSigned,'+',pdblInputStep,0);

 // Valeur minimale/maximale/pas de saisie ?
 if (  (pdblMinValue == null)
     &&(pdblMaxValue == null) )
   { return; }

 var lobjValue = pobjInput.value;

 // . Comme separateur de decimales
 lobjValue = lobjValue.replace(shr_fexe0_gstrDecimalPoint,'.');

 // Valeur numerique
 lobjValue = parseFloat(lobjValue);

 // Depassement valeur minimale
 if (  (pdblMinValue != null)
     &&(lobjValue < pdblMinValue) )
   {
    // Force zone à la valeur minimale
    pobjInput.value = pdblMinValue.toString(10);

	// Mise au format localise
	shr_fexe0_AddToNumeric(pobjInput,pintDecimalNumber,pblnUnSigned,'+',pdblInputStep,0);
	alert(shr_fexe0_gstrMSGCheckMinValue + pdblMinValue);
	return;
   }

 // Depassement valeur maximale
 if (  (pdblMaxValue != null)
     &&(lobjValue > pdblMaxValue) )
   {
    // Force zone à la valeur maximale
    pobjInput.value = pdblMaxValue.toString(10);

	// Mise au format localise
	shr_fexe0_AddToNumeric(pobjInput,pintDecimalNumber,pblnUnSigned,'-',pdblInputStep,0);
	alert(shr_fexe0_gstrMSGCheckMaxValue + pdblMaxValue);
	return;
   }
}


// -------------------------------------------------------------------------
//  Ajoute une valeur additionnelle à une valeur numérique
//  Force a une valeur numerique
//  Formate la valeur suivant le nombre de decimale transmis
//  Utilise le separateur de décimale localise
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
//  [IN] pintDecimalNumber : Nombre de decimales
//  [IN] pblnUnSigned : Non signee si true
//  [IN] pstrStepSens : +,- Arrondi inferieur/superieur suivant le pas de saisie
//  [IN] pdblInputStep : Pas de saisie ou null
//  [IN] pintValueAdd : Valeur additionnelle
// -------------------------------------------------------------------------

function shr_fexe0_AddToNumeric(pobjInput,pintDecimalNumber,pblnUnSigned,pstrStepSens,pdblInputStep,pintValueAdd)
{
 var lobjValue;
 var lobjStepValue;
 var lintVirgule;
 var lintPosDecimal;
 var lintLength;

 lobjValue = pobjInput.value;

 // Supprimer le signe -
 if (pblnUnSigned == true)
   { lobjValue = lobjValue.replace(/-/g,''); }

 // Supprimer les espaces
 lobjValue = lobjValue.replace(/\s/g,'');

 // . Comme separateur de decimales
 lobjValue = lobjValue.replace(',','.');
 lobjValue = lobjValue.replace(shr_fexe0_gstrDecimalPoint,'.');

 // Valeur numerique
 lobjValue = parseFloat(lobjValue);

 // Force a une valeur numerique
 if (isNaN(lobjValue))
   { lobjValue = 1; }

 // Ajoute valeur additionnelle
 lobjValue = lobjValue + pintValueAdd;

 // Valeur non signée ?
 if (  (pblnUnSigned)
     &&(lobjValue < 0) )
   { lobjValue = 0; }

 // Pas de saisie
 if (  (pdblInputStep != null)
     &&(pdblInputStep != 0.0) )
   {
    lobjStepValue = (Math.floor(lobjValue/pdblInputStep))*pdblInputStep;

    if (  (pstrStepSens == '+')
        &&(lobjStepValue < lobjValue) )
      { lobjValue = lobjStepValue + pdblInputStep; }
    else
      { lobjValue = lobjStepValue; }
   }

 // Nombre de decimal fixe ?
 if (pintDecimalNumber != -1)
   {
    // Arrondi suivant nombre de decimales
    lintVirgule = Math.pow(10,pintDecimalNumber);
    lobjValue = (Math.round(lobjValue*lintVirgule))/lintVirgule;
    lobjValue = lobjValue.toString(10);

    if (pintDecimalNumber > 0)
      {
       // Position separateur de decimale
       lintPosDecimal = lobjValue.search(/\./i);

	   // Longueur  = Longueur partie entiere + Separateur de decimale + longueur partie decimale
	   if (lintPosDecimal > 0)
	     { lintLength = lintPosDecimal + 1 + pintDecimalNumber; }
	   else
	     { lintLength = lobjValue.length + 1 + pintDecimalNumber; }

	   // Complement partie decimale
	   if (lintPosDecimal == -1)
	     { lobjValue += '.0000000000'; }
	   else
	     { lobjValue += '0000000000'; }

       // Longueur finale
       lobjValue = lobjValue.substr(0,lintLength);

	   // Separateur de decimal localise
       lobjValue = lobjValue.replace('.',shr_fexe0_gstrDecimalPoint);
      }
   }

 pobjInput.value = lobjValue;
}


// -------------------------------------------------------------------------
//  Formate une heure au format localise
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
//  [IN] pstrFormatInput : Format d'entrée
// -------------------------------------------------------------------------

function shr_fexe0_ToTime(pobjInput, pstrFormatInput)
{
 var lobjValue;
 var lstrHour;
 var lstrMinute;
 var lstrSecond;
 var lintPosHour;
 var lintPosMinute;
 var lintPosSecond;
 var lstrTimeFormatInput;

 if (typeof pobjInput == 'undefined')
   { return; }

 lobjValue = pobjInput.value;

 // Chaine vide
 if (lobjValue.length == 0)
   { return; }

 // Supprimer les caracteres non numeriques
 lobjValue = lobjValue.replace(/\D/g,'');

 // Complete par des 0
 lobjValue = lobjValue + '000000';

 // Preparation format (sans separateur)
 lstrTimeFormatInput = pstrFormatInput;
 lstrTimeFormatInput = lstrTimeFormatInput.replace('%H', '00');
 lstrTimeFormatInput = lstrTimeFormatInput.replace('%M', '11');
 lstrTimeFormatInput = lstrTimeFormatInput.replace('%S', '22');
 lstrTimeFormatInput = lstrTimeFormatInput.replace(/\D/g, '');

 // Positions
 lintPosHour = lstrTimeFormatInput.search('00')
 lintPosMinute = lstrTimeFormatInput.search('11')
 lintPosSecond = lstrTimeFormatInput.search('22')

 // Mise au format localise
 lstrHour = lobjValue.substr(lintPosHour, 2);
 lstrMinute = lobjValue.substr(lintPosMinute, 2);

 if (lintPosSecond != -1)
   { lstrSecond = lobjValue.substr(lintPosSecond, 2); }

 lobjValue = pstrFormatInput;
 lobjValue = lobjValue.replace('%H', lstrHour);
 lobjValue = lobjValue.replace('%M', lstrMinute);

 if (lintPosSecond != -1)
   { lobjValue = lobjValue.replace('%S', lstrSecond); }

 pobjInput.value = lobjValue;
}


// -------------------------------------------------------------------------
//  Formate une date au format localise
//  Initialisation du siecle si necessaire
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
//  [IN] pclsFormInfo : Objet information complementaire formulaire
// -------------------------------------------------------------------------

function shr_fexe0_ToDate(pobjInput, pclsFormInfo)
{
 var lobjValue;
 var lclsFormInfoFieldDate;

 if (typeof pobjInput == 'undefined')
   { return; }

 lobjValue = pobjInput.value;

 // Chaine vide
 if (lobjValue.length == 0)
   { return; }

 // Objet champ de type date
 lclsFormInfoFieldDate = pclsFormInfo.tclsFields[pobjInput.name];

 // Supprimer les caracteres non numeriques
 lobjValue = lobjValue.replace(/\D/g,'');

 // Format date
 switch (lclsFormInfoFieldDate.strFormatDate)
       {
        // Format mois
        case 'M':
                 lobjValue = shr_fexe0_ToDateFormatMonth(lobjValue);
                 break;

        // Format semaine
        case 'W':
                 lobjValue = shr_fexe0_ToDateFormatWeek(lobjValue);
                 break;

        // Format date
        default:
                 lobjValue = shr_fexe0_ToDateFormatDate(lobjValue);
                 break;
       }

 pobjInput.value = lobjValue;
}


// -------------------------------------------------------------------------
//  Formate une date au format date localise
//  Initialisation du siecle si necessaire
// -------------------------------------------------------------------------
//  [IN] pobjValue : Objet valeur date
//  [RETURN] Objet valeur date au format date
// -------------------------------------------------------------------------

function shr_fexe0_ToDateFormatDate(pobjValue)
{
 var lobjValue;
 var lstrYear;
 var lstrMonth;
 var lstrDay;
 var lintPosYear;
 var lintPosMonth;
 var lintPosDay;
 var lstrDateFormatDateInput;

 lobjValue = pobjValue;

 // Preparation format (sans separateur, annee sur 2)
 lstrDateFormatDateInput = shr_fexe0_gstrDateFormatDateInput;
 lstrDateFormatDateInput = lstrDateFormatDateInput.replace('%d','00');
 lstrDateFormatDateInput = lstrDateFormatDateInput.replace('%m','11');
 lstrDateFormatDateInput = lstrDateFormatDateInput.replace('%Y','22');
 lstrDateFormatDateInput = lstrDateFormatDateInput.replace(/\D/g,'');

 // Date saisie au format court
 if (lobjValue.length == lstrDateFormatDateInput.length)
   {
    // Positions
    lintPosYear = lstrDateFormatDateInput.search('22')
    lintPosMonth = lstrDateFormatDateInput.search('11')
    lintPosDay = lstrDateFormatDateInput.search('00')

    // Annee au format long, mois, jour
    lstrYear = shr_fexe0_GetLongYear(lobjValue.substr(lintPosYear,2));
	lstrMonth = lobjValue.substr(lintPosMonth,2);
	lstrDay = lobjValue.substr(lintPosDay,2);
   }
 else
   {
    // Complete par des 0
    lobjValue = lobjValue + '00000000';

    // Preparation format (sans separateur, annee sur 4)
    lstrDateFormatDateInput = shr_fexe0_gstrDateFormatDateInput;
    lstrDateFormatDateInput = lstrDateFormatDateInput.replace('%d','00');
    lstrDateFormatDateInput = lstrDateFormatDateInput.replace('%m','11');
    lstrDateFormatDateInput = lstrDateFormatDateInput.replace('%Y','2222');
    lstrDateFormatDateInput = lstrDateFormatDateInput.replace(/\D/g,'');

    // Positions
    lintPosYear = lstrDateFormatDateInput.search('2222')
    lintPosMonth = lstrDateFormatDateInput.search('11')
    lintPosDay = lstrDateFormatDateInput.search('00')

    // Annee, mois, jour
	lstrYear = lobjValue.substr(lintPosYear,4);
	lstrMonth = lobjValue.substr(lintPosMonth,2);
	lstrDay = lobjValue.substr(lintPosDay,2);
   }

 // Mise au format localise
 lobjValue = shr_fexe0_gstrDateFormatDateInput;
 lobjValue = lobjValue.replace('%d',lstrDay);
 lobjValue = lobjValue.replace('%m',lstrMonth);
 lobjValue = lobjValue.replace('%Y',lstrYear);

 return(lobjValue);
}


// -------------------------------------------------------------------------
//  Formate une date au format mois
//  Initialisation du siecle si necessaire
// -------------------------------------------------------------------------
//  [IN] pobjValue : Objet valeur date
//  [RETURN] Objet valeur date au format mois
// -------------------------------------------------------------------------

function shr_fexe0_ToDateFormatMonth(pobjValue)
{
 var lobjValue;
 var lstrYear;
 var lstrMonth;
 var lintPosYear;
 var lintPosMonth;
 var lstrDateFormatMonthInput;

 lobjValue = pobjValue;

 // Preparation format (sans separateur, annee sur 2)
 lstrDateFormatMonthInput = shr_fexe0_gstrDateFormatMonthInput;
 lstrDateFormatMonthInput = lstrDateFormatMonthInput.replace('%m','11');
 lstrDateFormatMonthInput = lstrDateFormatMonthInput.replace('%Y','22');
 lstrDateFormatMonthInput = lstrDateFormatMonthInput.replace(/\D/g,'');

 // Date saisie au format court
 if (lobjValue.length == lstrDateFormatMonthInput.length)
   {
    // Positions
    lintPosYear = lstrDateFormatMonthInput.search('22')
    lintPosMonth = lstrDateFormatMonthInput.search('11')

    // Annee au format long, mois
    lstrYear = shr_fexe0_GetLongYear(lobjValue.substr(lintPosYear,2));
	lstrMonth = lobjValue.substr(lintPosMonth,2);
   }
 else
   {
    // Complete par des 0
    lobjValue = lobjValue + '000000';

    // Preparation format (sans separateur, annee sur 4)
    lstrDateFormatMonthInput = shr_fexe0_gstrDateFormatMonthInput;
    lstrDateFormatMonthInput = lstrDateFormatMonthInput.replace('%m','11');
    lstrDateFormatMonthInput = lstrDateFormatMonthInput.replace('%Y','2222');
    lstrDateFormatMonthInput = lstrDateFormatMonthInput.replace(/\D/g,'');

    // Positions
    lintPosYear = lstrDateFormatMonthInput.search('2222')
    lintPosMonth = lstrDateFormatMonthInput.search('11')

    // Annee, mois
	lstrYear = lobjValue.substr(lintPosYear,4);
	lstrMonth = lobjValue.substr(lintPosMonth,2);
   }

 // Mise au format localise
 lobjValue = shr_fexe0_gstrDateFormatMonthInput;
 lobjValue = lobjValue.replace('%m',lstrMonth);
 lobjValue = lobjValue.replace('%Y',lstrYear);

 return(lobjValue);
}


// -------------------------------------------------------------------------
//  Formate une date au format semaine
//  Initialisation du siecle si necessaire
// -------------------------------------------------------------------------
//  [IN] pobjValue : Objet valeur date
//  [RETURN] Objet valeur date au format semaine
// -------------------------------------------------------------------------

function shr_fexe0_ToDateFormatWeek(pobjValue)
{
 var lobjValue;
 var lstrYear;
 var lstrWeek;
 var lintPosYear;
 var lintPosWeek;
 var lstrDateFormatWeekInput;

 lobjValue = pobjValue;

 // Preparation format (sans separateur, annee sur 2)
 lstrDateFormatWeekInput = shr_fexe0_gstrDateFormatWeekInput;
 lstrDateFormatWeekInput = lstrDateFormatWeekInput.replace('%V','11');
 lstrDateFormatWeekInput = lstrDateFormatWeekInput.replace('%Y','22');
 lstrDateFormatWeekInput = lstrDateFormatWeekInput.replace(/\D/g,'');

 // Date saisie au format court
 if (lobjValue.length == lstrDateFormatWeekInput.length)
   {
    // Positions
    lintPosYear = lstrDateFormatWeekInput.search('22')
    lintPosWeek = lstrDateFormatWeekInput.search('11')

    // Annee au format long, semaine
    lstrYear = shr_fexe0_GetLongYear(lobjValue.substr(lintPosYear,2));
	lstrWeek = lobjValue.substr(lintPosWeek,2);
   }
 else
   {
    // Complete par des 0
    lobjValue = lobjValue + '000000';

    // Preparation format (sans separateur, annee sur 4)
    lstrDateFormatWeekInput = shr_fexe0_gstrDateFormatWeekInput;
    lstrDateFormatWeekInput = lstrDateFormatWeekInput.replace('%V','11');
    lstrDateFormatWeekInput = lstrDateFormatWeekInput.replace('%Y','2222');
    lstrDateFormatWeekInput = lstrDateFormatWeekInput.replace(/\D/g,'');

    // Positions
    lintPosYear = lstrDateFormatWeekInput.search('2222')
    lintPosWeek = lstrDateFormatWeekInput.search('11')

    // Annee, mois
	lstrYear = lobjValue.substr(lintPosYear,4);
	lstrWeek = lobjValue.substr(lintPosWeek,2);
   }

 // Forcer saisie numero de semaine
 if (parseInt(lstrWeek,10) < 1)
   { lstrWeek = '01'; }
 else
   {
    var lintWeekYear = shr_fexe0_GetWeekYear(parseInt(lstrYear,10));

    if (parseInt(lstrWeek,10) > lintWeekYear)
      { lstrWeek = lintWeekYear.toString(10); }
   }

 // Mise au format localise
 lobjValue = shr_fexe0_gstrDateFormatWeekInput;
 lobjValue = lobjValue.replace('%V',lstrWeek);
 lobjValue = lobjValue.replace('%Y',lstrYear);

 return(lobjValue);
}


// -------------------------------------------------------------------------
//  Change le format de saise de la date
// -------------------------------------------------------------------------
//  [IN] pstrInputName : Nom du champ date
//  [IN] pclsFormInfo : Objet information complementaire formulaire
// -------------------------------------------------------------------------

function shr_fexe0_ChangeFormatDate(pstrInputName, pclsFormInfo)
{
 // Change le format date
 var lclsFormInfoFieldDate1 = pclsFormInfo.tclsFields[pstrInputName];
 lclsFormInfoFieldDate1.ChangeFormatDate();

 // Change le format date de la borne oppose (cas des fourchettes de date)
 if (lclsFormInfoFieldDate1.strRangeLinkFieldName != '')
   {
    var lclsFormInfoFieldDate2 = pclsFormInfo.tclsFields[lclsFormInfoFieldDate1.strRangeLinkFieldName];
    lclsFormInfoFieldDate2.ChangeFormatDate();
   }
}


// -------------------------------------------------------------------------
//  Nombre de semaine dans l'année.
// -------------------------------------------------------------------------
//  [IN] pintYear : Année
//  [RETURN] Nombre de semaine (53 ou 52)
// -------------------------------------------------------------------------

function shr_fexe0_GetWeekYear(pintYear)
{
 // Premier et dernier jour de l'annee
 var lobjYearFirstDay = new Date(pintYear,  0, 1);
 var lobjYearLastDay  = new Date(pintYear, 11, 31);

 // Nombre de jour dans l'annee
 var lintYearDayCount = parseInt((lobjYearLastDay - lobjYearFirstDay) / (60 * 60 * 24 * 1000) + 1, 10);

 if (  (lobjYearFirstDay.getDay() == 4)
     ||(  (lobjYearFirstDay.getDay() == 3)
        &&(lintYearDayCount == 366) ) )
   { return(53) ; }

 return(52);
}


// -------------------------------------------------------------------------
//  Retourne une année sur 4 chiffres à partir d'une année sur 2 chiffres.
// -------------------------------------------------------------------------
//  [IN] pstrYear : Année sur 2 chiffres
//  [RETURN] Année sur 4 chiffres
// -------------------------------------------------------------------------

function shr_fexe0_GetLongYear(pstrYear)
{
 var lstrYear;

 // Determine le siecle
 if (pstrYear >= '30')
   { lstrYear = '19'; }
 else
   { lstrYear = '20'; }

 // Annee au format long SSAA
 lstrYear += pstrYear;

 return(lstrYear);
}


// -------------------------------------------------------------------------
//  Majusculisation de la valeur d'une zone de saisie
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
// -------------------------------------------------------------------------

function shr_fexe0_ToUpper(pobjInput)
{
 if (typeof pobjInput == 'undefined')
   { return; }

 pobjInput.value = pobjInput.value.toUpperCase();
}


// -------------------------------------------------------------------------
//  Formate une couleur au format #RRGGBB
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
// -------------------------------------------------------------------------

function shr_fexe0_ToRGBColor(pobjInput)
{
 var lobjValue;

 if (typeof pobjInput == 'undefined')
   { return; }

 lobjValue = pobjInput.value;

 // Chaine vide
 if (lobjValue.length == 0)
   { return; }

 // Majusculisation
 lobjValue = lobjValue.toUpperCase();

 // Supprimer caracteres non hexadecimales
 lobjValue = lobjValue.replace(/[^A-F0-9]/g,'');

 // Mise au format apres complement a 0 a droite
 lobjValue = lobjValue.substr(0,6) + '000000';
 lobjValue = '#' + lobjValue.substr(0,6);

 pobjInput.value = lobjValue;
}


// -------------------------------------------------------------------------
//  Formate une couleur au format CIP (couleur physique d'interface)
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
// -------------------------------------------------------------------------

function shr_fexe0_ToCIPColor(pobjInput)
{
 var lobjValue;

 if (typeof pobjInput == 'undefined')
   { return; }

 lobjValue = pobjInput.value;

 // Chaine vide
 if (lobjValue.length == 0)
   { return; }

 // Majusculisation
 lobjValue = lobjValue.toUpperCase();

 // Remplacer espaces par underscore
 lobjValue = lobjValue.replace(/\s+/g,'_');

 // Supprimer caracteres non autorises
 lobjValue = lobjValue.replace(/[^A-Z0-9_]/g,'');

 // Supprimer caracteres non autorises (Premier caractere)
 lobjValue = lobjValue.replace(/^[0-9_]/g,'');

 pobjInput.value = lobjValue;
}


// -------------------------------------------------------------------------
//  Formate l'identifiant d'un style
// -------------------------------------------------------------------------
//  [IN] pobjInput : Objet input
// -------------------------------------------------------------------------

function shr_fexe0_ToStyle(pobjInput)
{
 var lobjValue;

 if (typeof pobjInput == 'undefined')
   { return; }

 lobjValue = pobjInput.value;

 // Chaine vide
 if (lobjValue.length == 0)
   { return; }

 // Remplacer espaces par underscore
 lobjValue = lobjValue.replace(/\s+/g,'_');

 // Supprimer caracteres non autorises
 lobjValue = lobjValue.replace(/[^A-Za-z0-9_]/g,'');

 // Supprimer caracteres non autorises (Premier caractere)
 lobjValue = lobjValue.replace(/^[0-9_]/g,'');

 pobjInput.value = lobjValue;
}


// -------------------------------------------------------------------------
//  Formate un nom de fichier
// -------------------------------------------------------------------------
//  [IN] pobjInput   : Objet input
//  [IN] pstrPrefixe : Prefixe obligatoire pour le nom de fichier
//  [IN] pstrSuffixe : Suffixe obligatoire pour le nom de fichier
//  [IN] pstrExtend  : Extension
// -------------------------------------------------------------------------

function shr_fexe0_ToFileName(pobjInput, pstrPrefixe, pstrSuffixe, pstrExtend)
{
 var lobjValue;
 var lstrExtend;
 var ltstrFileName;

 if (typeof pobjInput == 'undefined')
   { return; }

 lobjValue = pobjInput.value;

 // Chaine vide
 if (lobjValue.length == 0)
   { return; }

 // Supprimer caracteres non autorises
 lobjValue = lobjValue.replace(/[^A-Za-z0-9.]/g,'');

 // Supprimer l'extension
 ltstrFileName = lobjValue.split('.');
 lobjValue = ltstrFileName[0];

 if (pstrExtend.length > 0)
   { lstrExtend = pstrExtend; }
 else if (ltstrFileName[1] != null)
   { lstrExtend = ltstrFileName[1]; }
 else
   { lstrExtend = ''; }

 // Ajouter prefixe si necessaire
 if (  (pstrPrefixe.length > 0)
     &&(lobjValue.substr(0,pstrPrefixe.length) != pstrPrefixe) )
   { lobjValue = pstrPrefixe + lobjValue; }

 // Ajouter suffixe si necessaire
 if (  (pstrSuffixe.length > 0)
     &&(  (lobjValue.length < pstrSuffixe.length)
        ||(lobjValue.substr(lobjValue.length - pstrSuffixe.length, pstrSuffixe.length) != pstrSuffixe) ) )
   { lobjValue = lobjValue + pstrSuffixe; }

 // Extension
 if (lstrExtend != '')
   { lobjValue = lobjValue + '.' + lstrExtend; }

 // Majusculiser le premier caractere suivant le prefixe
 lobjValue = lobjValue.substr(0,pstrPrefixe.length) + lobjValue.substr(pstrPrefixe.length,1).toUpperCase() + lobjValue.substr(pstrPrefixe.length+1,lobjValue.length-pstrPrefixe.length+1);

 pobjInput.value = lobjValue;
}


// -------------------------------------------------------------------------
//  Attache le gestionnaire d'erreur a une zone de saisie.
// -------------------------------------------------------------------------
//  [IN] pstrErrorText : Texte de l'erreur
//  [IN] pobjInput : Zone de saisie
// -------------------------------------------------------------------------

function shr_fexe0_SetErrorManager(pstrErrorText, pobjInput)
{
 var lobjFormInfo = eval(pobjInput.form.name + 'FormInfo');

 if (lobjFormInfo.tclsMarkers[pobjInput.name] != null)
   { shr_fexe0_UnsetErrorManager(pobjInput); }

 var lobjFormInfoMarker = new shr_fexe0_gclsFormInfoMarker(pobjInput);

 lobjFormInfoMarker.fntOnMouseOver = function (pobjEvent) { shr_fexe0_DisplayError(pstrErrorText, pobjInput, pobjEvent); };
 lobjFormInfoMarker.fntOnMouseMove = function (pobjEvent) { shr_fexe0_ManageErrorTipTimeout(pobjInput, pobjEvent); };

 shr_tool0_AttachEvent(pobjInput, 'mouseover', lobjFormInfoMarker.fntOnMouseOver);
 shr_tool0_AttachEvent(pobjInput, 'mousemove', lobjFormInfoMarker.fntOnMouseMove);

 // Ajout de l'indicateur d'erreur
 var lobjHTMLMarker = window.document.createElement('span');
 lobjHTMLMarker.className = 'cssFFormErrorMarkup';
 lobjHTMLMarker.innerHTML = '*';
 pobjInput.parentNode.whiteSpace = 'nowrap';
 lobjFormInfoMarker.objHTMLMarker = pobjInput.parentNode.appendChild(lobjHTMLMarker);

 lobjFormInfo.AddMarker(lobjFormInfoMarker);
}


// -------------------------------------------------------------------------
//  Détache le gestionnaire d'erreur d'une zone de saisie.
// -------------------------------------------------------------------------
//  [IN] pobjInput : Zone de saisie
// -------------------------------------------------------------------------

function shr_fexe0_UnsetErrorManager(pobjInput)
{
 var lobjFormInfo = eval(pobjInput.form.name + 'FormInfo');

 if (lobjFormInfo.tclsMarkers[pobjInput.name] == null)
   { return; }

 var lobjFormInfoMarker = lobjFormInfo.tclsMarkers[pobjInput.name];

 shr_tool0_DetachEvent(pobjInput, 'mouseover', lobjFormInfoMarker.fntOnMouseOver);
 shr_tool0_DetachEvent(pobjInput, 'mousemove', lobjFormInfoMarker.fntOnMouseMove);

 // Suppression de l'indicateur d'erreur
 if (lobjFormInfoMarker.objHTMLMarker != null)
   {
    pobjInput.parentNode.removeChild(lobjFormInfoMarker.objHTMLMarker);
    pobjInput.parentNode.whiteSpace = 'normal';
   }

 // Suppression du marker
 lobjFormInfo.tclsMarkers[pobjInput.name] = null;
}


// -------------------------------------------------------------------------
//  Affichage texte d'erreur
// -------------------------------------------------------------------------
//  [IN] pstrErrorText : Texte de l'erreur
//  [IN] pobjInput : Zone de saisie
//  [IN] pobjEvent : Objet evenement
// -------------------------------------------------------------------------

function shr_fexe0_DisplayError(pstrErrorText, pobjInput, pobjEvent)
{
 if (shr_fexe0_gobjFormErrorTip == null)
   {
    shr_fexe0_gobjFormErrorTip = window.document.createElement('div');
    shr_fexe0_gobjFormErrorTip.className = 'cssFFormErrorTip';
    document.body.appendChild(shr_fexe0_gobjFormErrorTip);
   }

 shr_fexe0_gobjFormErrorTip.innerHTML='<div class="cssSFormErrorText">' + pstrErrorText + '</div>';

 pobjInput.onmouseout = shr_fexe0_HideError;

 // Affichage suivant time out
 shr_fexe0_ManageErrorTipTimeout(pobjInput, pobjEvent);
}


// -------------------------------------------------------------------------
//  Masque le cadre flottant d'affichage des erreurs
// -------------------------------------------------------------------------

function shr_fexe0_HideError()
{
 // Desactiver time out
 if (shr_fexe0_gintDisplayErrorTimeoutID)
   {
    window.clearTimeout(shr_fexe0_gintDisplayErrorTimeoutID);
    shr_fexe0_gintDisplayErrorTimeoutID = null;
   }

 // Effacer
 if (shr_fexe0_gobjFormErrorTip != null)
   { shr_fexe0_gobjFormErrorTip.style.visibility = "hidden"; }
}


// -------------------------------------------------------------------------
//  Gestion time out texte d'erreur
// -------------------------------------------------------------------------
//  [IN] pobjEvent : Objet evenement
// -------------------------------------------------------------------------

function shr_fexe0_ManageErrorTipTimeout(pobjInput, pobjEvent)
{
 if (shr_fexe0_gobjFormErrorTip == null)
   { return; }

 // IE : uniquement si coordonnées souris modifiees
 if (typeof event != 'undefined')
   {
    if (  (event.clientY == shr_fexe0_gintErrorTipClientY)
        &&(event.clientX == shr_fexe0_gintErrorTipClientX) )
      { return; }

    // Memorise coordonnees souris
    shr_fexe0_gintErrorTipClientY = event.clientY;
    shr_fexe0_gintErrorTipClientX = event.clientX;
   }

 // Effacer et desactiver time out
 shr_fexe0_HideError();

 // Position zone de saisie
 var lobjInputPos = shr_tools_GetElementPos(pobjInput)

 if (typeof event != 'undefined')
   {
    // IE : Pas d'affichage si deplacement + bouton enfonce
    if (event.button != 0)
      { return; }

    // Initialisations
    var lintY = event.y + document.body.scrollTop;
    var lintX = event.x + document.body.scrollLeft;
    var lintRightEdge = document.body.clientWidth - event.clientX;
    var lintBottomEdge = document.body.clientHeight - event.clientY;
    var lintInputHeight = pobjInput.clientHeight;
   }
 else
   {
    // GECKO : Coordonnees souris hors zone (sur liste d'une combo ou bouton enfonce)
    if (  (pobjEvent.pageY < lobjInputPos.y)
        ||(pobjEvent.pageY > lobjInputPos.y + pobjInput.innerHeight)
        ||(pobjEvent.pageX < lobjInputPos.x)
        ||(pobjEvent.pageX > lobjInputPos.x + pobjInput.innerWidth) )
      { return; }

    // Initialisations
    var lintY = pobjEvent.pageY;
    var lintX = pobjEvent.pageX;
    var lintRightEdge = window.innerWidth - 20 - pobjEvent.clientX; // 20 : Ascenceur
    var lintBottomEdge = window.innerHeight - 20 - pobjEvent.clientY; // 20 : Ascenceur
    var lintInputHeight = pobjInput.innerHeight;
   }

 // Afficher suivant time out
 shr_fexe0_gintDisplayErrorTimeoutID = window.setTimeout('shr_fexe0_DisplayErrorTip(' + lintY + ',' + lintX + ',' + lintRightEdge + ',' + lintBottomEdge + ',' + lobjInputPos.y + ',' + lintInputHeight + ',\'' + pobjInput.type + '\')',300);
}


// -------------------------------------------------------------------------
//  Positionnement et affichage texte d'erreur dans cadre flottant
// -------------------------------------------------------------------------
//  [IN] pintY : Coordonnees curseur
//  [IN] pintX : Coordonnees curseur
//  [IN] lintRightEdge : Espace affichage a droite
//  [IN] pintBottomEdge : Espace affichage bas
//  [IN] pintInputTop : Position haute zone de saisie
//  [IN] pintInputHeight : Hauteur zone de saisie
//  [IN] pstrInputType : Type de zone
// -------------------------------------------------------------------------

function shr_fexe0_DisplayErrorTip(pintY, pintX, pintRightEdge, pintBottomEdge, pintInputTop, pintInputHeight, pstrInputType)
{
 var lintOffsetDivFromPointerX = 10; // X offset tooltip div
 var lintOffsetDivFromPointerY = 14; // Y offset tooltip div
 var lintTipLeft = 0; // Position gauche tooltip
 var lintTipTop = 0; // Position haute tooltip

  // Positionnement horizontal suivant place disponible
 lintTipLeft = pintX - lintOffsetDivFromPointerX;

 if (shr_fexe0_gobjFormErrorTip.offsetWidth - lintOffsetDivFromPointerX > pintRightEdge)
   { lintTipLeft -= (shr_fexe0_gobjFormErrorTip.offsetWidth - lintOffsetDivFromPointerX - pintRightEdge); }

 if (lintTipLeft < 0)
   { lintTipLeft = 0; }

 // Positionnement vertical suivant place disponible
 if (shr_fexe0_gobjFormErrorTip.offsetHeight + lintOffsetDivFromPointerY > pintBottomEdge)
   { lintTipTop = pintY - shr_fexe0_gobjFormErrorTip.offsetHeight - lintOffsetDivFromPointerY; }
 else
   { lintTipTop = pintY + lintOffsetDivFromPointerY; }

 // IE : Gestion chevauchement avec combobox
 if (  (shr_tool0_gblnIE5)
     ||(shr_tool0_gblnIE6) )
   {
    if (  (pstrInputType == "select-one")
        ||(pstrInputType == "select-multiple") )
      {
       var lintInputTop = pintInputTop;
       var lintInputHeight = pintInputHeight;
      }
    else
      {
       var lintInputTop = pintY - lintOffsetDivFromPointerY;
       var lintInputHeight = lintOffsetDivFromPointerY * 2;
      }

    lintTipTop = shr_fexe0_AdjustErrorTipPosition(pintY, lintInputTop, lintInputHeight, lintTipTop, lintTipLeft, pintBottomEdge);
   }

 // Desactiver time out effacement
 if (shr_fexe0_gintClearErrorTimeoutID)
   {
    window.clearTimeout(shr_fexe0_gintClearErrorTimeoutID);
    shr_fexe0_gintClearErrorTimeoutID = null;
   }

 // Positionnement
 shr_fexe0_gobjFormErrorTip.style.left = lintTipLeft + 'px';
 shr_fexe0_gobjFormErrorTip.style.top = lintTipTop + 'px';
 shr_fexe0_gobjFormErrorTip.style.visibility = "visible";

 // Activer time out effacement
 shr_fexe0_gintClearErrorTimeoutID = window.setTimeout('shr_fexe0_HideError()',10000);
}


// -------------------------------------------------------------------------
//  Afficher/cacher combobox de formulaires
// -------------------------------------------------------------------------
//  Traitement effectue uniquement sous IE
// -------------------------------------------------------------------------
//  [IN] pintY : Coordonnees curseur
//  [IN] pintInputTop : Position haute zone de saisie
//  [IN] pintInputHeight : Hauteur zone de saisie
//  [IN] pintTipTop : Position haute message d'erreur
//  [IN] pintTipLeft : Position gauche message d'erreur
//  [IN] pintBottomEdge : Espace affichage bas
//  [RETOUR] Position haute message d'erreur
// -------------------------------------------------------------------------

function shr_fexe0_AdjustErrorTipPosition(pintY, pintInputTop, pintInputHeight, pintTipTop, pintTipLeft, pintBottomEdge)
{
 var lintI; // Indice
 var lintJ; // Indice
 var lintIMax; // Indice
 var lintJMax; // Indice
 var lobjForm; // Objet formulaire
 var lobjElem; // Objet element du formulaire
 var lobjPosition; // Objet pour lequel la position absolue doit etre obtenue
 var lintTipHeight; // Hauteur message d'erreur
 var lintTipWidth; // Largeur message d'erreur
 var lintLowerTipTop; // Position basse optimale message d'erreur
 var lintUpperTipTop; // Position haute optimale message d'erreur
 var lblnOverlap = false; // Recouvrement ?
 var lintElementNumber = 0; // Nbre elements
 var ltintElemTop = new Array(); // Positions hautes elements
 var ltintElemLeft = new Array(); // Positions gauches elements
 var ltintElemHeight = new Array(); // Hauteurs elements
 var ltintElemWidth = new Array(); // Largeurs elements

 // Dimension message d'erreur
 lintTipHeight = shr_fexe0_gobjFormErrorTip.clientHeight + 1;
 lintTipWidth = shr_fexe0_gobjFormErrorTip.clientWidth + 1;

 // Parcourir tous les elements de chaque formulaire
 for (lintI=0,lintIMax=window.document.forms.length; lintI<lintIMax; lintI++)
    {
     lobjForm = window.document.forms[lintI];

     for (lintJ=0,lintJMax=lobjForm.elements.length; lintJ<lintJMax; lintJ++)
        {
         lobjElem = lobjForm.elements[lintJ];

         if (  (lobjElem.type == "select-one")
             ||(lobjElem.type == "select-multiple") )
           {
            // Determine les coordonnees absolues de l'element
            ltintElemHeight[lintElementNumber] = lobjElem.clientHeight;
            ltintElemWidth[lintElementNumber] = lobjElem.clientWidth;

            var lobjElemPos = shr_tools_GetElementPos(lobjElem);
            ltintElemTop[lintElementNumber] = lobjElemPos.y;
            ltintElemLeft[lintElementNumber] = lobjElemPos.x;

            // Chevauchement message d'erreur
            if (  (ltintElemTop[lintElementNumber] <= pintTipTop + lintTipHeight)
                &&(ltintElemTop[lintElementNumber] + ltintElemHeight[lintElementNumber] >= pintTipTop)
                &&(ltintElemLeft[lintElementNumber] <= pintTipLeft + lintTipWidth)
                &&(ltintElemLeft[lintElementNumber] + ltintElemWidth[lintElementNumber] >= pintTipLeft) )
              { lblnOverlap = true; }

            lintElementNumber++;
           }
        }
    }

 // Pas de chevauchement
 if (!lblnOverlap)
   { return(pintTipTop); }

 // Position optimale en bas de la zone de saisie
 lintLowerTipTop = pintInputTop + pintInputHeight + 1;

 for (;;)
    {
     for (lintI=0; lintI < lintElementNumber ; lintI++)
        {
         // Chevauchement message d'erreur
         if (  (ltintElemTop[lintI] <= lintLowerTipTop + lintTipHeight)
             &&(ltintElemTop[lintI] + ltintElemHeight[lintI] >= lintLowerTipTop)
             &&(ltintElemLeft[lintI] <= pintTipLeft + lintTipWidth)
             &&(ltintElemLeft[lintI] + ltintElemWidth[lintI] >= pintTipLeft) )
           {
            lintLowerTipTop = ltintElemTop[lintI] + ltintElemHeight[lintI] + 1;
            break;
           }
        }

     if (lintI == lintElementNumber)
       { break; }
    }

 // Position optimale en haut de la zone de saisie
 lintUpperTipTop = pintInputTop - lintTipHeight - 2;

 for (;;)
    {
     for (lintI=0; lintI < lintElementNumber ; lintI++)
        {
         // Chevauchement message d'erreur
         if (  (ltintElemTop[lintI] <= lintUpperTipTop + lintTipHeight)
             &&(ltintElemTop[lintI] + ltintElemHeight[lintI] >= lintUpperTipTop)
             &&(ltintElemLeft[lintI] <= pintTipLeft + lintTipWidth)
             &&(ltintElemLeft[lintI] + ltintElemWidth[lintI] >= pintTipLeft) )
           {
            lintUpperTipTop = ltintElemTop[lintI] - lintTipHeight - 2;
            break;
           }
        }

     if (lintI == lintElementNumber)
       { break; }
    }

 // Position retournee : position la plus proche de la zone de saisie
 if (  (lintLowerTipTop + lintTipHeight - pintY <= pintBottomEdge)
     &&(lintLowerTipTop - (pintInputTop + pintInputHeight) <= pintInputTop - (lintUpperTipTop + lintTipHeight)) )
   { return(lintLowerTipTop); }

 return(lintUpperTipTop);
}


// -------------------------------------------------------------------------
//  Obtenir Position curseur (Caret)
// -------------------------------------------------------------------------
//  [IN] pobjField  Champ de saisie
//  [RETURN] Position du curseur, -1 Position non calculée
// -------------------------------------------------------------------------

function shr_fexe0_GetCursorPosition(pobjField)
{
 // Internet Explorer
 if (document.selection)
   {
    var lchrCaracter = "\001";
    var lobjSelect	= document.selection.createRange();
    var lobjSelectDuplicate = lobjSelect.duplicate();
    var lintCursorPosition	= 0;

    // Texte selectionné pas de Calcul de position
    if (lobjSelect.text)
      { return -1; }

    // Dupliquer Objet
    lobjSelectDuplicate.moveToElementText(pobjField);

    // Positionner le caractère
    lobjSelect.text = lchrCaracter;

    // Rechercher position du caractère
    lintCursorPosition	= (lobjSelectDuplicate.text.indexOf(lchrCaracter));

    // Supprimer le caractère
    lobjSelect.moveStart('character',-1);
    lobjSelect.text = "";
   }
 // Firefox
 else if (pobjField.selectionStart || pobjField.selectionStart == '0')
   {
    lintCursorPosition = pobjField.selectionStart;

    // Ajouter longueur fin de ligne (\r\n)
    lintCursorPosition=lintCursorPosition+2;
   }

 // Retourner Position curseur
 return lintCursorPosition;
}


// -------------------------------------------------------------------------
//  Determine si il faut afficher la boite de confirmation de validation
//  du formulaire
// -------------------------------------------------------------------------
//  [RETURN] True si la confirmation ne doit pas etre effectuée, sinon false
// -------------------------------------------------------------------------

function shr_fexe0_IsStopConfirm()
{
 var lblnIsStopConfirm = shr_fexe0_gblnIsStopConfirm;
 shr_fexe0_gblnIsStopConfirm = false;

 return(lblnIsStopConfirm);
}


// -------------------------------------------------------------------------
//  Ne pas afficher la la boite de confirmation de validation
//  du formulaire
// -------------------------------------------------------------------------

function shr_fexe0_StopConfirm()
{ shr_fexe0_gblnIsStopConfirm = true; }
