changed it from pure css to a javascript function so it has more browser support.