Вот он
function createElement(name, attrs, style, text,past_id,position,changed) {
var parent = document.getElementsByTagName('BODY')[0];
var e = document.createElement(name);
if (attrs) {
for (key in attrs) {
if (key == 'class') {
e.className = attrs[key];
} else if (key == 'id') {
e.id = attrs[key];
} else {
e.setAttribute(key, attrs[key]);
}
}
}
if (style) {
for (key in style) {
e.style[key] = style[key];
}
}
if (text) {
e.appendChild(document.createTextNode(text));
}
parent.appendChild(e);
if(past_id){
var old_elem = document.getElementById(past_id);
if(position=='before'){
parent.insertBefore(e,old_elem)
}else if(position=='after'){
insertAfter(parent,e,old_elem);
}
if(changed!='' && changed==true){
parent.removeChild(old_elem);
}
}
}