Also, I choose to respect the Dokuwiki methodology. Start hacking things and it gets messy. Also, all your changes get wiped next time there's an update. That's why I chose to rely on plugins as it's a cleaner solution.
PS just noticed the for loop as too many brackets. Should read:
jQuery(n = id+i.toString()).length
No matter how much you proof read code there's always something lol