// Javascript functions for building and maintaining the pull down selection menus on web pages
//
// V1.0 - 2006-10-20

// Remove given item from the given SELECT menu
function deleteAnItem(theMenu,itemNo)
{
  theMenu.options[itemNo] = null;
}

// Remove all items from the given SELECT menu (except the first item)
function clearMenu(theMenu)
{
  theMenu.options[0].text='---';
  theMenu.options[0].selected = true;
  for (var i = theMenu.options.length-1;  i > 0;  i--) {
    deleteAnItem(theMenu,i);
  }
}

// Clear the menu and set the first item in menu...
function resetMenu(theMenu)
{
  clearMenu(theMenu);	
  theMenu.options[0].text='請選擇地點...';
}

// Populate menu items for Austria to the given SELECT menu
function populateAustria(theMenu)
{
  resetMenu(theMenu);	
  theMenu.options[1] = new Option("主頁", "../at/index.htm");
  theMenu.options[2] = new Option("維也納 (Vienna/Wien)", "../at/wien.htm");
  theMenu.options[3] = new Option("Hallstatt", "../at/hallstatt.htm");
  theMenu.options[0].selected = true;
}

// Populate menu items for Croatia to the given SELECT menu
function populateCroatia(theMenu)
{
  resetMenu(theMenu);	
  theMenu.options[1] = new Option("主頁", "../hr/index.htm");
  theMenu.options[2] = new Option("薩格勒布 (Zagreb)", "../hr/zagreb.htm");
  theMenu.options[3] = new Option("Dubrovnik (杜布羅夫尼克)", "../hr/dubrovnik.htm");
  theMenu.options[4] = new Option("Hvar Island", "../hr/hvar.htm");
  theMenu.options[5] = new Option("Krka National Park", "../hr/krka.htm");
  theMenu.options[6] = new Option("Plitvice N.P. (十六湖國家公園)", "../hr/plitvice.htm");
  theMenu.options[7] = new Option("Rovinj, Pula, Rijeka", "../hr/rovinj.htm");
  theMenu.options[8] = new Option("Sibenik", "../hr/sibenik.htm");
  theMenu.options[9] = new Option("Split", "../hr/split.htm");
  theMenu.options[10] = new Option("Zadar", "../hr/zadar.htm");
  theMenu.options[0].selected = true;
}

// Populate menu items for Czech to the given SELECT menu
function populateCzech(theMenu)
{
  resetMenu(theMenu);	
  theMenu.options[1] = new Option("主頁", "../cz/index.htm");
  theMenu.options[2] = new Option("布拉格 (Prague/Praha)", "../cz/praha.htm");
  theMenu.options[3] = new Option("České Budějovice", "../cz/cb.htm");
  theMenu.options[4] = new Option("Český Krumlov", "../cz/ck.htm");
  theMenu.options[5] = new Option("Kutná Hora", "../cz/kh.htm");
  theMenu.options[6] = new Option("Telč", "../cz/telc.htm");
  theMenu.options[7] = new Option("Třeboň", "../cz/trebon.htm");
  theMenu.options[0].selected = true;
}

// Populate menu items for Hungary to the given SELECT menu
function populateHungary(theMenu)
{
  resetMenu(theMenu);	
  theMenu.options[1] = new Option("主頁", "../hu/index.htm");
  theMenu.options[2] = new Option("布達佩斯 (Budapest)", "../hu/budapest.htm");
  theMenu.options[3] = new Option("Pécs", "../hu/pecs.htm");
  theMenu.options[0].selected = true;
}

// Populate menu items for Russia to the given SELECT menu
function populateRussia(theMenu)
{
  resetMenu(theMenu);	
  theMenu.options[1] = new Option("主頁", "../ru/index.htm");
  theMenu.options[2] = new Option("莫斯科 (Moscow)", "../ru/moscow.htm");
  theMenu.options[3] = new Option("聖彼得堡 (St. Petersburg)", "../ru/sptb.htm");
  theMenu.options[4] = new Option("Novgorod, Sergiev Porad", "../ru/others.htm");
  theMenu.options[0].selected = true;
}

// Populate menu items for Slovakia to the given SELECT menu
function populateSlovakia(theMenu)
{
  resetMenu(theMenu);	
  theMenu.options[1] = new Option("主頁", "../sk/index.htm");
  theMenu.options[2] = new Option("布拉迪斯拉發 (Bratislava)", "../sk/bratislava.htm");
//  theMenu.options[3] = new Option("Bratislava 的博物館", "../sk/museum.htm");
  theMenu.options[0].selected = true;
}

// Populate menu items for Slovenia to the given SELECT menu
function populateSlovenia(theMenu)
{
  resetMenu(theMenu);	
  theMenu.options[1] = new Option("主頁", "../si/index.htm");
  theMenu.options[2] = new Option("盧布爾雅那 (Ljubljana)", "../si/ljubljana.htm");
  theMenu.options[3] = new Option("Lake Bled", "../si/bled.htm");
  theMenu.options[4] = new Option("Lake Bohinj", "../si/bohinj.htm");
  theMenu.options[5] = new Option("Maribor", "../si/maribor.htm");
  theMenu.options[6] = new Option("Postojna", "../si/postojna.htm");
  theMenu.options[7] = new Option("Ptuj", "../si/ptuj.htm");
  theMenu.options[0].selected = true;
}

// Populate menu items for UK to the given SELECT menu
function populateUK(theMenu)
{
  resetMenu(theMenu);	
  theMenu.options[1] = new Option("主頁", "../uk/index.htm");
  theMenu.options[2] = new Option("倫敦 (London)", "../uk/london.htm");
  theMenu.options[3] = new Option("Bath (巴庫/巴斯/巴芙)", "../uk/bath.htm");
  theMenu.options[4] = new Option("Cambridge (劍橋)", "../uk/cam.htm");
  theMenu.options[5] = new Option("Canterbury (坎特伯雷)", "../uk/canterbury.htm");
  theMenu.options[6] = new Option("Dover (多佛)", "../uk/dover.htm");
  theMenu.options[7] = new Option("Greenwich (格林威治)", "../uk/greenwich.htm");
  theMenu.options[8] = new Option("Hampton Court", "../uk/hampton.htm");
  theMenu.options[9] = new Option("Oxford (牛津)", "../uk/oxford.htm");
  theMenu.options[10] = new Option("Windsor (溫莎)", "../uk/windsor.htm");
  theMenu.options[0].selected = true;
}

// Refresh place selection menu base on current selection of country
function refreshPlacesMenu(countryMenu, placeMenu)
{
  var idx = countryMenu.selectedIndex;
  var value = countryMenu.options[idx].value;
//  alert('selectIndex[' + idx + '] = ' + value + ', target is ' + placeMenu.name);
  switch (value) {
    case "at": populateAustria(placeMenu);
               break;
    case "cz": populateCzech(placeMenu);
               break;
    case "hr": populateCroatia(placeMenu);
               break;
    case "hu": populateHungary(placeMenu);
               break;
    case "ru": populateRussia(placeMenu);
               break;
    case "si": populateSlovenia(placeMenu);
               break;
    case "sk": populateSlovakia(placeMenu);
               break;
    case "uk": populateUK(placeMenu);
               break;
    default: clearMenu(placeMenu);
			 return;
  }
  placeMenu.focus();
}

// End of file