<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System !                                 */
/* ===========================                                          */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
# FORM HELPING... used in Fora/News / Parts off PHPBB
#
# Doprompt(), DoAdd() is a rewrited and optimized version from an old version
# of BB forum javascript.
#   : DoPrompt()
#   : - Now whith real HTML tags, and not whith BBcodes...
#   : - A better check if empty entrys
#   : DoAdd()
#   : - include the caretPos, insert 'text' at the cursor pos. in the textArea
#       and not only at the End.
#
# storeCaret(), I found it somewhere in a Javascript Lib Page... Also i can't
# remember the Author for credits !!!
#
# Modification by GaWaX @ g2001.net (c) Jun 2002
# Intégré dans NPDS V par snipe 04/2003
?>

<SCRIPT type="text/javascript" language="JavaScript">
<!--
function addText(instextD, instextF) {
   var mess = document.coolsus.message;
   //IE support
   if (document.selection) {
      mess.focus();
      sel = document.selection.createRange();
      sel.text = instextD + sel.text + instextF;
      document.coolsus.focus();
   }
   //MOZILLA/NETSCAPE support
   else if (mess.selectionStart || mess.selectionStart == "0") {
      var startPos = mess.selectionStart;
      var endPos = mess.selectionEnd;
      var chaine = mess.value;
      mess.value = chaine.substring(0, startPos) + instextD + chaine.substring(startPos, endPos) + instextF  + chaine.substring(endPos, chaine.length);
      mess.focus();
   } else {
      mess.value += instext;
      mess.focus();
   }
}

function DoAdd(externe, champ, text) {
   if (externe)
      var thisForm = opener.document.coolsus[champ];
   else
      var thisForm = document.coolsus[champ];

   if (thisForm.createTextRange && thisForm.caretPos) {
      var caretPos = thisForm.caretPos;
      caretPos.text = (caretPos.text.charAt(caretPos.text.length - 1) == ' ') ? text + ' ' : text;
   } else thisForm.value  += text;
   thisForm.focus();
   return;
}

function emoticon(text) {
   text = ' ' + text + ' ';
   var txtarea = document.coolsus.message;
   if (txtarea.createTextRange && txtarea.caretPos) {
      var caretPos = txtarea.caretPos;
      caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
      txtarea.focus();
   } else {
      txtarea.value  += text;
      txtarea.focus();
   }
}

function storeCaret(text) {
   if (text.createTextRange) text.caretPos = document.selection.createRange().duplicate();
}

function storeForm(textEl) {
   document.currentForm = textEl;
}
//-->
</script>