User:Anakin101/addPortlet.js

function addPortlet(id, title, before) { var copy = document.getElementById('p-tb'); var div = document.createElement('div'); div.setAttribute('id', id); div.setAttribute('class', copy.getAttribute('class')); div.innerHTML = ' ' + title + ' '; var pBody = document.createElement('div'); pBody.setAttribute('class', copy.getElementsByTagName('div')[0].getAttribute('class')); pBody.appendChild(document.createElement('ul')); div.appendChild(pBody); if (before && (before = document.getElementById(before))) { copy.parentNode.insertBefore(div, before); } else { copy.parentNode.appendChild(div); }	return pBody; }