// The page's billboard scroller.
var scroller;

$(window).addEvent("domready", function() {
    scroller = new Fx.Scroll($("content"), {
        wait:       false,
        duration:   500,
        offset:     {x: 0, y: 0},
        transition: Fx.Transitions.Quad.easeInOut
    });

    /* Examine each link to ascertain whether it's a real link or a link that
       should scroll the billboard instead (controlled by the rel attribute).
     */
    $$("a").each(function(link) {
        if (link.rel) {
            link.addEvent("click", function(e) {
                e = new Event(e).stop();
                scroller.toElement(link.rel);
                $("navigation").getElements("a").each(function(navLink) {
                    if (navLink.rel == link.rel) {
                        navLink.addClass("active");
                    }
                    else if (navLink.hasClass("active")) {
                        navLink.removeClass("active");
                    }
                });
            });
        }
    });

    var size = $(window).getSize();
    var contentHeight = size.y - $("navigation").getSize().y;
    var count = 0;

    /* We need to position each pane to avoid them overlapping. Furthermore, we
     * need to reiterate the height and width attributes for certain less
     * bright browsers. */
    $$(".pane").each(function(pane) {
        pane.setStyle("left", count++ * size.x);
        pane.setStyle("height", contentHeight);
        pane.setStyle("width", size.x);
    });

    /* And again, for the special kid in the browser classroom... (Hi,
     * Microsoft!) */
    $("content").setStyle("height", contentHeight);
    $("content").setStyle("width", size.x);
});

// vim: set cin ai ts=4 sw=4 et:
