
// ページUP
// ------------------------------------------------------------ //

function getScroll(){
	var x, y ;
	if( document.all !== void 0 ){
		x = document.body.scrollLeft ;
		y = document.body.scrollTop ;
	}else if( document.layers !== void 0 ){
		x = window.pageXOffset ;
		y = window.pageYOffset ;
	}else{
		x = window.scrollX ;
		y = window.scrollY ;
	}
	return { x : x, y : y };
}
var SCROLL ;
var divCountScroller = 25 ;
function scroller( x, y, edging, count ){
	if( count === void 0 ){
		count = 0;
		SCROLL = getScroll();
	}
	if( count++ < divCountScroller ){
		var c = count/divCountScroller ;
		var nx = SCROLL.x+( x-SCROLL.x )*( c+edging/(100*Math.PI)*Math.sin( Math.PI*c ) );
		var ny = SCROLL.y+( y-SCROLL.y )*( c+edging/(100*Math.PI)*Math.sin( Math.PI*c ) );
		window.scrollTo( nx, ny );
		setTimeout( "scroller("+x+","+y+","+edging+","+count+");", 30); //数字が小さいほど早い。
	}
}


function pageScroll() {
	var scroll = 1;
	getScroll();
	if(scroll < 50 && pageY && pageY != null) {
		pageY = (pageY > 3) ? Math.ceil(pageY * 0.2) : 1;
		scroll++;
		scrollBy(0,-pageY);
		setTimeout("pageScroll()", 20);
	} else {
		scrollTo(0, 0);
		scroll = 1;
	}
}

//　NEWウインドウオープン
// ------------------------------------------------------------ //

function subWin(Url, Name, W, H) {
	new_window = window.open(Url, Name, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" +W+ ",height=" +H) ;
}




//　NEWウインドウオープン（スクロールなし）
// ------------------------------------------------------------ //

function subWinJust(Url, Name, W, H) {
	new_window = window.open(Url, Name, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" +W+ ",height=" +H) ;
}




//　NEWウインドウオープン（アクセスマップ）
// ------------------------------------------------------------ //

function subWinMap() {
	new_window = window.open("subwin/map.html", "MAP", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=570") ;
}

function subWinMap2() {
	new_window = window.open("../subwin/map.html", "MAP", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=570") ;
}




//　NEWウインドウオープン（矯正歯科）
// ------------------------------------------------------------ //

function subWinFlow() {
	new_window = window.open("../subwin/pop_flow.html", "POP1", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=560") ;
}
function subWinPattern() {
	new_window = window.open("../subwin/pop_pattern.html", "POP2", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=480,height=500") ;
}
function subWinOption() {
	new_window = window.open("../subwin/pop_option.html", "POP3", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=500") ;
}
function subWinOption2() {
	new_window = window.open("../subwin/pop_option.html#option05", "POP3", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=500") ;
}
function subWinOption3() {
	new_window = window.open("../subwin/pop_option.html#option08", "POP3", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=500") ;
}
function subWinFirstEx() {
	new_window = window.open("../subwin/pop_first_ex.html", "POP4", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=540,height=460") ;
}






// グローバルナビゲーションの画像のプリロード
// ------------------------------------------------------------ //

//イメージのプリロード（絶対指定）
function preload() {
	var numOfBtn = 14;
	var onImgs = new Array(numOfBtn);

	for (i=0; i < 9; i++) {
		onImgs[i] = new Image();
		onImgs[i].src = "http://www.kotaromachi.com/ximage/gnav_0" + (i + 1) + "_over.gif";
	} 
	for (i=9; i < numOfBtn; i++) {
		onImgs[i] = new Image();
		onImgs[i].src = "http://www.kotaromachi.com/ximage/gnav_" + (i + 1) + "_over.gif";
	} 
}



/* ロールオーバー
_____________________________________________________*/
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;