
function calculeLongueur(maxlength)
{
   var iLongueur, iLongueurRestante;
   
   iLongueur = document.getElementById('ddescription').value.length;
   
   if (iLongueur > maxlength) {
      document.getElementById('ddescription').value = document.getElementById('ddescription').value.substring(0,maxlength);
      iLongueurRestante = 0;
   }
   else {
      iLongueurRestante = maxlength - iLongueur;
   }
   if (iLongueurRestante <= 1)
      document.getElementById('cptchars').innerHTML = iLongueurRestante;
   else
      document.getElementById('cptchars').innerHTML = iLongueurRestante;
}

function afficher(value)
{
  if (value.style.display == 'block')
  {
    value.style.display = 'none';
    return;
  }
  if (value.style.display == 'none')
  {
    value.style.display = 'block';
    return;
  }
}

function hidde(value)
{
  value.style.display = 'none';
  return;
}

function validate_geoloc(id_local)
{
  document.getElementById('IDgeolocalisation').value = id_local;
  document.getElementById('getgeoloc').submit();
}


function insertTag(startTag, endTag, textareaId, tagType) 
{
        var field  = document.getElementById(textareaId); 
        var scroll = field.scrollTop;
        field.focus();
        
        if (window.ActiveXObject) // C'est IE
        { 
                var textRange = document.selection.createRange();            
                var currentSelection = textRange.text;
                
                textRange.text = startTag + currentSelection + endTag;
                textRange.moveStart("character", -endTag.length - currentSelection.length);
                textRange.moveEnd("character", -endTag.length);
                textRange.select();     
        } 
        else // Ce n'est pas IE
        { 
                var startSelection   = field.value.substring(0, field.selectionStart);
                var currentSelection = field.value.substring(field.selectionStart, field.selectionEnd);
                var endSelection     = field.value.substring(field.selectionEnd);
                
                field.value = startSelection + startTag + currentSelection + endTag + endSelection;
                field.focus();
                field.setSelectionRange(startSelection.length + startTag.length, startSelection.length + startTag.length + currentSelection.length);
        } 

        field.scrollTop = scroll; // et on redéfinit le scroll.
}

