function actionStart () {
	
	picImg  = new Image();		//写真イメージ
	copyImg  = new Image();		//キャッチコピーイメージ
	
	//フェードイン設定値ここから
	in_spd = 20;		// 透明度変化速度（m秒単位）
	in_ntc = 2;			// 何%ずつ変化させるか	
	//設定値ここまで
	
	//フェードアウト設定値ここから
	out_spd = 5;		// 透明度変化速度（m秒単位）
	out_ntc = 10;		// 何%ずつ変化させるか		
	//設定値ここまで	
	
	trsprnt = 0;
	progressFlg = 0;
	
	g_IdViser = new Array(); 	// 監視タイマーのID
	g_NumViser = 0;      		// 監視器の数
	g_i = 0;        			// グローバルカウンタ
	
	//処理進捗
	PROG_LOAD_FINISHED = 1;					//画像ロード完了
	PROG_SET_PICTURE_FINISHED = 2;			//写真イメージ設定完了
	PROG_SET_COPY_FINISHED = 3;				//キャッチコピーイメージ設定完了
	
	//画像をロード
	loadImageFile();	
	
	//写真の表示
	setViser("progressFlg==PROG_LOAD_FINISHED", "setPicture()" , 10);
	
	//写真フェードイン
	setViser("progressFlg==PROG_SET_PICTURE_FINISHED", "fdInImg('ia')" , 10);
	
	//写真フェードアウト
	setViser("100==trsprnt", "fdOutImg('ia')" , 3000);
	
	//キャッチコピーの表示
	setViser("0==trsprnt", "setCatchCopy()" , 4000);
	
	//キャッチコピーフェードイン開始
	setViser("progressFlg==PROG_SET_COPY_FINISHED", "fdInImg('ia')" , 4000);
}

//////////////////////////////////////////
// イメージファイルのロード
//////////////////////////////////////////
function loadImageFile() {
	loadPicture();
	loadCatchCopy();
	progressFlg = PROG_LOAD_FINISHED;
}

//////////////////////////////////////////
// 写真画像ファイルのロード
//////////////////////////////////////////
function loadPicture() {
	var image = new Array();
	
	image[0]='images/top/photo/p1.jpg';
	image[1]='images/top/photo/p2.jpg';
	image[2]='images/top/photo/p3.jpg';
	image[3]='images/top/photo/p4.jpg';
	image[4]='images/top/photo/p10.jpg';
	image[5]='images/top/photo/p6.jpg';
	image[6]='images/top/photo/p11.jpg';
	image[7]='images/top/photo/p8.jpg';
	image[8]='images/top/photo/p9.jpg';
	
	x=Math.floor(Math.random() * image.length);
	picImg.src = image[x];
}

//////////////////////////////////////////
// キャッチコピー画像ファイルのロード
//////////////////////////////////////////
function loadCatchCopy() {
	var copies = new Array();
	
	copies[0] = "images/top/catchCopy/c1.jpg";
	copies[1] = "images/top/catchCopy/c2.jpg";
	copies[2] = "images/top/catchCopy/c3.jpg";
	copies[3] = "images/top/catchCopy/c4.jpg";
	copies[4] = "images/top/catchCopy/c5.jpg";
	copies[5] = "images/top/catchCopy/c6.jpg";
	copies[6] = "images/top/catchCopy/c7.jpg";
	copies[7] = "images/top/catchCopy/c8.jpg";
	
	x=Math.floor(Math.random() * copies.length);
	copyImg.src = copies[x];
}

//////////////////////////////////////////
// 写真のイメージ設定
//////////////////////////////////////////
function setPicture() {
	document.ia.src = picImg.src;
	document.ia.filters['alpha'].opacity = 0;
	picImg.style.MozOpacity = 0;
	trsprnt = 0;
	progressFlg = PROG_SET_PICTURE_FINISHED;
}

//////////////////////////////////////////
// キャッチコピーのイメージ設定
//////////////////////////////////////////
function setCatchCopy() {
	document.ia.src = copyImg.src;
	document.ia.filters['alpha'].opacity = 0;
	copyImg.style.MozOpacity = 0;
	trsprnt = 0;
	progressFlg = PROG_SET_COPY_FINISHED;
}

//////////////////////////////////////////
// フェードイン
//////////////////////////////////////////
function fdInImg(imgId) {
	IMG = document.getElementById(imgId);
	trsprnt += in_ntc;
	if(trsprnt > 100) {trsprnt = 100;}
	
	document.images[imgId].filters['alpha'].opacity = trsprnt;
	//IMG.style.filter = "alpha(opacity:"+trsprnt+")";
	//IMG.style.opacity = trsprnt/100;
	IMG.style.MozOpacity = trsprnt/100;
	
	if(trsprnt == 100) {return;	}	
	setTimeout("fdInImg('"+imgId+"')",out_spd);
}

//////////////////////////////////////////
// フェードアウト
//////////////////////////////////////////
function fdOutImg(imgId) {
	IMG = document.getElementById(imgId);
	trsprnt -= out_ntc;
	if(trsprnt < 0) {trsprnt = 0;}
		
	document.images[imgId].filters['alpha'].opacity = trsprnt;
	//IMG.style.filter = "alpha(opacity:"+trsprnt+")";
	//IMG.style.opacity = trsprnt/100;
	IMG.style.MozOpacity = trsprnt/100;
	
	if(trsprnt == 0) {return;}
	setTimeout("fdOutImg('"+imgId+"')",out_spd);
}

////////////////////////////////////////////
//
// ■ ある(グローバルな)条件が満たされるまで一定間隔で監視を行い、
//    条件が満たされたら指定された処理を呼び出す関数
//
// ■ setViser( 監視する条件式(文字列) , 
//		条件が満たされとき呼び出す関数(文字列) , 
//		監視間隔)
//    ※条件式の中の変数、関数などはグローバルのものである必要があります。
//	必要に応じてグローバル変数に移しておきます。
//    ・何個も起動できます。
//
function setViser( cond , funcCall , timeVise)
{
    // 条件が満たされれば、タイマーをクリアして関数を呼び出す
    strFunc = "" +
          "if(" + cond +"){ " + 
          "clearInterval(g_IdViser[" + g_NumViser + "]);" 
          + funcCall + ";" + 
          "}";
    // 監視タイマーをセット ( setInterval)
    g_IdViser[g_NumViser] = setInterval( strFunc , timeVise);
    g_NumViser++;
}
