// JavaScript Document
var cur = 0;
var list;
var timer;
var bz = 4;
var isMSIE = /*@cc_on!@*/false; 
function FadeIn(ID,NOW,OPA,TIME,STEP) {
	name = ID; // ID名
	n = NOW; // 開始不透明度(0～100)
	o = OPA; // 終了不透明度(0～100）
	t = TIME; // 時間(0.1秒単位)
	s = STEP; // ステップ数（数値が高ければ滑らかになる)
	obj = document.getElementById(ID);
	
	// ステップ数から1ステップ辺りのタイムを取得
	time_new = t - (t % s);
	timeout = time_new / s;
	
	// ステップ数からカウント数を取得
	j = o - (o % s);
	stepcount = j / s; 
	
	// 透明度を変化させる
	/*if ( isMSIE ) {
		obj.style.filter = "alpha(opacity="+n+")";
	} else {*/
		obj.style.opacity = n / 100;
		obj.style.mozOpacity = n / 100;
	/*}*/
	
	// 目標透明度までループさせる
	n += stepcount;
	if (n <= o) {
		setTimeout("FadeIn(name,n,o,time_new,s)",timeout);
	}
}
function FadeOut(ID,NOW,OPA,TIME,STEP) {
	name = ID; // ID名
	n = NOW; // 開始不透明度(0～100)
	o = OPA; // 終了不透明度(0～100）
	t = TIME; // 時間(0.1秒単位)
	s = STEP; // ステップ数（数値が高ければ滑らかになる)
	obj = document.getElementById(ID);
	
	// ステップ数から1ステップ辺りのタイムを取得
	time_new = t - (t % s);
	timeout = time_new / s;
	time_new -= timeout;
	
	// ステップ数からカウント数を取得
	j = n - (n % s);
	stepcount = j / s;
	s--;
	
	// 透明度を変化させる
	/*if ( isMSIE ) {
		obj.style.filter = "alpha(opacity="+n+")";
	} else {*/
		obj.style.opacity = n / 100;
		obj.style.mozOpacity = n / 100;
	/*}*/
	
	// 目標透明度までループさせる
	n -= stepcount;
	if (n >= o) {
		setTimeout("FadeOut(name,n,o,time_new,s)",timeout);
	}
}

function loop_wait() {
	timer = setTimeout( next_image, 5000 );
}
function next_image() {
	last_cur = cur;
	cur = ( cur + 1 ) % list.length;
	FadeIn( list[cur].id, 0, 100, 1200, 20, { complete: loop_wait() } );
	document.getElementById(list[cur].id).style.zIndex = 4;
	document.getElementById(list[last_cur].id).style.zIndex = 3;
	for (i = 0; i < list.length; i++) {
		if ( i != cur && i != last_cur ) {
			document.getElementById(list[i].id).style.zIndex = 1;
		}
	}
}
window.onload = function() {
	list = document.getElementById('banner-box').getElementsByTagName('p');
	/*document.getElementById('ban-com1').style.display = 'none';
	document.getElementById('ban-com2').style.display = 'none';
	document.getElementById('ban-com3').style.display = 'none';
	document.getElementById('ban-com4').style.display = 'none';*/
	loop_wait();
}
function ban_view(num) {
	clearTimeout(timer);
	if ( cur != num ) {
		last_cur = cur;
		cur = num;
		FadeIn( list[cur].id, 0, 100, 250, 10 );
		document.getElementById(list[cur].id).style.zIndex = 4;
		document.getElementById(list[last_cur].id).style.zIndex = 3;
		for (i = 0; i < list.length; i++) {
			if ( i != cur && i != last_cur ) {
				document.getElementById(list[i].id).style.zIndex = 1;
			}
		}
	}
}
// IDの表示・非表示を交互に繰り返す
function ShowHide(ID, IMG1) {
	asub = document.getElementById(ID).style;
	arrow = document.getElementById(IMG1).style;
	if ( asub.display == "none" ) {
		asub.display = "block";
		arrow.backgroundImage = "url('/image/home/arrival-link-arrow2.gif')";
	} else {
		asub.display = "none";
		arrow.backgroundImage = "url('/image/home/arrival-link-arrow1.gif')";
	}
}
