// scripts by me to manage forms and checkboxes

function validate_form()
{
   var valid = true;
   var missing = "";

   if ( window.document.order.b_name.value == "" )
   {
      missing = "- Company Name\n";
      window.document.order.b_name.focus();
   }

   if ( window.document.order.b_email.value == "" )
   {
      if (missing == "")
      window.document.order.b_email.focus();
      missing += "- Your Email Address\n";
   }

   if ( window.document.order.b_company.value == "" )
   {
      if (missing == "")
      window.document.order.b_company.focus();
      missing += "- Your Name\n";
   }

   if ( window.document.order.b_phone.value == "" )
   {
      if (missing == "")
      window.document.order.b_phone.focus();
      missing += "- Phone Number\n";
   }

   if (missing != "")
   {
      alert ( "The following required field(s) in the form have not been completed\n\n" + missing);
      valid = false;
   }
   return valid;
}


function notice()
{
   if (window.document.order.process.checked==true)
   {
      window.document.order.summary.value=" Clicking on Submit WILL PROCESS YOUR ORDER IMMEDIATELY.";
      window.document.order.subbut.value="  SUBMIT  ";
   }
   if (window.document.order.process.checked==false)
   {
      window.document.order.summary.value=" Clicking on Preview will allow you to preview your order.";
      window.document.order.subbut.value=" PREVIEW ";
   }
}

// used for show all feature.  mode is used 0 for initial logon set checkbox but don't display, 1 is for in the order form
function checkcatall(mode,max)
{
var formpos = 0;		// position of form on page
var count = 0;
var info = "";

  if (window.document.custom.allcats.checked == true)
  {
    while (count <= max)
    {
      info = "idcat" + count;
      if (document.custom.elements[count].checked==false)		// if not on, display, else it's already on
      {
        if (mode)
          document.getElementById(info).style.display = "";	// 100313 now forcing this here so if on refresh of page checkboxes don't invert
        document.custom.elements[count].checked=true;		// set all categories to ON
      }
      count++;
    }
  }
  else
  {
    count = 0;
    while (count <= max)
    {
      info = "idcat" + count;
      if (document.custom.elements[count].checked==true)	// if on, now turn it off
      {
        if (mode)
        document.getElementById(info).style.display = "none";	// 100313 now forcing this here so if on refresh of page checkboxes don't invert
        document.custom.elements[count].checked=false;		// set category to off
      }
      count++;
    }
  }
}

function checkcat()
{
   if (window.document.custom.allcats.checked==true)		// show all categories is true
      window.document.custom.allcats.checked=false;		// so turn it off
}


// for individual display of subs including help and the quick access menu.
function displaycategory(the_sub,idval)
{
  if (idval)
  {
   if (document.custom.elements[idval].checked==false)
      document.getElementById(the_sub).style.display = "none";
   else
     document.getElementById(the_sub).style.display = "";
  }
  else
  {
   if (document.getElementById(the_sub).style.display=="")
   {
      document.getElementById(the_sub).style.display = "none";
      return
   }
   document.getElementById(the_sub).style.display = "";
  }
}

// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place

function numbersonly(myfield, e, dec)
{
   var key;
   var keychar;

   if (window.event)
      key = window.event.keyCode;
   else if (e)
      key = e.which;
   else
      return true;
   keychar = String.fromCharCode(key);

   // control keys
   if ((key==null) || (key==0) || (key==8) || 
       (key==9) || (key==13) || (key==27) )
      return true;

   // numbers
   else if ((("0123456789").indexOf(keychar) > -1))
      return true;

   // decimal point jump
   else if (dec && (keychar == "."))
   {
      myfield.form.elements[dec].focus();
      return false;
   }
   else
      return false;
}


