/*
    (c) 2006 Wylovan Data Services
    http://www.wylovan.com

    $Id$
*/
function bodyOnload() {ree.evaluate();}
function Ree() {}
Ree.prototype.evaluate = function() {
    var patternLT = new RegExp("<", "gim"),
        searchText = document.getElementById('searchText').value.replace(patternLT, '&lt;'),
        pattern = new RegExp(document.getElementById('pattern').value.replace(patternLT, '&lt;'), "gim"),
        matches = searchText.match(pattern), startIndex = 0, count = 0, results = '';
    if (matches) {
        count = matches.length;
        pattern.lastIndex = 0;
        while ((result = pattern.exec(searchText)) != null) {
            results += searchText.substring(startIndex, result.index) + '<span class="match">' + result[0] + '<\/span>';
            startIndex = pattern.lastIndex;
        }
        results += searchText.substring(startIndex);
    }
    else results = searchText;
    document.getElementById('resultCount').innerHTML = 'Results: (' + count + ')';
    document.getElementById('resultsDiv').innerHTML = results;
};
var ree = new Ree();