// JavaScript Document

/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

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;


/*
   -----------------------------------------------------
   スムーズスクロール
   Ver. 1.0.0
   update 2009.5.17
   Copyright (C) WEB-JOZU  URL:http://www.web-jozu.com/
   -----------------------------------------------------
*/


/* ---------- 設定領域 start ---------- */

//滑らかさ（最適範囲2〜10）
//数値が大きいほど滑らかになりますが遅くなります。
smooth = 10;

//速さ（最適範囲70〜10）
//数値が小さい程早くなります。
speed = 10;

/* ---------- 設定領域 end ---------- */


function scrlWin(){

	if(distYY >= 1 || distYY <= -1){
		if(distYY > 0){
			moveYY = Math.ceil(distYY / smooth);
		}else{
			moveYY = Math.floor(distYY / smooth);
		}
		distYY -= moveYY;
		window.scrollBy(0, -moveYY);

		clearTimeout(timerId);
		timerId = setTimeout("scrlWin()", speed);
	}
}

function smScroll(ET){

	if(document.body.scrollTop){
		winYY = document.body.scrollTop;
	}else{
		winYY = document.documentElement.scrollTop;
	}

	if(window.innerHeight){
		winHH = window.innerHeight;
	}else if(document.all && document.getElementById && (document.compatMode == 'CSS1Compat')){
		winHH = document.documentElement.clientHeight;
	}else{
		winHH = document.body.clientHeight;
	}


	linkVal = "" + ET;
	linkName = linkVal.split("#");

	targetEt = document.getElementById(linkName[1]);
	targetYY = targetEt.offsetTop;
	distYY = winYY - targetYY;
	pageHH = document.body.scrollHeight;

	if(pageHH - targetYY < winHH){
		difVal = winHH - (pageHH - targetYY) - 15;
		distYY += difVal;
	}

	timerId = setTimeout("scrlWin()", speed);
}