function isBlank(id, caption)
{
  var el = document.getElementById(id);
  if(el.value.length == 0)
  {
    alert(caption + ' cannot be blank. Please correct it.');
    el.focus();
    return true;
  }
  return false;
}

function isBlankSel(id, caption)
{
  var el = document.getElementById(id);
  if(el.selectedIndex == 0)
  {
    alert(caption + ' cannot be blank. Please correct it.');
    el.focus();
    return true;
  }
  return false;
}

function isNum(id, caption)
{
  var el = document.getElementById(id);
  if(!el.value.match(/^[0-9]+$/))
  {
    alert(caption + ' must be a number. Please correct it.');
    el.focus();
    return false;
  }
  
  return true;
}

function isValidDate(yy, mm, dd)
{
  y = document.getElementById(yy).value;
  ms = document.getElementById(mm);
  m = ms[ms.selectedIndex].value;
  d = document.getElementById(dd).value;
  
  aNumDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
  if(!y) return false
  if(m < 1) return false
  if(!(y % 4)) aNumDays[1] = 29
  return !(d < 1 || d > aNumDays[m - 1]) 
}

function isEmail(id, caption)
{
  el = document.getElementById(id);
  e = el.value;
  if(e.indexOf('.') >= 0 && e.indexOf('@') > 0 && e.indexOf('@') < e.lastIndexOf('.'))
    return true;
  else
  {
    alert(caption + ' is not a valid Internet email address. Please correct it.');
    el.focus();
    return false;
  }
}
