       function process() {
        /* 
        * depending on the choice of the combobox, the search will be done 
        * in the main window or a new window will be opened 
        * (where a script will parse the url)
        */
        var searchbox_form = document.getElementById('searchbox_form');
        var index = searchbox_form.choice.options.selectedIndex;
        var id = searchbox_form.choice.options[index].id;
        var url = searchbox_form.choice.options[index].value;
        //regexp /^\d/ find a number at beginning of the string
        if (id != 'search_rubric' && id != 'search_portal' && !id.match(/^\d/)) {
            searchbox_form.submit();
            return false;
        } else {
            //var toSearch = searchbox_form.toSearch.value;
            var toSearch = document.getElementById('toSearch').value;
            url = url + toSearch;
            window.location.href = url;
            return false;
        }
      }
    
    function addInput(container, name, id, size, value) {
        /* add an INPUT to the container */
        var input = document.createElement("input");

        input.name = name;
        input.onkeypress = function() { submitOnEnter(event); };
        input.id = id;
        input.size = size;
        input.value = value;
        container.appendChild(input);
    }
    
    function addLabel(container, id, content) {
        /* add a label for the field of the given id */
        var label = document.createElement("label");

        label.htmlfor = id;
        label.appendChild(document.createTextNode(content));
        container.appendChild(label);
    }
    
    function howManyFields(varList) {
        /*
         *return the number of fields that must be generated
         *that means the count of pattern with %(..)s in the given list
        */
        var count = 0;

        for (var i = 0; i < varList.length; i++) {
            var varName = varList[i].split('=');
            var pattern = varName[1];
            if (pattern.search('%') != -1) 
                count++;
        }
        return count;
    }
    
    function getLabel(expr) {
        /*
        * given : expr -> 'arg=%(name)s'
        * return name
        */
        var varName = expr.split('=')[1];

        varName = varName.slice(2, -2);
        return varName;
    }

    function urlToFields(container, url) {
            /*
            * generate form fields in the given container by
            * parsing the given url (website.com?arg=%(name)s
            */
            var varList = url.split('?')[1];
            varList = varList.split('&');
            var fieldsCount = howManyFields(varList);
            for (var i = 0; i < varList.length; i++) {
                var varName = varList[i].split('=');
                var pattern = varName[1];
                if (pattern.search('%') != -1) {
                    var labelContent = getLabel(varList[i]);
                    if (fieldsCount > 1 || labelContent != 'text') {
                        addLabel(container, varName[0], labelContent);
                        addBr(container);
                    }
                    addInput(container, varName[0], varName[0], 16, "testo da cercare");
                    addBr(container);
                }
            }
    }
    
    function addBr(container) {
        /* create and add a br tag to the container */
        var br = document.createElement("BR");
        container.appendChild(br);
    }

    function generateForm() {
        /*
        * the generated form depends on the choice of the combobox in the form.
        * The 2 first choices are specific, the url will not be parsed.
        */
        var searchbox_fields = document.getElementById('searchbox_fields');
        var searchbox_form = document.getElementById('searchbox_form');
        var index = searchbox_form.choice.options.selectedIndex;
        var id = searchbox_form.choice.options[index].id;
        var url = searchbox_form.choice.options[index].value;
        // Save search field content for first input box
        var old_value = null;
        if (searchbox_fields.getElementsByTagName('input').length > 0){
             old_value = searchbox_fields.getElementsByTagName('input').item(0).value;
         }
        clearForm();
        // Rebuild search form for new search engine
        if (id == 'search_rubric' || id == 'search_portal' || id.match(/^\d/)) {
            addInput(searchbox_fields, 'toSearch', 'toSearch', '16',' testo da cercare');
        } else {
            urlToFields(searchbox_fields, url);
        }
        // Restore search field content for first input box
        if (old_value != null) {
            searchbox_fields.getElementsByTagName('input').item(0).value = old_value 
        }
        return true;
    }

    function clearForm() {
        /* All in the searchbox_fields DIV will be removed */
        var searchbox_form = document.getElementById('searchbox_fields');
        var childrenList = searchbox_form.childNodes;

        while(childrenList.length > 0) {
            searchbox_form.removeChild(childrenList[0]);
        }
    }

    function submitOnEnter(e) {
        var searchbox_form = document.getElementById('searchbox_form');
        if (e.which == 13)
            searchbox_form.submit();
        
        return true;
    }

