// ==UserScript==
// @name Go to Top: Fix missing top anchors
// @author Tomcat76 
// @namespace http://userjs.org/ 
// @version 1.0
// @description  Enable links using "#top" fragments to work as
//			intended, even when the page lacks a proper
//			#top anchor.
// @ujs:category general: fixes
// @ujs:published 2005-05-29 00:18
// @ujs:modified 2005-09-19 09:19
// @ujs:documentation http://userjs.org/scripts/general/fixes/go-to-top 
// @ujs:download http://userjs.org/scripts/download/general/fixes/gototop.js
// ==/UserScript==


/* 
 * This script is granted to the public domain.
 */

document.addEventListener('load',function(){
  var allAnchors=document.getElementsByTagName("a");
  var myAnchor;
  for (var i=0; myAnchor=allAnchors[i];i++){
  if( (myAnchor.hash == "#top") && (myAnchor.href.indexOf(location.href) > -1)
   && (!myAnchor.getAttribute("onclick")) && (!document.getElementById("top") )){
    myAnchor.onclick=function(){document.body.scrollTop=0;}
    }
  }
},false);

