function insertAfter( node, referenceNode ) {
if ( !node || !referenceNode ) return;
var parent = referenceNode.parentNode, nextSibling = referenceNode.nextSibling;
if ( nextSibling && parent ) {
parent.insertBefore(node, referenceNode.nextSibling);
} else if ( parent ) {
parent.appendChild( node );
}
}