////////////////////////////////////////////////
//
// util.js[ver1.3 100202]
//
////////////////////////////////////////////////

var pageScrollTimer;

$(function(){
  $('#pagetop a').click(function(){pageScroll(0,7);return false;});
});

function pageScroll(toY,frms,cuY){
  if(pageScrollTimer) clearTimeout(pageScrollTimer);
  if(!toY || toY < 0) toY = 0;
  if(!cuY) cuY = 0 + $(window).scrollTop();
  if(!frms) frms = 6;
  if((toY > cuY) && (toY > getContentsHeight() - $(window).height())){ toY = getContentsHeight() - $(window).height() +1 };
  cuY += (toY - $(window).scrollTop()) / frms;
  if(cuY < 0) cuY = 0;
  var posY = Math.floor(cuY);

  window.scrollTo(0, posY);
  if(posY != toY){ pageScrollTimer = setTimeout("pageScroll("+toY+","+frms+","+cuY+")",16); }
}

function getContentsHeight(){return ($.support.boxModel) ? $('body').height() : document.body.scrollHeight ;}
