Ext.override(Ext.Element, {
    update : function(html, loadScripts, callback, scope){
        html = html || "";
        
        if(loadScripts !== true){
            this.dom.innerHTML = html;
            if(Ext.isFunction(callback)){
                callback.call(scope);
            }
            return this;
        }
        
        var id = Ext.id(),
            dom = this.dom;

        html += '<span id="' + id + '"></span>';

        dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
        var DOC = document,
            hd = DOC.getElementsByTagName("head")[0],
            re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
            srcRe = /\ssrc=([\'\"])(.*?)\1/i,
            typeRe = /\stype=([\'\"])(.*?)\1/i,
            match,
            attrs,
            srcMatch,
            typeMatch,
            el,
            s;

        while(match = re.exec(html)){
            attrs = match[1];
            srcMatch = attrs ? attrs.match(srcRe) : false;
            if(srcMatch && srcMatch[2]){
               s = DOC.createElement("script");
               s.src = srcMatch[2];
               typeMatch = attrs.match(typeRe);
               if(typeMatch && typeMatch[2]){
                   s.type = typeMatch[2];
               }
               hd.appendChild(s);
            }else if(match[2] && match[2].length > 0){
                if(window.execScript) {
                   window.execScript(match[2]);
                } else {
                   window.eval(match[2]);
                }
            }
        }
        el = DOC.getElementById(id);
        if(el){
            Ext.removeNode(el);
        }
        if(Ext.isFunction(callback)){
            callback.call(scope);
        }
        return this;
    }
});
