major overhaul/cleanup of code. Added <IE9 compatibility.