fixing javascript bug in Firefox and IE