// utils.js -- JavaScript utility functions -- Copyright 2005, Cary Wyman

  // A technique for hiding email addresses from spiders (from Judy Scholl):
  //    <a href="#page" onclick='send("bob", "earthlink", "net");'>&lt;bob&#64;earthlink&#46;net&gt;</a>
function send(owner, host, identifier)
{
	location.href = "mailto:" + owner + "@" + host + "." + identifier;
}

  // return an integer between m and n (equal distribution; ignores the case
  // whee random returns one, because there's nothing above the floor
function iRandom(m, n)
{
  var k;
  do
    k = Math.floor(Math.random() * (n - m + 1)) + m;
  while (k > n);
  return k;
}

  // remove leading and trailing blanks
function trim(s)
{
  var k0 = 0, kn = s.length;
  while (k0 < kn && s.charAt(k0) == " ") k0 += 1;
  while (k0 < kn && s.charAt(kn) == " ") kn -= 1;
  return s.substring(k0, kn);
}

  // converts a number m to a string and inserts leading zeros (if length < n)
function zFill(m, n)
{
  var s = m.toString();
  while (s.length < n) s = "0" + s;
  return s;
}

function ConfirmSubmit()
{
  var submitForm = confirm("Are you sure you want to submit these values?");
  return submitForm;
}

function ConfirmReset()
{
  var resetForm = confirm("Are you sure you want to reset the page to its original state?");
    // Do this instead of reset to clear any changes made
  if (resetForm) location.reload(true);
  return false;
}

