You may not need some of this after some of the other suggestions, but I just wanted to remark that it's probably cleaner to have "var blah = document.getElementById(link);" and then reference blah thereafter, rather than calling document.getElementById() again and again.