function selectClear(inputComponent, buttonPress) {
  butt = eval('document.queryform.' + buttonPress);
  if (butt.value == '  All  ') { butt.value = 'None'; tF = true; }
  else  {butt.value = '  All  '; tF = false; }
  cb = eval('document.queryform.' + inputComponent);
  size = cb.length;
  for (var i=0; i<size; i++)
    cb[i].checked = tF;
}

function changeSel(dt) {
  qf = document.queryform;
  if (dt != 'state') qf.pState.selectedIndex = 0;
//  if (dt != 'cma') qf.pCMA.selectedIndex = 0;
  if (dt != 'imcra') qf.pIMCRA.selectedIndex = 0;
  if (dt != 'marinereg') qf.pMarineReg.selectedIndex = 0;
  if (dt != 'nrmzone') qf.pNRMZone.selectedIndex = 0;
  if (dt != 'lga') qf.pLGA.selectedIndex = 0;
}

function makeString() {
  var enoString = '', estCount = 1, wsdString = '';
  qf = document.queryform.pEstuary;
  el = qf.length;
  // Reset all user selectable variables
  document.queryform2.pEstuary1.value = '';
  document.queryform2.pEstuary2.value = '';
  document.queryform2.pEstuary3.value = '';
  document.queryform2.pEstuary4.value = '';
  for (i=1; i<el; i++) {
    if (qf[i].checked) enoString += qf[i].value + ',';
    // For select statement of SQL transaction must use max 4000 characters
    if (enoString.length > 3990) {
      qf2est = eval("document.queryform2.pEstuary"+estCount);
      qf2est.value = enoString;
      estCount++;
      enoString = ''; }
  }
  qf2est = eval("document.queryform2.pEstuary"+estCount);
  if (qf2est == null) alert('You must select too many checkboxes. Please try again.');
  qf2est.value = enoString;
  if (document.queryform2.pEstuary1.value.length == 0) alert('You must select at least one checkbox. Please try again.');
  else document.queryform2.submit();
  return false;
}

function clearMeasureAll() {
  qf = document.queryform;
  qf.pPerimeterLt.value = '';
  qf.pPerimeterGt.value = '';
  qf.pWaterAreaLt.value = '';
  qf.pWaterAreaGt.value = '';
  qf.pEstLengthLt.value = '';
  qf.pEstLengthGt.value = '';
  qf.pEstWidthLt.value  = '';
  qf.pEstWidthGt.value  = '';
  qf.pEntLengthLt.value = '';
  qf.pEntLengthGt.value = '';
  qf.pEntWidthLt.value  = '';
  qf.pEntWidthGt.value  = '';
}

<!-- Select or clear the check and depth boxes -->
function allNoneWSD() {
  var qf = document.queryform;
  if (qf.WSD.value == "  All  ") { chk = true; qf.WSD.value = "None"; }
  else { chk = false; qf.WSD.value = "  All  "; }
  qf.pSPPU.checked = chk;
  qf.pSPPD.value = "";
  qf.pSPPL.checked = chk;
  qf.pSCSU.checked = chk;
  qf.pSCSD.value = "";
  qf.pSCSL.checked = chk;
  qf.pSMSU.checked = chk;
  qf.pSMSD.value = "";
  qf.pSMSL.checked = chk;
  qf.pBFCH.checked = chk;
  qf.pBFCO.checked = chk;
  qf.pPWCU.checked = chk;
  qf.pPWCD.value = "";
  qf.pPWCL.checked = chk;
  qf.pWCP.checked = chk;
  qf.pWCG.checked = chk;
}

<!-- Set the appropriate value in the depth box depending on check boxes selected -->
function checkSample(db) {
  var qf = document.queryform;
  if (db == "SPP")      { box1 = qf.pSPPU; box2 = qf.pSPPL; boxText = qf.pSPPD; }
  else if (db == "SCS") { box1 = qf.pSCSU; box2 = qf.pSCSL; boxText = qf.pSCSD; }
  else if (db == "SMS") { box1 = qf.pSMSU; box2 = qf.pSMSL; boxText = qf.pSMSD; }
  else if (db == "PWC") { box1 = qf.pPWCU; box2 = qf.pPWCL; boxText = qf.pPWCD; }

  if (box1.checked && box2.checked) boxText.value = "";
  else if (!box1.checked && !box2.checked) boxText.value = "";
  else if (box1.checked || box2.checked) boxText.value = "0.2";
}

function allNoneHF_TI(divID, buttonPress){
  butt = eval('document.queryform.' + buttonPress);
  if (butt.value == '  All  ') { butt.value = 'None'; tF = true; }
  else  {butt.value = '  All  '; tF = false; }

  container = document.getElementById(divID);
  nodes = container.getElementsByTagName("input");
  // Last input is the button so do not set
  nl = nodes.length - 1;
  for (var i=0; i<nl; i++)
     nodes[i].checked = tF;
}

