fixed the naughty javascript

Fixed the javascript that was causing problems in every browser except Chrome (which probably fixed on the fly, sly dog Chrome you)