/*-----------------------------------------------------------------
	scroll2top Version 0.2
	Last updated on 2003/11/28
	Copyright(c) swanq inc. All Rights Reserved.
	Script written by saz.
-----------------------------------------------------------------*/

// Sampla code
// <a href="#top" onClick="if(swScrollStart()){return false;}">

// const
var SW_SCROLL_SPD=0.36;	//scroll speed
var SW_SCROLL_INTERVAL=33;	//timer interval (msec)

// vars
var cnt;			//counter for speed test

function swScrollStart() {
	// if scrolling is possible, return true.
cnt=0;
	if(window.pageYOffset){
		// NN3 is not supported.
		window.scroll(0,Math.floor(window.pageYOffset*0.94));
		timScroll=setTimeout("swScrollNN()",SW_SCROLL_INTERVAL);
		return true;
	}else if (document.all && document.getElementById && (document.compatMode=='CSS1Compat')) {
		// ウィンドウズIE 6・標準モード。
		window.scroll(0,Math.floor(document.documentElement.scrollTop*0.94));
		timScroll=setTimeout("swScrollIE6()",SW_SCROLL_INTERVAL);
		return true;
	}else if(document.body && document.body.scrollTop){
		window.scroll(0,Math.floor(document.body.scrollTop*0.94));
		timScroll=setTimeout("swScrollIE()",SW_SCROLL_INTERVAL);
		return true;
	}else{
		return false;
	}
}

function swScrollIE6(){
	clearTimeout(timScroll);
	var y=Math.floor(document.documentElement.scrollTop*SW_SCROLL_SPD);
	if(y>0){
		// scroll main
		window.scroll(0,y);
		timScroll=setTimeout("swScrollIE6()",SW_SCROLL_INTERVAL);
	}else{
		//scroll end
		window.scroll(0,0);
	}
}
function swScrollIE(){
	clearTimeout(timScroll);
	var y=Math.floor(document.body.scrollTop*SW_SCROLL_SPD);
	if(y>0){
		// scroll main
		window.scroll(0,y);
		timScroll=setTimeout("swScrollIE()",SW_SCROLL_INTERVAL);
	}else{
		//scroll end
		window.scroll(0,0);
	}
}
function swScrollNN(){
	clearTimeout(timScroll);
	var y=Math.floor(window.pageYOffset*SW_SCROLL_SPD);
	if(y>0){
		// scroll main
		window.scroll(0,y);
		timScroll=setTimeout("swScrollNN()",SW_SCROLL_INTERVAL);
	}else{
		//scroll end
		window.scroll(0,0);
	}
}

