﻿var photos = [];
photos[photos.length] = {"src": "es1_edinburgh_castle.jpg", "caption": "1:スコットランドの古城「エディンバラ城」を下から見る"};
photos[photos.length] = {"src": "es2_edinburgh_castle2.jpg", "caption": "2:エディンバラ城（Edinburgh　Castle　）"};
photos[photos.length] = {"src": "es3_poppy.jpg", "caption": "3:エディンバラからセントアンドリュースに向かう途中「ポピー」"};
photos[photos.length] = {"src": "es4_standrews_before_arrive.jpg", "caption": "4:到着前のセントアンドリュースの町"};
photos[photos.length] = {"src": "es5_standrews_bridge.jpg", "caption": "5:セントアンドリュース・ブリッジ"};
photos[photos.length] = {"src": "es6_standrews_clubhouse.jpg", "caption": "6:セントアンドリュースのクラブハウス"};
photos[photos.length] = {"src": "es7_standrews_18fairway.jpg", "caption": "7:セントアンドリュースの18番フェアウェイ"};
photos[photos.length] = {"src": "es8_standrews_18green_oldcourse.jpg", "caption": "8:セントアンドリュースの18番グリーン）"};
photos[photos.length] = {"src": "es9_standrews_north_beach.jpg", "caption": "9:リンクス特有の風はこの海岸から（セントアンドリュース北側の海岸）"};
photos[photos.length] = {"src": "es10_standrews_autumn.jpg", "caption": "10:暖かい秋の日のセントアンドリュースの町"};
photos[photos.length] = {"src": "es11_univercity_standrews_office.jpg", "caption": "11:スコットランド最古の大学「セントアンドリュース大学（オフィス）」"};

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;
	}
}

