
function validateNews(theForm)
{
  if (theForm.title.value == "")
  {
    alert("Please enter a title for the item.");
    theForm.title.focus();
    return (false);
  }
  if (theForm.body.value == "")
  {
    alert("Please enter the body for the item.");
    theForm.body.focus();
    return (false);
  }
  return (true);
}

function validateNewsSlimAdd(theForm)
{
  if (theForm.title.value == "")
  {
    alert("Please enter a title for the item.");
    theForm.title.focus();
    return (false);
  }
}

function validateCommunity(theForm)
{
  if (theForm.title.value == "")
  {
    alert("Please enter a title for the article.");
    theForm.title.focus();
    return (false);
  }
  if (theForm.body.value == "")
  {
    alert("Please enter the body for the article.");
    theForm.body.focus();
    return (false);
  }
  return (true);
}

function validateCommunitySlimAdd(theForm)
{
  if (theForm.title.value == "")
  {
    alert("Please enter a title for the article.");
    theForm.title.focus();
    return (false);
  }
}

function validateNewAccountForm(theForm)
{
  if (theForm.name.value == "")
  {
    alert("Please enter your name.");
    theForm.name.focus();
    return (false);
  }
  if (theForm.contact.value == "")
  {
    alert("Please enter your e-mail address or phone number.");
    theForm.contact.focus();
    return (false);
  }
  return (true);
}

function validateContactForm(theForm)
{
  if (theForm.name.value == "")
  {
    alert("Please enter your name.");
    theForm.name.focus();
    return (false);
  }
  if (theForm.contact.value == "")
  {
    alert("Please enter your e-mail address or phone number.");
    theForm.contact.focus();
    return (false);
  }
  return (true);
}

function validateProduct(theForm)
{
  if (theForm.productName.value == "")
  {
    alert("Please enter a product name.");
    theForm.productName.focus();
    return (false);
  }
  return (true);
}

function validateCategory(theForm)
{
  if (theForm.categoryName.value == "")
  {
    alert("Please enter a category name.");
    theForm.categoryName.focus();
    return (false);
  }
  return (true);
}

function validateImage(theForm)
{
  if (theForm.image.value == "")
  {
    alert("Dude! Enter a file name for the image.");
    theForm.image.focus();
    return (false);
  }
  return (true);
}

function validateLogDelete(theForm)
{
  if(!/^\d+$/.test(theForm.clearNum.value))
  {
    alert("The month field should contain a number.");
    theForm.clearNum.focus();
    return false;
  }
  return (true);
}

function deleteItem(what)
{
   if (confirm("Are you sure you want to delete this item?"))
   {
   document.forms[0].action = what;
   document.forms[0].submit();
   }
}

function deleteCat(what)
{
   if (confirm("Are you sure you want to delete this category?"))
   {
   document.forms[0].action = what;
   document.forms[0].submit();
   }
}

function deleteProd(what)
{
   if (confirm("Are you sure you want to delete this product?"))
   {
   document.forms[0].action = what;
   document.forms[0].submit();
   }
}

function deleteUser(what)
{
   if (confirm("Are you sure you want to delete this user?"))
   {
   document.forms[0].action = what;
   document.forms[0].submit();
   }
}

function CancelDelete(thePage)
{
   document.forms[0].action = thePage;
   document.forms[0].submit();
}

function formPopUp(file) 
{
   window.open(file,'BMSI','scrollbars=no,width=525,height=375,top=150,left=150');
}

function imagePopUp(file) 
{
   window.open(file,'BMSI','scrollbars=no,width=600,height=450,top=100,left=100');
}

function helpPopUp(file) 
{
   window.open(file,'BMSI','scrollbars=yes,width=300,height=300,top=150,left=150');
}

function TrackCount(fieldObj,countFieldName,maxChars)
{
  var countField = eval("fieldObj.form."+countFieldName);
  var diff = maxChars - fieldObj.value.length;

  // Need to check & enforce limit here also in case user pastes data
  if (diff < 0)
  {
    fieldObj.value = fieldObj.value.substring(0,maxChars);
    diff = maxChars - fieldObj.value.length;
  }
  countField.value = diff;
}

function trackCount(fieldObj,countFieldName,maxChars)
{
  var countField = eval("fieldObj.form."+countFieldName);
  var diff = maxChars - fieldObj.value.length;

  // Need to check & enforce limit here also in case user pastes data
  if (diff < 0)
  {
    fieldObj.value = fieldObj.value.substring(0,maxChars);
    diff = maxChars - fieldObj.value.length;
  }
  countField.value = diff;
}

function limitText(fieldObj,maxChars)
{
  var result = true;
  if (fieldObj.value.length >= maxChars)
    result = false;
  
  if (window.event)
    window.event.returnValue = result;
  return result;
}

function closeWindow(closeWait)
{
	window.setTimeout("window.close()",closeWait*1000);
}

