﻿var photos = [];
photos[photos.length] = {"src": "bar1_beach.jpg", "caption": "1:バルセロナの海岸（ビーチ）"};
photos[photos.length] = {"src": "bar2_harbor.jpg", "caption": "2:バルセロナの船着場(ハーバー）"};
photos[photos.length] = {"src": "bar3_tower_columbs.jpg", "caption": "3:なぜここにあるのかコロンブスタワー"};
photos[photos.length] = {"src": "bar4_new_santamaria.jpg", "caption": "4:復元サンタマリア号（バルセロナから日本へ）"};
photos[photos.length] = {"src": "bar5_ramblas_street.jpg", "caption": "5:有名なランブラス通り"};
photos[photos.length] = {"src": "bar6_sagrada_familia.jpg", "caption": "6:ガウディの作品　サグラダ・ファミィリア（聖家族教会）"};
photos[photos.length] = {"src": "bar7_parc_grell.jpg", "caption": "7:ガウディの作品　グエル公園"};
photos[photos.length] = {"src": "bar8_casa_mila.jpg", "caption": "8:ガウディの作品　カサ・ミラ"};
photos[photos.length] = {"src": "bar9_catedral.jpg", "caption": "9:バルセロナの中心カテドラル"};
photos[photos.length] = {"src": "bar10_museu_picasso.jpg", "caption": "10:ピカソ美術館の入り口"};
photos[photos.length] = {"src": "bar11_museu_picasso2.jpg", "caption": "11:ピカソ美術館の中"};
photos[photos.length] = {"src": "bar12_cordobes_flamenco.jpg", "caption": "12:タブラオ（居酒屋）でのフラメンコショー"};

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;
	}
}

