﻿var photos = [];
photos[photos.length] = {"src": "teton1_grand_tetons.jpg", "caption": "1:グランドテトンの山々"};
photos[photos.length] = {"src": "teton2_mt.jpg", "caption": "2:シェーンのラストシーンを思わせる風景1"};
photos[photos.length] = {"src": "teton3_before_lawn.jpg", "caption": "3:夜明け前のグランドテトン"};
photos[photos.length] = {"src": "teton4_jackson_lake.jpg", "caption": "4:パーク内のジャクソン湖のほとりから"};
photos[photos.length] = {"src": "teton5_snake_river.jpg", "caption": "5:スネイクリバーと輝く山々"};
photos[photos.length] = {"src": "teton6_elk.jpg", "caption": "6:野生の大鹿（エルク）"};
photos[photos.length] = {"src": "teton7_mt_molan.jpg", "caption": "7:シェーンのラストシーンを思わせる風景2"};

window.onload = function() {
	var menu = document.createElement("form");
	var menulist = document.createElement("select");
	
	document.body.appendChild(menu);
	menu.appendChild(menulist);
	var options = new Array();
	var caption = document.createTextNode("選んでください");
	options[0] = document.createElement("option");
	options[0].appendChild(caption);
	menulist.appendChild(options[0]);
	for(var i = 0; i<photos.length; i++) {
		var caption = document.createTextNode(photos[i].caption);
		options[i+1] = document.createElement("option");
		options[i+1].appendChild(caption);
		menulist.appendChild(options[i+1]);
	}

	menulist.onchange = function() {
		if(!this.selectedIndex) return false;
		if(document.getElementById("photoframe")) {
			var photoframe = document.getElementById("photoframe");
		} else {
			var photoframe = document.createElement("img");
			photoframe.id = "photoframe";
			photoframe.width = "240";
			photoframe.height = "180";
			document.body.appendChild(photoframe);
		}
		photoframe.src = photos[this.selectedIndex-1].src;
	}
}

