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 product_sub_cats[val]) {
      length++;
    }
    
    if (length > 0) {
      option = document.createElement ('option');
      
      if (list_id == 'brand' || list_id == 'brand_search') {
        option.appendChild (document.createTextNode ('--Brand--'));
      } else if (list_id == 'sub_category' || list_id == 'sub_category_search') {
        option.appendChild (document.createTextNode ('--Item Type--'));
      }
      
      sub_select.appendChild (option);
      
      // add sub categories
      for (var subcat_id in product_sub_cats[val]) {
        option = document.createElement ('option');
        option.value = subcat_id;
        option.appendChild (document.createTextNode (product_sub_cats[val][subcat_id]));
        sub_select.appendChild (option);
      }
    } else {
      option = document.createElement ('option');
      option.appendChild (document.createTextNode ('N/A'));
      sub_select.appendChild (option);
    }
  }
}
