function currentScrollYPos() {
  var myYPos = 0;
  
  // Netscape and compatible browsers use the WINDOW object for
  // storing window's properties
  //
  if (navigator.appName.indexOf("Netscape")!= -1) {
    myYPos = window.pageYOffset;
  }
  else {
    // Internet Explorer 6 changed implementation of its DOM, renaming
    // document.body into document.documentElement
    //
    if (document.documentElement && document.documentElement.scrollTop) {
      myYPos = document.documentElement.scrollTop;
    }
    else {
      // This applies to older IE browsers
      myYPos = document.body.scrollTop;
    }
  }
  return myYPos;
}

function checkLocation(objTopID) {
  var myCurrentYPos = currentScrollYPos();
  objTop = document.getElementById(objTopID);
  
  // Let's show a "go to top" button, if we are far enough from the top
  if (myCurrentYPos >= 200) {
	objTop.style.display = "block";
  }
  // or hide this button, if we are too close
  else {
    if (objTop.style.display == "block") objTop.style.display = "none";
  }
 
  setTimeout("checkLocation('"+objTopID+"')", 25);
}

function smoothTop() {
  var curYPos = currentScrollYPos();

  if ( curYPos > 3 ) {
    myStepY = Math.round( curYPos / 3 );
    window.scrollBy(0,-myStepY);
    myTimeoutHandle = setTimeout('smoothTop()', 25);
  }
  else { 	
	window.scrollBy(0,-curYPos);
    clearTimeout(myTimeoutHandle);
  }
  return false;
}

window.onload = function(e) {
  checkLocation('back-to-top');
}