<!-- $Id: toolbar.txt,v x.x 2011-08-31 16:17:36 flh Exp $ -->

<script type="text/javascript"><!--
function insertTags (tagOpen, tagClose, sampleText) {
  var t = document.forms%[0].%name;;

  // IE
  if(document.selection) {
    var theSelection = document.selection.createRange().text;
    if(!theSelection) { theSelection=sampleText;}
    t.focus();
    if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
      theSelection = theSelection.substring(0, theSelection.length - 1);
      document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
    } 
    else {
      document.selection.createRange().text = tagOpen + theSelection + tagClose;
    }
  }
  else 
    if(t.selectionStart || t.selectionStart == '0') {
      var replaced = false;
      var startPos = t.selectionStart;
      var endPos = t.selectionEnd;
      if(endPos-startPos) replaced=true;
      var scrollTop=t.scrollTop;
      var myText = (t.value).substring(startPos, endPos);
      if(!myText) { myText=sampleText;}
      if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
        subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
      } 
      else {
        subst = tagOpen + myText + tagClose;
      }
      t.value = t.value.substring(0, startPos) + subst +
                t.value.substring(endPos, t.value.length);
      t.focus();
      //set new selection
      if(replaced){
        var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
        t.selectionStart=cPos;
        t.selectionEnd=cPos;
      }
      else {
        t.selectionStart=startPos+tagOpen.length;
        t.selectionEnd=startPos+tagOpen.length+myText.length;
      }
      t.scrollTop=scrollTop;
    }

  if (t.createTextRange) t.caretPos = document.selection.createRange().duplicate();
  return false;
}
--></script>

<a onclick="return insertTags('\'\'\'','\'\'\'','Texte gras')" href="javascript:;">
<img width="25" height="25" alt="Texte gras" title="Texte gras" src="%image_prefix;/button_bold.png"/></a>

<a onclick="return insertTags('\'\'','\'\'','Texte italique');" href="javascript:;">
<img width="25" height="25" alt="Texte italique" title="Texte italique" src="%image_prefix;/button_italic.png"/></a>

<a onclick="return insertTags('\n*Element 1\n*Element 2\n*Element 3','','Liste a puces');" href="javascript:;">
<img width="25" height="25" alt="Liste a puces" title="Liste a puces" src="%image_prefix;/button_list.png"/></a>

<a onclick="return insertTags('\[\[\[','\]\]\]','Lien_interne/Nom du lien');" href="javascript:;">
<img width="25" height="25" alt="Lien_interne/Nom du lien" title="Lien_interne/Nom du lien" src="%image_prefix;/button_link.png"/></a>

<a onclick="return insertTags('\n== ',' ==\n','Titre de rubrique');" href="javascript:;">
<img width="25" height="25" alt="Titre de rubrique" title="Titre de rubrique" src="%image_prefix;/button_headline.png"/></a>

<a onclick="return insertTags('\n<hr />\n','','');" href="javascript:;">
<img width="25" height="25" alt="Ligne horizontale" title="Ligne horizontale" src="%image_prefix;/button_hr.png"/></a>

