function toggleCategoryTree(elm) {
  var li = elm.parentNode;
  var img = $("li#"+li.id+" img")[0];

  // Image urls
  var tree_open = 'http://static.snipesoft.net.nz/images/icons/tree_open.gif';
  var tree_close = 'http://static.snipesoft.net.nz/images/icons/tree_close.gif';

  // Find all child categories
  var children = $("li[parent="+li.id+"]");

  // If the tree is currently open, close it
  console.log(img);

  if(img.src.toString().indexOf('tree_close.gif')!=-1) {
    children.hide();
    img.src = tree_open;
  } else {
    children.show();
    img.src = tree_close;
  } 
}