function submitForm(pEno,pToDo) {
  mgF = eval("document.frm"+pEno);
  mgF = eval("document.frm"+pEno);
  if (pToDo == 'malvern') {
    mgF.action = "malvern_graph.jsp";
    mgF.target = "_top"; }
  else if (pToDo == 'html') {
    // Create list of all checked WSD
    lw = mgF.pListWSD, cat = 'XXXX';
    lw.value = "";

    wsc = mgF.pSPP;
    wl = wsc.length;
    if (wl > 1) {
      for (var i=2; i<wl; i++)
        if (wsc[i].checked) {
          if (cat != "SPP") { cat = "SPP"; lw.value += "$SPP "; }
          lw.value += "''" + wsc[i].value + "'',"; }
    }

    wsc = mgF.pSCS;
    wl = wsc.length;
    if (wl > 1) {
      for (var i=2; i<wl; i++)
        if (wsc[i].checked) {
          if (cat != "SCS") { cat = "SCS"; lw.value += "$SCS "; }
          lw.value += "''" + wsc[i].value + "'',"; }
    }

    wsc = mgF.pSMS;
    wl = wsc.length;
    if (wl > 1) {
      for (var i=2; i<wl; i++)
        if (wsc[i].checked) {
          if (cat != "SMS") { cat = "SMS"; lw.value += "$SMS "; }
          lw.value += "''" + wsc[i].value + "'',"; }
    }

    wsc = mgF.pBFCH;
    wl = wsc.length;
    if (wl > 1) {
      for (var i=2; i<wl; i++)
        if (wsc[i].checked) {
          if (cat != "BFCH") { cat = "BFCH"; lw.value += "$BFCH "; }
          lw.value += "''" + wsc[i].value + "'',"; }
    }

    wsc = mgF.pBFCO;
    wl = wsc.length;
    if (wl > 1) {
      for (var i=2; i<wl; i++)
        if (wsc[i].checked) {
          if (cat != "BFCO") { cat = "BFCO"; lw.value += "$BFCO "; }
          lw.value += "''" + wsc[i].value + "'',"; }
    }

    wsc = mgF.pPWC;
    wl = wsc.length;
    if (wl > 1) {
      for (var i=2; i<wl; i++)
        if (wsc[i].checked) {
          if (cat != "PWC") { cat = "PWC"; lw.value += "$PWC "; }
          lw.value += "''" + wsc[i].value + "'',"; }
    }

    wsc = mgF.pWCP;
    wl = wsc.length;
    if (wl > 1) {
      for (var i=2; i<wl; i++)
        if (wsc[i].checked) {
          if (cat != "WCP") { cat = "WCP"; lw.value += "$WCP "; }
          lw.value += "''" + wsc[i].value + "'',"; }
    }

    wsc = mgF.pWCG;
    wl = wsc.length;
    if (wl > 1) {
      for (var i=2; i<wl; i++)
        if (wsc[i].checked) {
          if (cat != "WCG") { cat = "WCG"; lw.value += "$WCG "; }
          lw.value += "''" + wsc[i].value + "'',"; }
    }

    if (lw.value == "") {
      alert("You must select at least one checkbox. Please try again.");
      return false; }
    else {
      mgF.action = "wsd_details.jsp";
      mgF.target = "_blank"; }
    }
  else {
    mgF.pType.value = pToDo;
   mgF.action = "http://dbforms.ga.gov.au/www/npm.ozcoast2.sample_detail_report";
//     mgF.action = "http://biotite.ga.gov.au:7777/wwwstaff_dev/npm.ozcoast2.sample_detail_report";
    if (pToDo == 'csv') mgF.target = "_blank";
    else mgF.target = "_top"; }
  mgF.submit();
  return false;
}

function checkExcelS(pForm) {
  var aCat = ['SCS','SPP','WCP'];
  var aCatl = aCat.length;
  var aProp = ['As,Cl,Cu,Ni,Pb,TP,Zn,','grain size,','DO,'];
  var found = false, i = 0, cont = false;
  while (!found && i < aCatl) {
    var j = 1;
    var frmProp = eval("document.frm"+pForm+".p"+aCat[i]);
    var frmPropl = frmProp.length;
    while (!found && j < frmPropl) {
      if (!frmProp[j].checked) { j++; continue; }
      if (aProp[i].search(frmProp[j].value+",") > -1) {
        found = true;
        if (confirm("The following properties are not able to be generated by sample:\n\tSubstrate Chemistry: As,Cl,Cu,Ni,Pb,TP,Zn\n\tSubstrate Physical Properties: grain size\n\tWater Column Properties: DO\n\nDo you wish to continue?")) cont = true;
      }
      j++;
    }
    i++;
  }
  if (!found || cont) {
    frmProp = eval("document.frm"+pForm);
    frmProp.target = "_top";
    frmProp.pType.value = "excels";
//    frmProp.action = "http://dbforms.ga.gov.au/www/npm.ozcoast2.sample_detail_report";
    frmProp.action = "http://biotite.ga.gov.au:7777/wwwstaff_dev/npm.ozcoast2.sample_detail_report";
    frmProp.submit(); }
  return false;
}

function allNoneDetail(pProperty,pForm) {
  var frmprop = eval("document."+pForm+"."+pProperty);
  var frml = frmprop.length;
  var butt = eval("document."+pForm+".allNone"+pProperty);
  if (butt.value == '  All  ') { butt.value = 'None'; tF = true; }
  else  {butt.value = '  All  '; tF = false; }
  for (var i=0; i<frml; i++)
    frmprop[i].checked = tF;
}

