// JavaScript Document

/* メインイメージのランダム表示 */

var imgCnt = 19;
var imgValueOpacity = 0;
var imgData = new Array(
	"images/top/001.jpg",
	"images/top/002.jpg",
	"images/top/003.jpg",
	"images/top/004.jpg",
	"images/top/005.jpg",
	"images/top/006.jpg",
	"images/top/007.jpg",
	"images/top/008.jpg",
	"images/top/009.jpg",
	"images/top/010.jpg",
	"images/top/011.jpg",
	"images/top/012.jpg",
	"images/top/013.jpg",
	"images/top/014.jpg",
	"images/top/015.jpg",
	"images/top/016.jpg",
	"images/top/017.jpg",
	"images/top/018.jpg",
	"images/top/019.jpg"
);

function xChangeImage() {
	var mainImage = document.getElementById("changeimage");
    var rnd = Math.floor(Math.random()*imgCnt);
    mainImage.src = imgData[rnd];
	xImgChangeColer();
}

function xImgChangeColer() {
	imgValueOpacity = 0;
	xImgChangeOpacity();
}
function xImgChangeOpacity() {
	if(imgValueOpacity < 10) {
		imgValueOpacity++;
		setTimeout("xImgChangeOpacity()",40);
		xImgSetOpacity();
	}
}
function xImgSetOpacity() {
	var mainImage = document.getElementById("changeimage");
	mainImage.style.filter = "alpha(opacity=" + (imgValueOpacity*10) + ")";
	mainImage.style.MozOpacity = imgValueOpacity / 10;
	mainImage.style.opacity = imgValueOpacity / 10;
}

/* ------------------------------------------------------------------- */
/* 実行部分 */

function xStartPage() {
	xChangeImage();
}
addListener(window, "load", xStartPage);
