Highlighting selected text and getting the occurrence at the same time
<p>I'm new in JavaScript and is trying to write a simple highlighter tool. Each function works fine on their own, however when combining, the occurrence number doesn't work properly anymore. Here is my code, <a href="http://jsfiddle.net/mrBXu/" rel="nofollow">http://jsfiddle.net/mrBXu/</a>, the problem is when you select any "The" at the first time, the occurrence works fine, however if you re select it, it's not right anymore. Thanks ahead for helping!</p>
