function markedItems(action, theURL, theForm, bSetCommand, optionalMessage) {

   var cnt = 0;
   var strItemCnt = '';

   for (var i = 0; i < theForm.elements.length; i++) {
      if ((theForm.elements[i].type == 'checkbox') &&
          (theForm.elements[i].name != 'chk_select') &&
          (theForm.elements[i].id != 'noautoselect')) {
         theForm.elements[i].checked ? cnt++ : true;
      }
   }

   if (action == 'delete' || action == 'dbdelete' || action == 'multidelete') {
      if (cnt < 1) {
         alert(g_MUSTCHECKBOX);
      } else {
         var strDelConfirm = g_YOUHAVESELECTED;
         if (cnt == 1) {
            strItemCnt = cnt + g_ITEM
            strDelConfirm = strDelConfirm.replace(/%1/i,strItemCnt) + g_DELETESINGLECONFIRMATION;
         } else {
            strItemCnt = cnt + g_ITEMS
            strDelConfirm = strDelConfirm.replace(/%1/i,strItemCnt) + g_DELETECONFIRMATION;
         }

         //Append optional message
         if (optionalMessage!=undefined){strDelConfirm +=optionalMessage;}           

         if(confirm(strDelConfirm)) {
            if (bSetCommand) {
               if (action == 'delete' || action == 'dbdelete') {
                  theForm._command.value = 'delete';
               } else {
                  theForm._command.value = 'multidelete';
               }
            }

            if (action == 'dbdelete' || action == 'multidelete') {
                theForm.method = 'post';
            }
            theForm.action = theURL;
            theForm.submit();
         }
      }
   }
   else if (action == 'move') {
      if (cnt < 1) {
         alert(g_MUSTCHECKBOX);
      } else {
          if (bSetCommand) {
             theForm._command.value = 'move';
          }
         theForm.action = theURL;
         theForm.submit();
      }
   }
   else if (action == 'email') {
       getEmailAddresses(bSetCommand, theForm._emailcolumninfo.value, true);
   }
   else if (action == 'sendemail') {
      if (cnt < 1) {
         alert(g_NOEMAILRECIPIENTSSELECTED);
      } else {
          getEmailAddresses(bSetCommand, theForm._emailcolumninfo.value);
      }
   }
   else if (action == 'assigncreator') {
      if (cnt < 1) {
         alert(g_MUSTCHECKBOX);
      } else {
         var strDelConfirm = g_YOUHAVESELECTED + cnt;
         if (cnt == 1) {
            strDelConfirm += g_ITEMSELECTED
         } else {
            strDelConfirm += g_ITEMSSELECTED
         }
         strCreator = theForm.elements['_assigncreator'][theForm.elements['_assigncreator'].selectedIndex].text;

         strDelConfirm += g_CLICKOKTOASSIGN + strCreator + g_ASTHECREATORFOR;
         if (cnt == 1) {
            strDelConfirm += g_THIS + g_ITEMASSIGN
         } else {
            strDelConfirm += g_THESE + g_ITEMSASSIGN
         }

         if(confirm(strDelConfirm)) {
            if (bSetCommand) {
               theForm._command.value = 'assigncreator';
            }
            theForm.method = 'post';
            theForm.action = theURL;
            theForm.submit();
         }
      }
   }
   else if (action == 'flag') {
       if (cnt < 1) {
          alert(g_MUSTCHECKBOX);
       } else {
          if (bSetCommand) {
             theForm._command.value = action;
          }
          theForm.method = 'post';
          theForm.action = theURL;
          theForm.submit();
       }
   }
   else {
      alert(g_NOACTIONSPECIFIED);
   }

}

function checkItems(theForm, checked) {

   var cnt = 0;
   if (checked==-1) {
      checked = theForm.chk_select.checked;
   }

   for (var i = 0; i < theForm.elements.length; i++) {
      if (theForm.elements[i].type == 'checkbox') {
         if (theForm.elements[i].id != 'noautoselect') {
            theForm.elements[i].checked = checked;
         }
      }
   }
}

function confirmdelete(theForm, confirmFlag, confirmMessage)
{
    if (confirmFlag == undefined) {
        confirmFlag = true;
    }

    if (confirmMessage == undefined) {
        confirmMessage = g_DELETESINGLECONFIRMATION;
    }

    if (!confirmFlag
        || confirm(confirmMessage)) {
        theForm._command.value = 'delete';
        theForm.submit();
    }
}
