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

var pageScrollTimer;
$(function(){	   
$('a').each(function(){
if (($(this).attr("href") && $(this).attr("href").indexOf('#') != -1) && (($(this).attr("pathname") == location.pathname) || ('/'+$(this).attr("pathname") == location.pathname) ) && ($(this).attr("search") == location.search)){
 $(this).bind('click',function(){
	var aim = $(this).attr('href');
	aim = aim.substring(aim.lastIndexOf('#'));
	pageScroll(Math.floor($(aim).offset().top),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 ;}
