function insertTag(startTag, endTag, textareaId, tagType) {
        var field  = document.getElementById(textareaId); 
        var scroll = field.scrollTop;
        field.focus();
        
        /* === Partie 1 : on récupère la sélection === */
        if (window.ActiveXObject) {
                var textRange = document.selection.createRange();            
                var currentSelection = textRange.text;
        } else {
                var startSelection   = field.value.substring(0, field.selectionStart);
                var currentSelection = field.value.substring(field.selectionStart, field.selectionEnd);
                var endSelection     = field.value.substring(field.selectionEnd);               
        }
        
        /* === Partie 2 : on analyse le tagType === */
        if (tagType) {
                switch (tagType) {
						case "lien":
								endTag = "[/url]";
								if (currentSelection) { // Il y a une sélection
										if (currentSelection.indexOf("http://") == 0 || currentSelection.indexOf("https://") == 0 || currentSelection.indexOf("ftp://") == 0 || currentSelection.indexOf("www.") == 0) {
												// La sélection semble être un lien. On demande alors le libellé
												var label = prompt("Quel texte afficher ?") || "";
												startTag = "[url=" + currentSelection + "]";
												currentSelection = label;
										} else {
												// La sélection n'est pas un lien, donc c'est le libelle. On demande alors l'URL
												var URL = prompt("Quel est le lien ?");
												startTag = "[url=" + URL + "]";
										}
								} else { // Pas de sélection, donc on demande l'URL et le libelle
										var URL = prompt("Quel est le lien ?")|| "";
										var label = prompt("Quel texte afficher ?") || "";
										startTag = "[url=" + URL + "]";
										currentSelection = label;                     
								}
						break;
						case "lienonglet":
								endTag = "[/url]";
								if (currentSelection) { // Il y a une sélection
										if (currentSelection.indexOf("http://") == 0 || currentSelection.indexOf("https://") == 0 || currentSelection.indexOf("ftp://") == 0 || currentSelection.indexOf("www.") == 0) {
												// La sélection semble être un lien. On demande alors le libellé
												var label = prompt("Quel texte afficher ?") || "";
												startTag = "[url=" + currentSelection + " onglet]";
												currentSelection = label;
										} else {
												// La sélection n'est pas un lien, donc c'est le libelle. On demande alors l'URL
												var URL = prompt("Quel est le lien ?");
												startTag = "[url=" + URL + " onglet]";
										}
								} else { // Pas de sélection, donc on demande l'URL et le libelle
										var URL = prompt("Quel est le lien ?")|| "";
										var label = prompt("Quel texte afficher ?") || "";
										startTag = "[url=" + URL + " onglet]";
										currentSelection = label;                     
								}
						break;
						case "liensignet":
								endTag = "[/url]";
								if (currentSelection) { // Il y a une sélection
												// La sélection n'est pas un lien, donc c'est le libelle. On demande alors l'URL
												var URL = prompt("Quel est le signet ?");
												startTag = '[url signet="' + URL + '"]';
												
								} else { // Pas de sélection, donc on demande l'URL et le libelle
										var URL = prompt("Quel est le signet ?")|| "";
										var label = prompt("Quel texte afficher ?") || "";
										startTag = '[url signet="' + URL + '"]';
										currentSelection = label;                     
								}
						break;
						case "article":
								endTag = "[/article]";
								if (currentSelection) { // Il y a une sélection
								// La sélection n'est pas un lien, donc c'est le libelle. On demande alors l'URL
												var ID = prompt("Rediriger vers quel article (ID) ?");
												startTag = "[article=" + ID + "]";
										
								} else { // Pas de sélection, donc on demande l'URL et le libelle
										var URL = prompt("Rediriger vers quel article (ID) ?")|| "";
										var label = prompt("Quel texte afficher ?") || "";
										startTag = "[article=" + URL + "]";
										currentSelection = label;                     
								}
						break;
						case "couleur":
								endTag = "[/color]";
								if (currentSelection) { // Il y a une sélection
										if (currentSelection.indexOf("#") == 0) {
												// La sélection semble être un lien. On demande alors le libellé
												var label = prompt("Quel texte à colorer  ?") || "";
												startTag = '[color="' + currentSelection + '"]';
												currentSelection = label;
										} else {
												// La sélection n'est pas un lien, donc c'est le libelle. On demande alors l'URL
												var URL = prompt("Quel est la couleur (Hexadécimal ou noms anglais) ?");
												startTag = '[color="' + URL + '"]';
										}
								} else { // Pas de sélection, donc on demande l'URL et le libelle
										var URL = prompt("Quel est la couleur (Hexadécimal ou noms anglais) ?")|| "";
										var label = prompt("Quel texte à colorer  ?") || "";
										startTag = '[color="' + URL + '"]';
										currentSelection = label;                     
								}
						break;
                }
        }
        
        /* === Partie 3 : on insère le tout === */
        if (window.ActiveXObject) {
                textRange.text = startTag + currentSelection + endTag;
                textRange.moveStart("character", -endTag.length - currentSelection.length);
                textRange.moveEnd("character", -endTag.length);
                textRange.select();     
        } else {
                field.value = startSelection + startTag + currentSelection + endTag + endSelection;
                field.focus();
                field.setSelectionRange(startSelection.length + startTag.length, startSelection.length + startTag.length + currentSelection.length);
        } 

        field.scrollTop = scroll;     
}

