IE8 compatability

Script updated to work in Internet Explorer 8.