Changing nonworking js to jQuery standards