function innerXHTML(obj, encode) {      
  if (typeof obj == "string") {
    obj = document.getElementById(obj)
  }
  
  var open = '';
  var content = '';
  var close = '';
  var tagname = obj.nodeName.toLowerCase();
  var emptytag = (obj.nodeName.match(/area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param/i)) ? true : false; 

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

  if (!emptytag) {
    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], false);
      else
        content += " ";
    }

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

        // URI encode the content if desired
  return (typeof(encode)=="undefined" || encode==true) ? encodeURIComponent(open+content+close) : open+content+close;
}
