+function hyperlink_field(name)
+{
+ if (name == 'md-author')
+ return 'au';
+ else if (name == 'md-subject')
+ return 'su';
+ else if (name == 'md-url')
+ return 'URL';
+ else
+ return 0;
+}
+
+function paint_details_tr(name, dn)
+{
+ //emit a table row
+ var dname = displayname(name);
+ var ln = create_element('b', dname);
+ var tln = document.createElement('td');
+ tln.setAttribute('width', 70);
+ tln.setAttribute('valign', 'top');
+ tln.appendChild(ln);
+ var tr = document.createElement('tr');
+ tr.appendChild(tln);
+ tr.appendChild(dn);
+ return tr;
+}
+
+function paint_details(body, xml)
+{
+ // This is some ugly display code. Replace with your own ting o'beauty
+ clear_cell(body);
+ //body.appendChild(document.createElement('br'));
+ var nodes = xml.childNodes[0].childNodes;
+ var i;
+ var table = document.createElement('table');
+ table.setAttribute('cellpadding', 2);
+ var dn = 0;
+ var lastname = '';
+ for (i = 0; i < nodes.length; i++)
+ {
+ if (nodes[i].nodeType != 1)
+ continue;
+ var name = nodes[i].nodeName;
+ if (name == 'recid' || name == 'md-title')
+ continue;
+ if (name != lastname)
+ {
+ if (dn)
+ {
+ var tr = paint_details_tr(lastname, dn);
+ table.appendChild(tr);
+ }
+ dn = document.createElement('td');
+ lastname = name;
+ }
+
+ if (!nodes[i].childNodes[0])
+ continue;
+ var value = nodes[i].childNodes[0].nodeValue;
+ if (dn.childNodes[0])
+ dn.appendChild(document.createTextNode('; '));
+ var hyl = hyperlink_field(name);
+ var nv;
+ if (hyl)
+ {
+ nv = create_element('a', value);
+ if (hyl == 'URL')
+ {
+ nv.setAttribute('href', value);
+ nv.setAttribute('target', '_blank');
+ }
+ else
+ {
+ nv.setAttribute('href', '#');
+ nv.setAttribute('term', value);
+ nv.setAttribute('searchfield', hyl);
+ nv.onclick = function() { hyperlink_search(this); return false; };
+ }
+ }
+ else
+ nv = document.createTextNode(value);
+ dn.appendChild(nv);
+ }
+ if (dn)
+ {
+ var tr = paint_details_tr(lastname, dn);
+ table.appendChild(tr);
+ }
+ body.appendChild(table);
+ body.style.display = 'inline';
+}
+