function innerXHTML(obj) {
  //if our root element has been passed in by id rather than DOM reference
  if (typeof obj == "string") {
    obj = document.getElementById(obj)
  }
  
  var open = '';
  var content = '';
  var close = '';
  var tagname = obj.nodeName.toLowerCase();
  var emptytag = (obj.nodeName.match(/img|br|hr|param|area|input|col/i)) ? true : false; 

  //write open tag
  open = '<'+tagname;
  for (var i=0; i<obj.attributes.length; i++) {
    if (obj.attributes[i].specified && obj.attributes[i].value != "null")
      open += ' '+obj.attributes[i].name+'="'+obj.attributes[i].value+'"';
  }
  open += (emptytag) ? ' />' : '>';

  if (!emptytag) {
    // write tag content
    for (var i=0; i<obj.childNodes.length; i++) {
      var node = obj.childNodes[i];
      if (node.nodeType==3)
        content += node.data;
      else if (node.nodeType==1)
        content += innerXHTML(obj.childNodes[i]);
      else
        content += " ";
    }

    //write closing tag
    close = '</'+tagname+'>';
  }

  return open+content+close;
}