/*━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	J3JS
	────────────────────────────
	Domain : www.worldgooddesign.net
	Name : scroll.js
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━*/

//ページの高さを取得
function pageHeight(){
	return document.body.offsetHeight;
}
//ウィンドウサイズを取得
function windowHeight(){
	if((dtctBW() == 'NS70') || (dtctBW() == 'NS71') || (dtctBW() == 'NS72') || (dtctBW() == 'FF') || (dtctBW() == 'Mozira') || (dtctBW() == 'Safari') || (dtctBW() == 'Opera') || (dtctBW() == 'Camino')) {return window.innerHeight;}
	else if(((dtctBW() == 'IE5') && (dtctOS() == 'MacOSX')) || ((dtctBW() == 'IE5') && (dtctOS() == 'Mac'))) {return document.body.clientHeight;}
	else if((dtctBW() == 'IE6') || (dtctBW() == 'IE7') || (dtctBW() == 'IE5') || (dtctBW() == 'IE55')) {return document.documentElement.clientHeight;}
}
//現在のスクロール位置の取得
function nowScrl(){
	if((dtctBW() == 'NS70') || (dtctBW() == 'NS71') || (dtctBW() == 'NS72') || (dtctBW() == 'Safari') || (dtctBW() == 'IE5') || (dtctBW() == 'IE55')) {return document.body.scrollTop;}
	else if((dtctBW() == 'IE6') || (dtctBW() == 'IE7') || (dtctBW() == 'FF') || (dtctBW() == 'Camino') || (dtctBW() == 'Mozira') || (dtctBW() == 'Opera') || (dtctBW() == 'IE55')) {return document.documentElement.scrollTop;}
}
//スクロール処理
function scrl(elementName){
	var scrlSpd = 5;//スピード設定
	if(nowScrl() != null) {
		//#削除
		if(elementName.indexOf('#') > 0){
			n = elementName.split('#')
			elementName = n[1];
		}
		//
		ElementY = document.getElementById(elementName).offsetTop;
		//ページの長さが足りないときの処理
		if(((pageHeight() - ElementY) - windowHeight()) < 0) ElementY += (pageHeight() - ElementY) - windowHeight();
		//ふわっと処理
		if((ElementY - nowScrl()) >= 0) moveNum = Math.ceil((ElementY - nowScrl()) / scrlSpd);
		else moveNum = Math.floor((ElementY - nowScrl()) / scrlSpd);
		nextY = nowScrl() + moveNum;
		if(Math.abs(ElementY - nextY) >= 0.05){
			scrollTo(0,nextY);
			setTimeout("scrl('"+elementName+"')",20);
		}else{
			scrollTo(0,ElementY);
		}
	}
}


/*━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
var scrj = 1;
function scr() {
   if(navigator.appName == "Microsoft Internet Explorer" && document.compatMode == "CSS1Compat") {
      var scdist = document.body.parentNode.scrollTop;
   } else {
      var scdist = document.body.scrollTop;
   }
   if(scrj<50 && scdist) {
      scdist = (scdist>2) ? Math.ceil(scdist*.2) : 1;
      scrj++;
      scrollBy(0,-scdist);
      setTimeout("scr()",20);
   } else {
      scrollTo(0,0);
      scrj = 1;
   }
}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━*/