/*
  back-to-top: unobtrusive global 'back to top' link using mootools
  
  copyright (c) 2007 by gonchuki - http://blog.gonchuki.com
                    and Nicolas Sanguinetti - http://nicolassanguinetti.info
  
  version:	1.0.1
  released: November 11, 2007
  last modified: November 17, 2007
  
  This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.
    http://creativecommons.org/licenses/by-sa/3.0/
*/

window.addEvent('load', function(){
  new Element('span', {
    'id': 'back-to-top', 
    'styles': {'opacity': 0.6},
    'events': {'click': function() {
      if (window.location.hash) { window.location.hash = "#page"; } 
      else { window.scrollTo(0, 0); }
    }}
  })
  .appendText('TOP')
  .inject(document.body);
  
  window.addEvent('scroll', function() {
    var fn = window.getScrollTop() > (window.getHeight() * 0.3) ? "addClass" : "removeClass";
    $('back-to-top')[fn]('visible');
  });
});
