Fix ID counter not incrementing.
Allow script to work before document.ready event.