
/***********************************************************************************
 スムーズスクロール
***********************************************************************************/

function scroll (src){
	var wh, ph;
	var ty = 0;
	if (src){
		var href = src.href.split("#");
		if ((href[1])&&(document.getElementById(href[1]))){
			ty = document.getElementById(href[1]).offsetTop;
		}
	}
	if (document.documentElement.clientHeight){
		ph = document.documentElement.clientHeight;
	}else if (document.body.clientHeight){
		ph = document.body.clientHeight;
	}else if (window.innerHeight){
		ph = window.innerHeight;
	}else{
		ph = 0;
	}
	if (document.documentElement.scrollHeight){
		wh = document.documentElement.scrollHeight;
	}else if (document.body.scrollHeight){
		wh = document.body.scrollHeight;
	}else{
		wh = 0;
	}
	if ((wh > ph)&&((ty + ph) > wh)){
		ty = wh - ph;
	}
	smooth_scroll (1,ty);
}

function smooth_scroll (flg, ty, by){
	var x, y, win, page, timer;
	if (document.documentElement.scrollTop){
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}else if (document.body.scrollTop){
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}else if (window.pageYOffset){
		x = window.pageXOffset;
		y = window.pageYOffset;
	}else{
		x = 0;
		y = 0;
	}
	if ((y == by)||(flg == 1)){
		if (y > ty){
			y -= Math.ceil((y - ty) / 7);
			if (y < ty){
				y = ty;
			}
		}else{
			y += Math.ceil((ty - y) / 7);
			if (y > ty){
				y = ty;
			}
		}
		window.scrollTo (x,y);
		if (y != ty){
			timer = setTimeout ('smooth_scroll (0,' + ty + ',' + y + ')',10);
		}
	}
}

/********************************************************************************
 画像リサイズ
********************************************************************************/

function resize(src){
	if (src){
		if ((src.height > 128)&&(src.height > src.width)){
			src.height = 128;
		}else if (src.width > 128){
			src.width = 128;
		}
	}
}


