// injectBackToTop functionality for Decra website - İRob Fisher 2007
// Dependencies: see DecraJavaScriptDependencies.txt

window.addEvent('domready', function() {
  var scrollRatio = window.getScrollHeight()/window.getHeight();							//Calc ratio of visible : total height.

  if (scrollRatio>1.1) {
    new Element('div', {'id': 'toTop', 'class': 'floatRight'}).injectInside($('pageBG'));	//Inject an empty DIV.
    $('toTop').setHTML('<a id="toTopLink">Back to top</a>');						//Add an anchor.
	var winScroller = new Fx.Scroll(window, {												//Create Fx.Scroll object for window.
		duration: 1500, 
		wait: false, 
		transition: Fx.Transitions.bounceOut
		});
	$('toTopLink').addEvent('click', function() {winScroller.toTop();});					//Add Click event to scroll to top.
  };
});
