var preloadFlag	= false;
var orverimg	= [];

/* Header menu */
var imgroot		= "images/btn/";//画像パス
var bnames		= ["top","system","menu","introduction","access","contact"];	//メインメニュー

/*画像先読み込み用配列*/
var bfimgs		= ["top-f.gif","system-f.gif","menu-f.gif","introduction-f.gif","access-f.gif","contact-f.gif"];
var btimgs		= ["top-t.gif","system-t.gif","menu-t.gif","introduction-t.gif","access-t.gif","contact-t.gif"];

var photoroot ="";

/* イメージ関連付け */
function newImage(arg) {
	if (document.images) {
		rslt		= new Image();
		rslt.src	= arg;
		return rslt;
	}
}
/* 画像先読み */
function preloadImages() {
	if (document.images) {
		var i = 0;
		for(i = 0; i < btimgs.length; i++) {
			orverimg[i]		= newImage(imgroot + btimgs[i]);
		}
		preloadFlag = true;
	}
}

/* イメージ入れ替え */
function changeImages(id, img) {
	if (document.images && (preloadFlag == true)) {
		document.getElementById(id).src = imgroot + img;
	}
}

/* マウスオーバー */
function mover(num) {
	num	= eval(num);
	changeImages(bnames[num], btimgs[num]);
	return true;
}

/* マウスアウト */
function mout(num) {
	num	= eval(num);
	changeImages(bnames[num], bfimgs[num]);
	return true;
}



/*新規ウィンドウ*/
function openWin(file,w,h) {
	window.open(file, '', 'width=' + w + ',height=' + h + ',scrollbars=auto,resizable=yes');
}


function loadGallery() {
	if (document.images) {
		for(var i=1; i<=10; i++){
			mainphoto		= new Image();
			mainphoto.src	= "images/introduction/photo/" + i + ".jpg";
			thumbphoto		= new Image();
			thumbphoto.src	= "images/introduction/thumb/" + i + "-t.jpg";
			return rslt;
		}
	}
}

function changePhotoImages(id, img) {
	if (document.images && (preloadFlag == true)) {
		document.getElementById(id).src = photoroot + img + ".jpg";
	}
}

function photoOver(num){
	num	= eval(num);
	photoroot = "images/introduction/thumb/";
	changePhotoImages('thumb' + num , num + '-t');
	return true;
}
function photoOut(num){
	num	= eval(num);
	if(num != selectedPhoto){
		photoroot = "images/introduction/thumb/";
		changePhotoImages('thumb' + num , num + '-f');
		return true;
	}
}

var selectedPhoto = 1;
/*サムネイルクリック＆戻る進むボタンクリック時の動作*/
function changePhoto(num){
	num = eval(num);//表示する写真の番号を取得
	if(num != selectedPhoto){//現在閲覧中の写真はクリックしても動作しない
		photoroot = "images/introduction/photo/";
		changePhotoImages('photo-box',num);
		photoroot = "images/introduction/thumb/";
		changePhotoImages("thumb" + num , num + "-t");//サムネイルを表示状態に
		changePhotoImages("thumb" + selectedPhoto , selectedPhoto + "-f");//表示中のサムネイルを非表示状態に
		selectedPhoto = eval(num);//現在閲覧中に設定
	}
}

