﻿//Josh Bennett, Whittmanhart Interactive, 2007
//This uses mootools 1.11

//<'obj' class="scroll scrolToId" ....

//Example usage:
//<a href="javascript:void(0)" class="scroll scrollToMe">Move Me down</a>
//..........
//<h3 id="scrollToMe">When i click the link above it moves me here!</h3>

window.addEvent('domready', function(e){
    
    var scroll = new Fx.Scroll(window,  {wait: false, duration: 600, transition: Fx.Transitions.Quad.easeInOut} );
    
    $ES('a.scroll' ).each(function (el){
            el.removeClass('scroll');
            el.link = el.getProperty('class');
            el.addClass('scroll');

            if( $(el.link) ){
                el.addEvent('click', function(e) { 
                    lnkScrollTo( $(this).link ); 
                    $(this.link).setStyle('color', '#ed1556');
                    if(this.colorChange){ 
                        this.colorChange.stop();
                    }
                    this.colorChange = new Fx.Style(el.link, 'color', {duration:3000, transition: Fx.Transitions.Quad.easeIn}); 
                    this.colorChange.start('#ed1556', '#000000');
                });

                el.setProperty('href', 'javascript:void(0)');
            }
            else{ el.setProperty('href', 'javascript:void(0)'); }
        
    });

    //lnkScrollTo(element) -----------------------
    lnkScrollTo = function(el){
        scroll.toElement($(el));
    }
   
});
