function show_sub_category (val, list_id) {
  var sub_select = document.getElementById (list_id);
  
  if (sub_select) {
    var option;
    
    // clear existing options
    var children = sub_select.childNodes;
    while (children.length > 0) {
      sub_select.removeChild (children.item (0));
    }
    
    var length = '';
    for (var i in file_sub_cats[val]) {
      length++;
    }
    
    if (length > 0) {
      option = document.createElement ('option');
      option.appendChild (document.createTextNode ('--Sub-Category--'));
      sub_select.appendChild (option);
      
      // add sub categories
      for (var subcat_id in file_sub_cats[val]) {
        option = document.createElement ('option');
        option.value = subcat_id;
        option.appendChild (document.createTextNode (file_sub_cats[val][subcat_id]));
        sub_select.appendChild (option);
      }
    } else {
      option = document.createElement ('option');
      option.appendChild (document.createTextNode ('N/A'));
      sub_select.appendChild (option);
    }
  }
}
