function add_bold(){
  var text_input = document.article_input.comments;
  var selected=false;
  var before, newtext, after;
  var outlength = text_input.textLength;

  text_input.focus();

  if((navigator.userAgent == "Microsoft Internet Explorer") || (navigator.userAgent == "MSIE")) {
    selected = document.selection.createRange().text;
    if(selected) {
      document.selection.createRange().text = '[b]' + selected + '[/b]';
      text_input.focus();
      return;
    }// end if(selected)
    else {
      text_input.value += '[b][/b]';
      text_input.focus();
      return;
    }// end else
  }// end if(navigator.userAgent == "Microsoft Internet Explorer")
  else {
    if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 )) {
      before = (text_input.value).substring(0, text_input.selectionStart);
      newtext = (text_input.value).substring(text_input.selectionStart, text_input.selectionEnd);
      after = (text_input.value).substring(text_input.selectionEnd, outlength);

      text_input.value = before + '[b]' + newtext + '[/b]' + after;
      text_input.focus();
      return;
    }// end if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 ))
    else {
      text_input.value += '[b][/b]';
      text_input.focus();
      return;
    }// end else
  }// end else
}// end function add_bold()

function add_italics(){
  var text_input = document.article_input.comments;
  var selected=false;
  var before, newtext, after;
  var outlength = text_input.textLength;

  text_input.focus();

  if((navigator.userAgent == "Microsoft Internet Explorer") || (navigator.userAgent == "MSIE")) {
    selected = document.selection.createRange().text;
    if(selected) {
      document.selection.createRange().text = '[i]' + selected + '[/i]';
      text_input.focus();
      return;
    }// end if(selected)
    else {
      text_input.value += '[i][/i]';
      text_input.focus();
      return;
    }// end else
  }// end if(navigator.userAgent == "Microsoft Internet Explorer")
  else {
    if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 )) {
      before = (text_input.value).substring(0, text_input.selectionStart);
      newtext = (text_input.value).substring(text_input.selectionStart, text_input.selectionEnd);
      after = (text_input.value).substring(text_input.selectionEnd, outlength);

      text_input.value = before + '[i]' + newtext + '[/i]' + after;
      text_input.focus();
      return;
    }// end if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 ))
    else {
      text_input.value += '[i][/i]';
      text_input.focus();
      return;
    }// end else
  }// end else
}// end function add_italics()

function add_underline(){
  var text_input = document.article_input.comments;
  var selected=false;
  var before, newtext, after;
  var outlength = text_input.textLength;

  text_input.focus();

  if((navigator.userAgent == "Microsoft Internet Explorer") || (navigator.userAgent == "MSIE")) {
    selected = document.selection.createRange().text;
    if(selected) {
      document.selection.createRange().text = '[u]' + selected + '[/u]';
      text_input.focus();
      return;
    }// end if(selected)
    else {
      text_input.value += '[u][/u]';
      text_input.focus();
      return;
    }// end else
  }// end if(navigator.userAgent == "Microsoft Internet Explorer")
  else {
    if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 )) {
      before = (text_input.value).substring(0, text_input.selectionStart);
      newtext = (text_input.value).substring(text_input.selectionStart, text_input.selectionEnd);
      after = (text_input.value).substring(text_input.selectionEnd, outlength);

      text_input.value = before + '[u]' + newtext + '[/u]' + after;
      text_input.focus();
      return;
    }// end if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 ))
    else {
      text_input.value += '[u][/u]';
      text_input.focus();
      return;
    }// end else
  }// end else
}// end function add_underline()

function add_url(){
  var text_input = document.article_input.comments;
  var selected=false;
  var before, newtext, after;
  var outlength = text_input.textLength;

  text_input.focus();

  if((navigator.userAgent == "Microsoft Internet Explorer") || (navigator.userAgent == "MSIE")) {
    selected = document.selection.createRange().text;
    if(selected) {
      document.selection.createRange().text = '[url=' + selected + '][/url]';
      text_input.focus();
      return;
    }// end if(selected)
    else {
      text_input.value += '[url=][/url]';
      text_input.focus();
      return;
    }// end else
  }// end if(navigator.userAgent == "Microsoft Internet Explorer")
  else {
    if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 )) {
      before = (text_input.value).substring(0, text_input.selectionStart);
      newtext = (text_input.value).substring(text_input.selectionStart, text_input.selectionEnd);
      after = (text_input.value).substring(text_input.selectionEnd, outlength);

      text_input.value = before + '[url=' + newtext + '][/url]' + after;
      text_input.focus();
      return;
    }// end if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 ))
    else {
      text_input.value += '[url=][/url]';
      text_input.focus();
      return;
    }// end else
  }// end else
}// end function add_url()

