iframe_control_fixup = function() {
    var divs = document.getElementsByTagName("div");
    for(divi in divs) {
        if(divs[divi].className == "code") {
            var iframe = divs[divi].getElementsByTagName("iframe")[0];
            var links  = divs[divi].getElementsByTagName("a");

            if(links.length == 0)
                continue; /* no control links, so nothing to do */

            /* The first link becomes active, others inactive */
            links[0].className = "active";
            for(linki = 1; linki < links.length; linki++) {
                links[linki].className = "inactive";
            }

            /* We need an array of functions which make the clicked
             * link active, and all others inactive.
             */
            adjustActiveLink = function(link) {
                link.className = "active";
                sibling_links = link.parentNode.getElementsByTagName("a");
                for(i = 0; i < sibling_links.length; i++) {
                    if(sibling_links[i] != link)
                        sibling_links[i].className = "inactive";
                }
            }

            /* Turn all links into "buttons" */
            for(linki = 0; linki < links.length; linki++) {
                links[linki].onclick = function(e) {
                    window.frames[this.target].location = this.href;
                    adjustActiveLink(this);
                    if(e.stopPropagation)
                        e.stopPropagation(); // DOM level 2 (e.g., firefox)
                    else
                        e.cancelBubble = true; // IE
                    if(e.preventDefault)
                        e.preventDefault(); // DOM level 2
                    else
                        e.returnValue = false; // IE
                    return false;
                }
            }
        }
    }
}
