changed element visibility check to match jQuery's :visible filter, enhancing robustness and eliminating a potential Opera bug