rewrote it.

Mixing up raw javascript and jquery just cause confusion so I rewrote it to use jquery instead of a mix of jquery and raw javascript.