function processCommand(oFormObject) {


  oOption = oFormObject.options[oFormObject.selectedIndex];

  if (!oOption) return;

  sCmd = oOption.label;
  sData = oOption.value;

  if (!sData) return;

  // are we running in a popup?
  bInPop = window.opener;

  document.getElementById('user_cmd').value = sCmd;
  document.getElementById('user_cmd_data').value = sData;

  if (sCmd == "Delete Message"){
    if(!confirm("Are you sure you want to delete this message?"))
    {
      oFormObject.selectedIndex = 0;
      return;
    }
  }
  if (sCmd == "Delete This Topic"){
    if(!confirm("Are you sure you want to delete this ENTIRE topic?"))
    {
      oFormObject.selectedIndex = 0;
      return;
    }

  }

  if (sCmd == "Move This Topic"){
    openBoaderChooser("move_topic.html&mode=choose_board&bd=nh");
    storedData = sData;
    return;
  }


  if (sCmd == "Ban This User"){
    if(!confirm("Are you sure you want to ban this user?"))
    {
      oFormObject.selectedIndex = 0;
      return;
    }
    iNumDays = prompt("How many days (-1 is indefinite)?", "7");
    if (iNumDays != null)
      document.getElementById('user_cmd_extra_data').value = iNumDays;
    else
    {
      oFormObject.selectedIndex = 0;
      return;
    }

  }

  if (sCmd == "Suspend This User"){
    iNumDays = prompt("How many days (-1 is indefinite, Moderators may only select 1-7 days)?", "7");
    if (iNumDays != null)
      document.getElementById('user_cmd_extra_data').value = iNumDays;
    else
    {
      oFormObject.selectedIndex = 0;
      return;
    }

  }

  if (sCmd == "View Edit History"){
    if (window.opener)
      document.forms['command'].target = "_blank";
  }

  if (sCmd == "Moderate"){

       if(!confirm("This will automatically mark the message as abusive and take you to the moderation page. Are you sure?"))
       {
        oFormObject.selectedIndex = 0;
        return;
       }
  }

  document.forms['command'].submit();
}


function submitPost(form) {
  if(!self.DoubleClickTrapperAction) {
    return;
  }
  
  document.forms.edit_message['mode'].value = "submit";
  document.forms.edit_message.submit();
}

function preview(form) {
  if(!self.DoubleClickTrapperAction) {
    return;
  }
  document.forms.edit_message['mode'].value = "preview";
  document.forms.edit_message.submit();
}

function checkSpelling(form, using_wysiwyg) {
    // if using the wysiwyg editor, then call its functions
    if ( using_wysiwyg ) {
        tinyMCE.hideMenus();
        tinyMCE.execInstanceCommand('mce_editor_0','mceSpellCheck');
        tinyMCE.execInstanceCommand('mce_editor_1','mceSpellCheck'); // in case there is blurb and message
        return;
    }
      
    if(!self.DoubleClickTrapperAction) {
        return;
    }
    
    document.forms.edit_message['mode'].value = "preview";
    document.forms.edit_message['check_spelling'].value = "true";
    document.forms.edit_message.submit();
}

function resetForm() {
  document.forms.edit_message.reset();
}


function openBoaderChooser(url)
{
  iChooserWin=window.open(url, "tv_board_chooser", "width=200,height=250,scrollbars=no,resizable=no,titlebar=no");
  iChooserWin.focus();
  return iChooserWin;
}

function boardPicked(sTitle, iId) {

  // user has picked a dest board for moving a topic
  if (confirm("You have chosen to move the this topic and all of it's messages from this board to the '" + sTitle + "' board. Are you sure?")) {
        document.getElementById('user_cmd_extra_data').value = iId;
      document.forms['command'].submit();
  }
}



// This is used for the "quick quote" feature on the forums
// to pull the unformatted text of the quoted message into
// the message field
function quote(id,user) {
  msg = document.getElementById(id).value;
  msg = '[QUOTE="'+user+'"]'+msg+'[/QUOTE]';
  document.getElementById('msg_content').value = msg;
  reply();
}

// This just makes the reply div visible on the forums.
function reply() {
  document.getElementById('post-reply').style.display = 'block';
  document.getElementById('msg_content').focus();
}


// Search Bar Function
function searchForumBar(instance) {
  if (document.getElementById('search_forums_'+instance).search_text.value != ""){
    document.getElementById('search_forums_'+instance).submit();
  }else{
    alert('Please enter a search term.');
  }
}


// Board Selector Function
function board_selector_onchange(this_option) {
  if ( !this_option.options[this_option.selectedIndex].value ) {
    this_option.selectedIndex = 0;
    return;
  }
  location.href = this_option.options[this_option.selectedIndex].value;
}


function checkSpellingAjax(form, using_wysiwyg) {
  if(!self.DoubleClickTrapperAction) {
    return;
  }
  document.forms.edit_message['mode'].value = "preview";
  document.forms.edit_message['check_spelling'].value = "true";
  if ( using_wysiwyg ) {
      document.forms.edit_message.onsubmit();
  }
//  document.forms.edit_message.submit();
  postComment('edit_message');
}



function submitPostAjax(form, using_wysiwyg) {
  if(!self.DoubleClickTrapperAction) {
    return;
  }

  document.forms.edit_message['mode'].value = "submit";
  if ( using_wysiwyg ) {
      document.forms.edit_message.onsubmit();
  }
//  document.forms.edit_message.submit();
  postComment('edit_message');
}

function previewAjax(form, using_wysiwyg) {
  if(!self.DoubleClickTrapperAction) {
    return;
  }
  document.forms.edit_message['mode'].value = "preview";
  if ( using_wysiwyg ) {
      document.forms.edit_message.onsubmit();
  }
//  document.forms.edit_message.submit();
  postComment('edit_message');
}
