/************************************************************/
/* Fonctions de confirmation sur suppression                */
/************************************************************/
function confirmation(element,url){
	resultat = confirm('confirmez la suppression : '+element);
	if(resultat=="1") {
		window.location.replace(url)
	}
}

/************************************************************/
/* Fonctions Autochargement sur select                      */
/************************************************************/
function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

/************************************************************/
/* Fonctions d'insertion des balises de mise en page        */
/************************************************************/
function format(textarea, format) {
  var str = document.selection.createRange().text;
  document.post+textarea+focus();
  var sel = document.selection.createRange();
  sel.text = "[" + format + "]" + str + "[/" + format + "]";
  return;
}

function format2(f,g) {
  var str = document.selection.createRange().text;
  document.post.texte.focus();
  var sel = document.selection.createRange();
  sel.text = "[" + f + "]" + str + "[/" + g + "]";
  return;
}

/************************************************************/
/*    freekill (freekill.free.fr)                           */
/************************************************************/
function countInstances(open,closed,formName,areaName) {
   var opening = document.forms[formName][areaName].value.split(open);
   var closing = document.forms[formName][areaName].value.split(closed);
   return opening.length + closing.length - 2;
}
function TAinsert(text1,text2,formName,areaName) {
   //var ta = document.getElementById('texte');
   var ta = document.forms[formName][areaName];
   if (document.selection) {
       var str = document.selection.createRange().text;
       ta.focus();
       var sel = document.selection.createRange();
       if (text2!="") {
           if (str=="") {
               var instances = countInstances(text1,text2,formName,areaName);
               if (instances%2 != 0) sel.text = sel.text + text2;
               else sel.text = sel.text + text1;
           } else sel.text = text1 + sel.text + text2;
       } else sel.text = sel.text + text1;
   } else if (ta.selectionStart || ta.selectionStart == 0) {
       if (ta.selectionEnd > ta.value.length) ta.selectionEnd = ta.value.length;
       var firstPos = ta.selectionStart;
       var secondPos = ta.selectionEnd+text1.length;
       var contenuScrollTop = ta.scrollTop;
       ta.value=ta.value.slice(0,firstPos)+text1+ta.value.slice(firstPos);
       ta.value=ta.value.slice(0,secondPos)+text2+ta.value.slice(secondPos);
       ta.selectionStart = firstPos+text1.length;
       ta.selectionEnd = secondPos;
       ta.focus();
       ta.scrollTop = contenuScrollTop;
   } else { // Opera
       var sel = document.forms[formName][areaName];
       var instances = countInstances(text1,text2,formName,areaName);
       if (instances%2 != 0 && text2 != "") sel.value = sel.value + text2;
       else sel.value = sel.value + text1;
   }
}