// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function addText(Text)
{
  var obj = document.forms['message'].elements['message_body'];
  obj.focus();
 
  if (document.selection && document.selection.createRange)  // Internet Explorer
  {
    sel = document.selection.createRange();
if (sel.parentElement() == obj)  sel.text = Text;
  }

  else if (obj != "undefined")  // Firefox
  {
var selStart = obj.selectionStart;
var selEnd = obj.selectionEnd;

obj.value = obj.value.substring(0,selStart) + Text + obj.value.substr(selEnd);
  }
 
  else obj.value += Text;

  obj.focus();
}


function addTags(Tag, fTag)
{
  var obj = document.forms['message'].elements['message_body'];
  obj.focus();
 
  if (document.selection && document.selection.createRange)  // Internet Explorer
  {
    sel = document.selection.createRange();
if (sel.parentElement() == obj)  sel.text = Tag + sel.text + fTag;
  }

  else if (obj != "undefined")  // Firefox
  {
var selStart = obj.selectionStart;
var selEnd = obj.selectionEnd;

obj.value = obj.value.substring(0,selStart) + Tag + obj.value.substring(selStart,selEnd) + fTag + obj.value.substr(selEnd);
  }
 
  else obj.value += Tag + fTag;

  obj.focus();
}