function parent(e, n){ var n = n || 1; while(n-- && e){ e = e.parentNode(); } if(!e || e.nodeType != 1){ return null; } return e; } function sibling(e, n){ while(e && n !==0){ if(n > 0){ if(e.nextElementSibling){ e = e.nextElementSibling; } else{ for(e = e.nextSibling; e && e.nodeType !== 1; e = e.nextSibling); /*empty loop*/ } n--; } else{ if(e.previousElementSibling){ e = e.previousElementSibling; } else{ for(e = e.previousSibling; e && e.nodeType !== 1; e = e.previousSibling); /*empty loop*/ } n++ } } return e; } function textContent(element, value){ var content = element.textContent; if(value !== undefined){ if(content !== undefined){ content = value; } else{ element.innerText = value; } } else{ if(content !== undefined){ return content; } else{ return element.innerText; } } } function textContent(e){ var child, type, s = ''; for(child = e.firstChild; child != null; child = child.nextSibling){ type = child.nodeType; if(type == 3 || type == 4){ s += child.nodeValue; } else if(type == 1){ s += textContent(e); } } return s; }