//==============================================================
// ScrollScript
// Original JavaScript (C) 2003 kidoguchi & fukushige
// 無断転載・配付は禁止です。
//==============================================================

//Browser Property
function getBrowserInfo(){ 
	this.majorver = parseInt(navigator.appVersion) ;
	this.agent = navigator.userAgent.toLowerCase() ;
	this.platform = navigator.platform.toLowerCase() ;
	this.mac = ( this.platform.indexOf('mac') != -1 ) ? 1 : 0 ;
	this.win = ( this.platform.indexOf('win') != -1 ) ? 1 : 0 ;

	this.dom1 = ( document.getElementById ) ? 1 : 0 ;
	this.dom2event = ( document.addEventListener && document.removeEventListener ) ? 1 : 0 ;

	this.opera = ( ( this.agent.indexOf('opera') != -1 ) || window.opera ) ? 1 : 0 ; ;
	if ( this.opera ) {
		this.opera5 = this.agent.indexOf('opera 5') ? 1 : 0 ;
		this.opera6 = this.agent.indexOf('opera 6') ? 1 : 0 ;
		this.opera7 = this.agent.indexOf('opera 7') ? 1 : 0 ;
		return this ;
	}
	this.ie = ( ( this.agent.indexOf('msie') != -1 ) && !this.opera ) ? 1 : 0 ;;
	if ( this.ie ) {
		this.ie4 = ( ( this.agent.indexOf('msie 4') != -1 ) && !this.dom1 ) ? 1 :0 ;
		this.ie5 = ( ( this.agent.indexOf('msie 5') != -1 ) && this.dom1 ) ? 1 : 0 ;
		this.ie55 = ( this.ie5 && window.createPopup ) ? 1 : 0 ;
		this.ie6 = ( ( this.agent.indexOf('msie 6') != -1 ) && this.dom1 ) ? 1 : 0 ;
		this.ie6s = ( this.ie6 && ( document.compatMode == "CSS1Compat" ) ) ? 1 : 0 ;
		this.ie4up = ( this.majorver >= 4 ) ? 1 : 0 ;
		this.ie5up = ( ( this.majorver >= 4 ) && !this.ie4 ) ? 1 : 0 ;
		this.ie55up = ( ( this.majorver >= 4 ) && !this.ie4 && !this.ie5 ) ? 1 : 0 ;
		this.ie6up = ( ( this.majorver >= 4 ) && !this.ie4 && !this.ie55 ) ? 1 : 0 ;
		return this ;
	}
	this.net = 	( ( ( this.agent.indexOf('netscape') != -1 ) || 
		( this.agent.indexOf('mozilla') != -1 ) || ( this.agent.indexOf('gecko/') != -1 ) ) && !this.opera ) ? 1 : 0 ;
	if ( this.net ) {
		this.net4 = ( document.layers && !this.dom1 ) ? 1 : 0 ;
		this.net6 = ( ( this.majorver >= 5 ) && this.dom2event ) ? 1 : 0 ;
		this.net4up = ( this.majorver >= 4 ) ? 1 : 0 ;
		this.net6up = ( ( this.majorver >= 5 ) && !this.net4 ) ? 1 : 0 ;
		return this ;
	}
	return this ;
}

	var _bw = new getBrowserInfo;




function getScrollY() {
	if( _bw.net4up || _bw.opera ) { return window.pageYOffset }
	if( _bw.ie6s ) { return document.documentElement.scrollTop }
	if( _bw.ie4up ) { return document.body.scrollTop }
	return 0;
}


//UpScroll処理

var timeID01;
var position;
var upmemory;
var nowposition01;

function Upscroll_Y(){
	position -= position * 0.2;
	nowposition01 = getScrollY();
	if( position <= 1 || nowposition01 > upmemory){
		clearTimeout(timeID01);
		if(nowposition01 > upmemory){
			window.scrollTo(0,nowposition01);
		}else{
			window.scrollTo(0,0);
		}
	}else{
		window.scrollTo(0,position);
		upmemory = Math.ceil(position);
		time_SCLL01();
	}
}


function time_SCLL01() {
	timeID01=setTimeout("Upscroll_Y()",16);
}

function SCLL() {
	upmemory = getScrollY();
	position = getScrollY();
	time_SCLL01();
}


//DownScroll処理

var timeID02;
var distance;
var point;
var move;
var downmemory;
var nowposition02;


function getobjectY(linkname,linkId) {
i = 0;
	// IE 4.0以上
	if( document.all ) { return document.all[linkId].offsetTop }
	// IE5.0 & NN6.0以上
	if( document.getElementById ) { return document.getElementById(linkId).offsetTop }
	// NN4.0
	if( document.layers ){ return document.anchors[linkname].y }
	return 0;
}

function Downscroll_Y(){
	distance = point-getScrollY();
	move += distance * 0.2;
	if( distance <= 1 || nowposition02 == dwonmemory){
		clearTimeout(timeID02);
		window.scrollTo(0,point);
	}else{
		dwonmemory = getScrollY();
		window.scrollTo(0,move);
		nowposition02 = getScrollY();
		time_SCLL02();
	}
}


function time_SCLL02() {
	timeID02=setTimeout("Downscroll_Y()",16);
}

function DownSCLL(linkname,linkId) {
	move = 0;
	dwonmemory = getScrollY();
	point = getobjectY(linkname,linkId);
	if(point==0){
		location.hash = linkname;
	}else{
	time_SCLL02();
	}
}
