var SCRIPT_EXP = /<script[^>]*src="([^"]+)"[^>]*><\/script>/;

function setContent(cDiv,xmlHttp) {
    var scripts = Array();
    cDiv.innerHTML = extractScripts(xmlHttp.responseText, scripts);
    var scriptPath;
    while (scriptPath = scripts.pop()) {
        appendScript(scriptPath, cDiv);
    }
}

function extractScripts(responseText, scripts) {
    var match;
    while (match = SCRIPT_EXP.exec(responseText)) {
        scripts.push(match[1]);
        responseText = responseText.replace(match[0],'');
    }
    return responseText;
}

function appendScript(src, parentNode) {
    var scriptNode = document.createElement("script");
    scriptNode.setAttribute("type", "text/javascript");
    scriptNode.setAttribute("src", src);
    parentNode.appendChild(scriptNode);
}

function HttpObj() {
    var httpObj;
    if (window.XMLHttpRequest) {
        httpObj = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        httpObj = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return httpObj;
}
