/************************************************************************************************* 

Used for PostCode enable Location searching on the Jobsearch page
Added:    28 March 2006
Developer:  Brent J

**************************************************************************************************/
function updateLocationSearchType(sSearchType) {
  var oLocationRadio = document.getElementById("location");
  var oLocationSelect = document.getElementById("lLocationID");
  var oPostCode = document.getElementById("sPostCode");
  var oPostCodeRadio = document.getElementById("postcodeRadio");
  var oLocationGroupCheckboxes = document.getElementsByName("lLocationGroupID");
  var oLocationCheckboxes = document.getElementsByName("lLocationID");
  var oLocationCheckboxAll = document.getElementById("lLocationIDAll");
  
  if(sSearchType == "location") {
  
    if(oLocationRadio) {
      oLocationRadio.checked = true;
    }
    if(oPostCode) {
      oPostCode.value = "";
    }
    if(oPostCodeRadio) {
      oPostCodeRadio.checked = false;
    }
  }
  else {
    if(oLocationRadio) {
      oLocationRadio.checked = false;
    }
    if(oPostCodeRadio) {
      oPostCodeRadio.checked = true;
    }
    if (oLocationSelect) {
      if (oLocationSelect.getAttribute('type') == 'select-multiple') {
        for(i = 0; i < oLocationSelect.length; i++) {
          oLocationSelect[i].selected = false;
        }
      }
      else {
      // if we get to here there is no location select box, could be in grouping mode, or in single mode
        if (oLocationCheckboxes) {
          //loop through all locations and deselect them
          for (i = 0; i < oLocationCheckboxes.length; i++) {
        	  oLocationCheckboxes[i].checked = false;
          }
        }
      
        //this means we are not in grouping mode, and all locations are under one heading, so deselect the select all
        if (oLocationCheckboxAll) {
          oLocationCheckboxAll.checked = false;
        }
        //if we get here, we are in grouping mode, so loop through all the groups and deselect them
        else {
          if (oLocationGroupCheckboxes) {
            //loop through all location groups and deselect them
            for (i = 0; i < oLocationGroupCheckboxes.length; i++) {
              oLocationGroupCheckboxes[i].checked = false;
            }
          }
        }
      }
    }
  }
}

function updateSelectAll(oSelect) {
  if(oSelect.selectedIndex == 0) {
    for(i = 1; i < oSelect.length; i++) {
      oSelect[i].selected = false;
    }
  }
}

