function checkrequired(which) {
  var msg = "";

  for (i=0; i < which.length; i++) {

    var e = which.elements[i];

    if (e.title.substring(0,8) == "required") {
      if(e.value=='') {
        msg += "- '" + e.title.substring(8,30) + "' is a required field\n";
      }
    }

    if (e.value == "-") {
    msg += "- '" + e.name + "' contains an invalid option.\n";
    }
  }

  if ((msg == '') || (msg == null) ) {
    return true;
  } else {
    var alertmsg;
    alertmsg = "The form was not submitted due to the following errors:\n\n";
    alertmsg += msg + "\n";
    alertmsg += "Please re-submit once errors are corrected.";
    alert (alertmsg);
    return false;
  }
}


// LogDetails window function
  function subWin(type,query) {
    var url = "";
    var heightwidth = "height=300,width=400,";

  switch(type) {
    case 'dnldlog':
      url = "download_log.php?" + query ;
      heightwidth = "height=350,width=600";
      break;
    case 'cmpylog':
      url = "cmpy_log.php?" + query ;
      break;
    case 'addfile':
      url = "add_files.php" ;
      heightwidth = "height=350,width=450";
      break;
    case 'mailsol':
      url = "mail_solution.php?" + query ;
      heightwidth = "height=350,width=450";
      break;
    case 'mailcont':
      url = "mail_contact.php?" + query ;
      heightwidth = "height=350,width=450";
      break;
    case 'newdnld':
      url = "add_download.php?" + query ;
      break;
    case 'newlic':
      url = "add_license.php?" + query ;
      break;
    case 'up_prod':
      url = "upload_products.php?" + query ;
      break;
    case 'escalate':
      url = "escalate.php?" + query ;
      heightwidth = "height=350,width=450";
      break;
/* *********
    case 'getdnld':
      url = "../get_download_handler.php?" + query ;
      break;
    case 'getlic':
      url = "../get_license_handler.php?" + query ;
      break;
********** */
    case 'product':
      url = "prod_detail.php?" + query;
      break;
    case 'rem_usr':
      url = "remove_user.php?" + query;
      break;
    case 'soft_eval':
      url = "JabberSoftEval.pdf";
      heightwidth = "height=750,width=650";
      break;
    default:
      url = "log_detail.php?" + query;
      break;
  }

  var params = "resizable=yes,scrollbars=yes,status=no,menubar=no,location=no";
  params = heightwidth + params;
  newwin = window.open(url,type,params,true);
}

  function checkTimeOrDateValue(tdElement, type) {
    var valid = "0123456789"
    var ok = "yes";
    var temp;
    for (var i=0; i<tdElement.value.length; i++) {
      temp = "" + tdElement.value.substring(i, i+1);
      if (valid.indexOf(temp) == "-1") {
        alert("Invalid entry!  Only numbers are accepted!");
        return false;
      }
    }

    if(type == "hour") {
      if(tdElement.value > 12 || tdElement.value < 1) {
        alert("This is not a valid hour of the day.");
        tdElement.value = 1;
        return false;
      }
    }

    if(type == "minute") {
      if(tdElement.value > 59 || tdElement.value < 0) {
        alert("This is not a valid minute value");
        tdElement.value = 0;
        return false;
      }
    }

    if(type == "month") {
      if(tdElement.value > 12 || tdElement.value < 1) {
        alert("This is not a valid Month");
        tdElement.value = 1;
        return false;
      }
    }

    if(type == "day") {
      if(tdElement.value > 31 || tdElement.value < 1) {
        alert("This is not a valid Day");
        tdElement.value = 1;
        return false;
      }
    }

    if(type == "year") {
      if(tdElement.value.length != 4) {
        alert("Please enter a 4-digit year");
        tdElement = 2002;
        return false;
      }
      if(tdElement.value < 2002) {
        alert("Quit living in the past");
        tdElement = 2002;
        return false;
      }
    }

  }