function add_img(image_name, image_alignment, image_alt){
  window.opener.document.article_input.comments.value+='[img='+image_name+' align='+image_alignment+' alt='+image_alt+']\n';
}// end function add_img()

function add_quote(){
  var text_input = document.article_input.comments;
  var selected=false;
  var before, newtext, after;
  var outlength = text_input.textLength;

  text_input.focus();

  if((navigator.userAgent == "Microsoft Internet Explorer") || (navigator.userAgent == "MSIE")) {
    selected = document.selection.createRange().text;
    if(selected) {
      document.selection.createRange().text = '[quote]' + selected + '[/quote]';
      text_input.focus();
      return;
    }// end if(selected)
    else {
      text_input.value += '[quote][/quote]';
      text_input.focus();
      return;
    }// end else
  }// end if(navigator.userAgent == "Microsoft Internet Explorer")
  else {
    if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 )) {
      before = (text_input.value).substring(0, text_input.selectionStart);
      newtext = (text_input.value).substring(text_input.selectionStart, text_input.selectionEnd);
      after = (text_input.value).substring(text_input.selectionEnd, outlength);

      text_input.value = before + '[quote]' + newtext + '[/quote]' + after;
      text_input.focus();
      return;
    }// end if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 ))
    else {
      text_input.value += '[quote][/quote]';
      text_input.focus();
      return;
    }// end else
  }// end else
}// end function add_quote()

function add_title(){
  var text_input = document.article_input.comments;
  var selected=false;
  var before, newtext, after;
  var outlength = text_input.textLength;

  text_input.focus();

  if((navigator.userAgent == "Microsoft Internet Explorer") || (navigator.userAgent == "MSIE")) {
    selected = document.selection.createRange().text;
    if(selected) {
      document.selection.createRange().text = '[t]' + selected + '[/t]';
      text_input.focus();
      return;
    }// end if(selected)
    else {
      text_input.value += '[t][/t]';
      text_input.focus();
      return;
    }// end else
  }// end if(navigator.userAgent == "Microsoft Internet Explorer")
  else {
    if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 )) {
      before = (text_input.value).substring(0, text_input.selectionStart);
      newtext = (text_input.value).substring(text_input.selectionStart, text_input.selectionEnd);
      after = (text_input.value).substring(text_input.selectionEnd, outlength);

      text_input.value = before + '[t]' + newtext + '[/t]' + after;
      text_input.focus();
      return;
    }// end if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 ))
    else {
      text_input.value += '[t][/t]';
      text_input.focus();
      return;
    }// end else
  }// end else
}// end function add_bold()

function add_small_title(){
  var text_input = document.article_input.comments;
  var selected=false;
  var before, newtext, after;
  var outlength = text_input.textLength;

  text_input.focus();

  if((navigator.userAgent == "Microsoft Internet Explorer") || (navigator.userAgent == "MSIE")) {
    selected = document.selection.createRange().text;
    if(selected) {
      document.selection.createRange().text = '[s]' + selected + '[/s]';
      text_input.focus();
      return;
    }// end if(selected)
    else {
      text_input.value += '[s][/s]';
      text_input.focus();
      return;
    }// end else
  }// end if(navigator.userAgent == "Microsoft Internet Explorer")
  else {
    if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 )) {
      before = (text_input.value).substring(0, text_input.selectionStart);
      newtext = (text_input.value).substring(text_input.selectionStart, text_input.selectionEnd);
      after = (text_input.value).substring(text_input.selectionEnd, outlength);

      text_input.value = before + '[s]' + newtext + '[/s]' + after;
      text_input.focus();
      return;
    }// end if(text_input.selectionEnd && ((text_input.selectionEnd - text_input.selectionStart) > 0 ))
    else {
      text_input.value += '[s][/s]';
      text_input.focus();
      return;
    }// end else
  }// end else
}// end function add_bold()