new function() {

    // Variables configurables
    var extensiones = ['doc', 'xls', 'xlw', 'ppt', 'pdf', 'rtf'];

    // Cargamos el valor de las parámetros especificos para las búsquedas
    var input_xt_mtcl = document.getElementById("xt_mtcl");
    var input_xt_npg = document.getElementById("xt_npg");

    if (input_xt_mtcl || input_xt_npg) {
        var xt_mtcl;
        var xt_npg;

        if (input_xt_mtcl) {
            xt_mtcl = input_xt_mtcl.value; //Palabra de búsqueda
        } else {
            xt_mtcl = "";
        }

        if (input_xt_npg) {
            xt_npg = input_xt_npg.value; //número de páginas de resultados. “0” cuando no haya resultados.
        } else {
            xt_npg = "";
        }

        //do not modify below
        if (window.xtparam != null) { window.xtparam += "&mc=" + xt_mtcl + "&np=" + xt_npg; }
        else { window.xtparam = "&mc=" + xt_mtcl + "&np=" + xt_npg; };
    }

    // Modificamos los enlaces a los recursos descargables para que quede constancia de las descargas de los mismos
    var filtroDescargas = new RegExp('[^?]*\\.((' + extensiones.join(')|(') + '))([?#].*)?$', 'i');
    var filtroUrlDesgarga = new RegExp('/NR/([^/]+/)+', 'i');

    function anadirEvento(elemento, nombreEvento, funcionEvento) {
        if (elemento.addEventListener) {
            elemento.addEventListener(nombreEvento, funcionEvento, false);
        } else {
            elemento.attachEvent('on' + nombreEvento, function() { funcionEvento(event); });
        }
    }

    function obtenerNombreEnlace(enlace) {
        var nombre = '';
        var finCapitulo = xtpage.lastIndexOf('::');
        if (finCapitulo >= 0) {
            finCapitulo += 2;
            nombre = nombre + xtpage.substring(0, finCapitulo);
        }
        nombre = nombre + enlace.href.replace(filtroUrlDesgarga, '/NR/.../');

        return nombre;
    }

    function generarEventoDescarga(enlace) {
        anadirEvento(enlace, 'click', function(e) {
            var nombre = obtenerNombreEnlace(enlace);
            xt_click(enlace, 'C', xtn2, nombre, 'T');
        });
    }

    top.tratarEnlaces = function(documento) {

        for (var i in documento.links) {
            var enlace = documento.links[i];

            // Se realiza la comprobacion por extension
            if (filtroDescargas.test(enlace) == true) {
                generarEventoDescarga(enlace);
            }
        }
    }

    anadirEvento(window, 'load', function(e) { top.tratarEnlaces(document); });
}

