document.observe('dom:loaded', function() {

    var processing = false;

    // SET CURRENT LINK ON THE PAGE

    $$('a').each(function(i) {
        if (i.href == location.href) {
            i.addClassName('current');
        };
    });

    //  SMOOTH SCROLL

    //  just add the class 'pageScroller' to the button you want
    //  to use to scroll in your html code.

    if ($$('.pageScroller') != null) {
        $$('.pageScroller').each(function(item) {
            Event.observe(item, 'click', function(evt) {

                Effect.Transitions.easeOutExpo = function(pos) {
                    return (pos == 1) ? 1 : -Math.pow(2, -10 * pos) + 1;
                }

                var theAnchor = item.href.split('#');

                if (theAnchor.length === 2) {
                    Event.stop(evt);

                    this._currentDestination = theAnchor[1];

                    var options = {
                        duration: 1.5,
                        transition: Effect.Transitions.easeOutExpo,
                        afterFinish: function() { processing = false; }
                    }

                    new Effect.ScrollTo(this._currentDestination, options);

                }
            });
            return false;
        });
    };

});
