var category_row = 'category_row';
var keywords_row = 'keywords_row';

function hideChemicals(hide){
  //if hide is passed true .. then hide the states row
  if(hide){
    ID(category_row).style.display = 'none';
  }
  else{
    ID(category_row).style.display = '';
  }

}

function hideKeywords(hide){
  //if hide is passed true .. then hide the states row
  if(hide){
    ID(keywords_row).style.display = 'none';
  }
  else{
    ID(keywords_row).style.display = '';
  }
}


function ID(id) {
  if (!document.getElementById) return false;
  return document.getElementById(id);
}

function SelectIndexByID(id) {
  s=ID(id); if (!s) return false;
  if(s.options.length==0 || !s.options.length > s.options.selectedIndex) return false;
  return s.options[s.options.selectedIndex].value;
}

function UpdateCategories(){
  var chemical = SelectIndexByID('chemical');
  
  if(chemical == '*'){
    hideChemicals(false);
    hideKeywords(false);
  }
  else{
    hideChemicals(true);
    hideKeywords(true);
  }
}

function UpdateSafeMaterials(){
  var name = SelectIndexByID('name');
  
  if(name == '*'){
    hideKeywords(false);
  }
  else{
    hideKeywords(true);
  }
}

