//ƽĹЧ

var SmoothScroll = new Class({


 //̳Fx.Scroll

 Extends: Fx.Scroll,


 //캯,ǸFx.ScrollĹ캯

 initialize: function(options, context){
  //޶õĶ

  context = context || document;

  var doc = context.getDocument(), win = context.getWindow();
  //øFx.ScrollĹ캯

  arguments.callee.parent(doc, options);
  //ȡ

  this.links = (this.options.links) ? $$(this.options.links) : $$(doc.links);
  //ȡêĵǰҳַ

  var location = win.location.href.match(/^[^#]*/)[0] + '#';
  //,ֻêڵǰҳê

  this.links.each(function(link){
   //Ӳǵǰҳê

   if (link.href.indexOf(location) != 0) return;
   //ȡê(ֱlink.hashӦø)

   var anchor = link.href.substr(location.length);
   //ȡê,ȻΪǰ¼,ڵʱԶidֵΪêĶ

   if (anchor && $(anchor)) this.useLink(link, anchor);

  }, this);
  //Safarihack

  if (!Browser.Engine.webkit419) this.addEvent('onComplete', function(){

   win.location.hash = this.anchor;

  }, true);

 },


 //ʹõǰ,Եǰӵ¼

 useLink: function(link, anchor){
  //ӵĵ¼

  link.addEvent('click', function(event){
   //תΪ,ʹ¼ڿʹ

   this.anchor = anchor;

   //idΪanchorĶ
   this.toElement(anchor);

   //ֹ¼ðݼֵ
   event.stop();

  }.bind(this));

 }

 

});

