function highlight_text(text, search) { var newText = ''; var i = -1; var lcSearch = search.toLowerCase(); var lcText = text.toLowerCase(); while (text.length > 0) { i = lcText.indexOf(lcSearch, i+1); if (i < 0) { newText += text; text = ''; } else { // skip anything inside an HTML tag if (text.lastIndexOf('>', i) >= text.lastIndexOf('<', i)) { // skip anything inside a