var IstexWidget = function() {};

IstexWidget.prototype = {
    injectHTML: function() {

        var searchWidget = document.getElementById("istex-widget-search");
        var request = new XMLHttpRequest();
        request.open("GET", "http://caron.ads.intra.inist.fr:53390/html/part_search.html");
        request.onload = function() {
            searchWidget.innerHTML = request.responseText;
        };
        request.send();
    },

    injectCSS: function() {

        var header = document.head;

        var customCss = document.createElement("link");
        customCss.href = "http://caron.ads.intra.inist.fr:53390/css/part_search.css";
        customCss.rel = "stylesheet";
        customCss.type = "text/css";

        header.appendChild(customCss);

        var bootstrapCss = document.createElement("link");
        bootstrapCss.href = "//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css";
        bootstrapCss.rel = "stylesheet";
        bootstrapCss.type = "text/css";

        header.appendChild(bootstrapCss);
    }


};

var istexWidget = new IstexWidget();
istexWidget.injectHTML();
istexWidget.injectCSS();