var ns = "http://www.w3.org/1999/xhtml";

HTMLObjectElement.prototype.addParam = function(name, value) {
    var p = this.ownerDocument.createElementNS(ns, "param");
    p.setAttributeNS(null, "name", name);
    p.setAttributeNS(null, "value", value);
    this.appendChild(p);
};

Element.prototype.clearContentWith = function(node) {
    this.textContent = "";
    if (node) {
        this.appendChild(node);
    }
};

Document.prototype.createSilverLightObject = function(width, height, params, altnode) {
    var obj = this.createElementNS(ns, "object");
    obj.setAttributeNS(null, "type", "application/x-silverlight");
    obj.setAttributeNS(null, "width", width);
    obj.setAttributeNS(null, "height", height);
    for (var i in params) {
        obj.addParam(i, params[i]);
    }
    if (altnode) {
        obj.appendChild(altnode);
    }
    return obj;
};