  var JSSearch = {
            // set standard-values
            topContainer: null,     // The topcontainer
            inputBox: null,         // The input-element
            latestSearch: "",       // A variable to ensure that the same search isn't called multiple times for different events.
            latestSearchCache: "",  // A variable to speed up searches: Say, if the elements are filtered by "fi" and the next input is "fish"
            // then only the previously selected elements needs to be traversed.
            words: [],
            countOcc: 0,

            // The search-function
            search: function() {
                // Set running-variable
                // Get content of text-box
                if (this.inputBox.value != this.latestSearch) {
                    // Make sure that this search is done once
                    if (this.latestSearch != "")
                        this.unhighlight(this.latestSearch);
                    this.latestSearch = this.inputBox.value;

                    if (this.inputBox.value != "") {
                        // Construct regex
                        words = this.inputBox.value;
                        // split words
                        if (words.constructor == String) {
                            words = words.trim().split(' ');
                        }

                        words = this.filterLetter(words);

                        if (words.length > 0) {
                            var pattern = '(' + words.join('|') + ')';
                            var regex = new RegExp(pattern, 'i');

                            // Go through each box and decide if it should be shown or not.
                            this.recurse(this.topContainer, regex);
                            // Set number of occurences
                            //                        $('numOcc').innerHTML = this.countOcc;
                        }
                    }
                    this.showHide(this.topContainer.getElements('div'), words)
                }
            },

            // unhighlights items 
            unhighlight: function(words) {
                //var selector = this.options.tag + (word ? '[rel=' + word + ']' : '');
                if (words.constructor == String) { words = words.trim().split(" "); }
                    words = this.filterLetter(words);
                    words.each(function(word) {
                        word = word.toUpperCase();
                        var elements = $$('.highlight');
                        elements.set('class', '');
                        var lstOfElementsToClean = [];
                        elements.each(function(el) {
                            lstOfElementsToClean.push(el.getParent());
                            var tn = document.createTextNode(el.get('text'));
                            el.getParent().replaceChild(tn, el);
                        });
                        lstOfElementsToClean.each(function(el) {
                            el.innerHTML = el.innerHTML.replace("\n", "");
                        });
                    }, this);
                return this;
            },

            showHide: function(elements, words) {
                elements.each(function(elem) {
                    if (words.length == 0)
                        elem.addClass('hide');
                    else {
                        // get list of highlighted elements
                        var lst = elem.getElements('.highlight');
                        var lst2 = [];
                        lst.each(function(el) {
                            lst2.include(el.getAttribute("rel"));
                        });
                        if (words.length == lst2.length)
                            elem.removeClass('hide');
                        else
                            elem.addClass('hide');
                    }
                });
            },

            filterLetter: function(words) {
                var newWords = [];
                // Make sure that each word is at least two chars long
                words.each(function(word, index) {
                    if (word.length > 1)
                        newWords.push(word);
                });
                return newWords;
            },

            // iterate recursively through html-nodes
            recurse: function(node, regex) {
                if (node.nodeType == 3) {
                    var match = node.data.match(regex);
                    if (match) {
                        // new element 
                        var highlight = new Element('span');
                        highlight.addClass('highlight');
                        var wordNode = node.splitText(match.index);
                        wordNode.splitText(match[0].length);
                        var wordClone = wordNode.cloneNode(true);
                        highlight.appendChild(wordClone);
                        wordNode.parentNode.replaceChild(highlight, wordNode);
                        highlight.set('rel', highlight.get('text').toUpperCase());
                        var comparer = highlight.get('text');
                        comparer = highlight.get('text').toUpperCase();
                        if (!this.words[comparer]) { this.words[comparer] = []; }
                        this.words[comparer].push(highlight);
                        return 1;
                    }
                } else if ((node.nodeType == 1 && node.childNodes)) {
                    for (var i = 0; i < node.childNodes.length; i++) {
                        i += this.recurse(node.childNodes[i], regex);
                    }
                }
                return 0;
            }
        };

        // After ready
        window.addEvent("domready", function() {
            // Create search-object
            ss = JSSearch;
            ss.topContainer = $("faq");
            ss.inputBox = $("search");

            // Add event-handler on search
            // Included multiple events just to be sure
            $('search').addEvents({
                'keyup': function() {
                    ss.search();
                }
                ,
                'change': function() {
                    ss.search();
                },
                'focus': function() {
                    ss.search();
                },
                'click': function() {
                    ss.search();
                }
            });
        });

