* @see org.w3c.dom.html.HTMLTableElement#insertRow(int)
*/
public HTMLElement insertRow(int index)
throws DOMException {
CHTMLTrElement tr = new CHTMLTrElement(ownerDocument);
HTMLCollection nl = getRows();
if (index == -1) index = nl.getLength();
if (index < 0 || index > nl.getLength()) {
throw new DOMException(DOMException.INDEX_SIZE_ERR,index+" > "+nl.getLength()+" ,array index out of bound.");
}
if (nl.getLength() == 0) {
CHTMLTbodyElement body = new CHTMLTbodyElement(ownerDocument);
appendChild(body);
body.appendChild(tr);
} else {
boolean inserted = false;
Node lastNode = null;
for (int i=0;i<nl.getLength();i++) {
Node n = nl.item(i);
if (i == index) {
n.getParentNode().insertBefore(tr,n);
inserted = true;
lastNode = null;
break;