function balise(balise_debut,balise_fin,id_textarea){var champ=document.getElementById(id_textarea);var scroll=champ.scrollTop;balise_debut=remplace(balise_debut,'<br />',"\n");if(balise_fin=='')balise_debut=' '+balise_debut+' ';if(champ.curseur){champ.curseur.text=balise_debut+champ.curseur.text+balise_fin}else if(champ.selectionStart>=0&&champ.selectionEnd>=0){var debut=champ.value.substring(0,champ.selectionStart);var entre=champ.value.substring(champ.selectionStart,champ.selectionEnd);var fin=champ.value.substring(champ.selectionEnd);champ.value=debut+balise_debut+entre+balise_fin+fin;champ.focus();champ.setSelectionRange(debut.length+balise_debut.length,champ.value.length-fin.length-balise_fin.length)}else{champ.value+=balise_debut+balise_fin;champ.focus()}champ.scrollTop=scroll}function remplace(data,search,replace){var temp=data;var longueur=search.length;while(temp.indexOf(search)>-1){pos=temp.indexOf(search);temp=(temp.substring(0,pos)+replace+temp.substring((pos+longueur),temp.length))}return temp}
