window.onload = setTargets;

function setTargets() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("*");
 for (var i=0; i < anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("class") && anchor.getAttribute("class").match("_blank")) {
     anchor.target = "_blank";
   }
   if (anchor.getAttribute("className") && anchor.getAttribute("className").substr(0,6) == "_blank") {
     anchor.target = "_blank";
   }
 }
}

function updateList(listNum) {
  colName = document.getElementById("column_name"+listNum);
  searchType = document.getElementById("search_type"+listNum);
  searchValue = document.getElementById("search_value"+listNum);
  if (colName.value == "fulltext") {
    searchType.options[3] = null;
    searchType.options[2] = null;
    searchType.options[1] = null;
    searchType.options[0] = null;
    searchType.options[0] = new Option("Contains word(s)","1");
    searchType.selectedIndex = 0;
  } else if (colName.value == "MS_date") {
    searchType.options[0] = null;
    searchType.options[0] = new Option("Is","3");
    searchType.options[1] = new Option("Is later than","5");
    searchType.options[2] = new Option("Is earlier than","6");
    searchType.options[3] = null;
    if (searchValue.value == 3) { searchType.selectedIndex = 0; }
    if (searchValue.value == 5) { searchType.selectedIndex = 1; }
    if (searchValue.value == 6) { searchType.selectedIndex = 2; }
  } else if (colName.value == "date") {
    searchType.options[0] = null;
    searchType.options[0] = new Option("Is","3");
    searchType.options[1] = new Option("Is later than","5");
    searchType.options[2] = new Option("Is earlier than","6");
    searchType.options[3] = null;
    if (searchValue.value == 3) { searchType.selectedIndex = 0; }
    if (searchValue.value == 5) { searchType.selectedIndex = 1; }
    if (searchValue.value == 6) { searchType.selectedIndex = 2; }
  } else if (colName.value == "plre_nbr") {
    searchType.options[0] = null;
    searchType.options[0] = new Option("Contains","1");
    searchType.options[1] = new Option("Begins with","2");
    searchType.options[3] = new Option("Exactly matches","3");
    searchType.options[2] = new Option("Does not contain","4");
    if (searchValue.value == 1) { searchType.selectedIndex = 0; }
    if (searchValue.value == 2) { searchType.selectedIndex = 1; }
    if (searchValue.value == 3) { searchType.selectedIndex = 3; }
    if (searchValue.value == 4) { searchType.selectedIndex = 2; }
  } else if (colName.value == "STC_nbr_print") {
    searchType.options[0] = null;
    searchType.options[0] = new Option("Contains","1");
    searchType.options[1] = new Option("Begins with","2");
    searchType.options[3] = new Option("Exactly matches","3");
    searchType.options[2] = new Option("Does not contain","4");
    if (searchValue.value == 1) { searchType.selectedIndex = 0; }
    if (searchValue.value == 2) { searchType.selectedIndex = 1; }
    if (searchValue.value == 3) { searchType.selectedIndex = 3; }
    if (searchValue.value == 4) { searchType.selectedIndex = 2; }
  } else {
    searchType.options[0] = null;
    searchType.options[0] = new Option("Contains","1");
    searchType.options[1] = new Option("Begins with","2");
    searchType.options[2] = new Option("Does not contain","4");
    if (searchValue.value == 1) { searchType.selectedIndex = 0; }
    if (searchValue.value == 2) { searchType.selectedIndex = 1; }
    if (searchValue.value == 4) { searchType.selectedIndex = 2; }
  }
}

function checkAll() {
  var boxes = document.getElementsByTagName("input");
  for (var i=0; i < boxes.length; i++) {
    var box = boxes[i];
    if (box.type == "checkbox") {
      box.checked = true;
    }
  }
}
function uncheckAll() {
  var boxes = document.getElementsByTagName("input");
  for (var i=0; i < boxes.length; i++) {
    var box = boxes[i];
    if (box.type == "checkbox") {
      box.checked = false;
    }
  }
}
