window.onresize = function(){
    throttle(showOrHideTopLink, window);
};

showOrHideTopLink();

function showOrHideTopLink(){
     var docEl;
     if (document.documentElement) {
         docEl = document.documentElement;
     } else {
         docEl = document.body;
     }

     var hasScrollbar = document.body.scrollHeight > docEl.clientHeight;
     //If we've got no vertical scrollbar, hide the back to top link
     var className = hasScrollbar ? "show" : "hidden";
     document.getElementById('toplink').className = className;
}

// From http://www.nczonline.net/blog/2007/11/30/the-throttle-function/ 
function throttle(method, scope) {
    clearTimeout(method._tId);
    method._tId= setTimeout(function(){
        method.call(scope);
    }, 100);
}

