Adjusted JS for IE7/8 support