var tabid = false;
var pagearray = ['hotel-collection', 'self-catering-collection'];

function showTabCollections(pageid)
{
	pagearray.each( function(page) {

		var tab = $(page + '-tab');
		var content = $(page);

		if ('self-catering-collection' == pageid) $('mode').value = 'self';	 else $('mode').value = 'hotel';			

		if (page == pageid)
		{
			Element.show(content);
			tab.className = "active";
		}
		else
		{
			Element.hide(content);
			tab.className = "inactive";
		}
		
	});
}

	var hotel_collections_list = new Array(); 
	var hotel_collections = new Array();
	
	var hotel_collection_regions = new Array();
	
	hotel_collections_list[0] = "Australia"; 	
	hotel_collections_list[1] = "Austria"; 	
	hotel_collections_list[2] = "Bhutan"; 	
	hotel_collections_list[3] = "Brazil"; 	
	hotel_collections_list[4] = "Canada"; 	
	hotel_collections_list[5] = "Caribbean"; 	
	hotel_collections_list[6] = "Central America"; 	
	hotel_collections_list[7] = "China"; 	
	hotel_collections_list[8] = "Cyprus"; 	
	hotel_collections_list[9] = "France"; 	
	hotel_collections_list[10] = "Greece"; 	
	hotel_collections_list[11] = "India"; 	
	hotel_collections_list[12] = "Indian Ocean"; 	
	hotel_collections_list[13] = "Indonesia"; 	
	hotel_collections_list[14] = "Ireland"; 	
	hotel_collections_list[15] = "Italy"; 	
	hotel_collections_list[16] = "Malaysia"; 	
	hotel_collections_list[17] = "Mexico"; 	
	hotel_collections_list[18] = "Morocco"; 	
	hotel_collections_list[19] = "Netherlands"; 	
	hotel_collections_list[20] = "New Zealand"; 	
	hotel_collections_list[21] = "Portugal"; 	
	hotel_collections_list[22] = "South Africa"; 	
	hotel_collections_list[23] = "Spain"; 	
	hotel_collections_list[24] = "Thailand"; 	
	hotel_collections_list[25] = "Turkey"; 	
	hotel_collections_list[26] = "United Kingdom"; 	
	hotel_collections_list[27] = "United States"; 	
	hotel_collections_list[28] = "Zambia"; 	
	hotel_collection_regions['ASIAPAC'] = new Array();
	hotel_collection_regions['ASIAPAC'][0] = new Array();
	hotel_collection_regions['ASIAPAC'][0]['name'] = 'Australia';
	hotel_collection_regions['ASIAPAC'][0]['key'] = 0;
	hotel_collection_regions['ASIAPAC'][1] = new Array();
	hotel_collection_regions['ASIAPAC'][1]['name'] = 'Bhutan';
	hotel_collection_regions['ASIAPAC'][1]['key'] = 2;
	hotel_collection_regions['ASIAPAC'][2] = new Array();
	hotel_collection_regions['ASIAPAC'][2]['name'] = 'China';
	hotel_collection_regions['ASIAPAC'][2]['key'] = 7;
	hotel_collection_regions['ASIAPAC'][3] = new Array();
	hotel_collection_regions['ASIAPAC'][3]['name'] = 'India';
	hotel_collection_regions['ASIAPAC'][3]['key'] = 11;
	hotel_collection_regions['ASIAPAC'][4] = new Array();
	hotel_collection_regions['ASIAPAC'][4]['name'] = 'Indonesia';
	hotel_collection_regions['ASIAPAC'][4]['key'] = 13;
	hotel_collection_regions['ASIAPAC'][5] = new Array();
	hotel_collection_regions['ASIAPAC'][5]['name'] = 'Malaysia';
	hotel_collection_regions['ASIAPAC'][5]['key'] = 16;
	hotel_collection_regions['ASIAPAC'][6] = new Array();
	hotel_collection_regions['ASIAPAC'][6]['name'] = 'New Zealand';
	hotel_collection_regions['ASIAPAC'][6]['key'] = 20;
	hotel_collection_regions['ASIAPAC'][7] = new Array();
	hotel_collection_regions['ASIAPAC'][7]['name'] = 'Thailand';
	hotel_collection_regions['ASIAPAC'][7]['key'] = 24;
hotel_collection_regions['EMEA'] = new Array();
	hotel_collection_regions['EMEA'][0] = new Array();
	hotel_collection_regions['EMEA'][0]['name'] = 'Austria';
	hotel_collection_regions['EMEA'][0]['key'] = 1;
	hotel_collection_regions['EMEA'][1] = new Array();
	hotel_collection_regions['EMEA'][1]['name'] = 'Cyprus';
	hotel_collection_regions['EMEA'][1]['key'] = 8;
	hotel_collection_regions['EMEA'][2] = new Array();
	hotel_collection_regions['EMEA'][2]['name'] = 'France';
	hotel_collection_regions['EMEA'][2]['key'] = 9;
	hotel_collection_regions['EMEA'][3] = new Array();
	hotel_collection_regions['EMEA'][3]['name'] = 'Greece';
	hotel_collection_regions['EMEA'][3]['key'] = 10;
	hotel_collection_regions['EMEA'][4] = new Array();
	hotel_collection_regions['EMEA'][4]['name'] = 'Ireland';
	hotel_collection_regions['EMEA'][4]['key'] = 14;
	hotel_collection_regions['EMEA'][5] = new Array();
	hotel_collection_regions['EMEA'][5]['name'] = 'Italy';
	hotel_collection_regions['EMEA'][5]['key'] = 15;
	hotel_collection_regions['EMEA'][6] = new Array();
	hotel_collection_regions['EMEA'][6]['name'] = 'Morocco';
	hotel_collection_regions['EMEA'][6]['key'] = 18;
	hotel_collection_regions['EMEA'][7] = new Array();
	hotel_collection_regions['EMEA'][7]['name'] = 'Netherlands';
	hotel_collection_regions['EMEA'][7]['key'] = 19;
	hotel_collection_regions['EMEA'][8] = new Array();
	hotel_collection_regions['EMEA'][8]['name'] = 'Portugal';
	hotel_collection_regions['EMEA'][8]['key'] = 21;
	hotel_collection_regions['EMEA'][9] = new Array();
	hotel_collection_regions['EMEA'][9]['name'] = 'South Africa';
	hotel_collection_regions['EMEA'][9]['key'] = 22;
	hotel_collection_regions['EMEA'][10] = new Array();
	hotel_collection_regions['EMEA'][10]['name'] = 'Spain';
	hotel_collection_regions['EMEA'][10]['key'] = 23;
	hotel_collection_regions['EMEA'][11] = new Array();
	hotel_collection_regions['EMEA'][11]['name'] = 'Turkey';
	hotel_collection_regions['EMEA'][11]['key'] = 25;
	hotel_collection_regions['EMEA'][12] = new Array();
	hotel_collection_regions['EMEA'][12]['name'] = 'United Kingdom';
	hotel_collection_regions['EMEA'][12]['key'] = 26;
	hotel_collection_regions['EMEA'][13] = new Array();
	hotel_collection_regions['EMEA'][13]['name'] = 'Zambia';
	hotel_collection_regions['EMEA'][13]['key'] = 28;
hotel_collection_regions['NASA'] = new Array();
	hotel_collection_regions['NASA'][0] = new Array();
	hotel_collection_regions['NASA'][0]['name'] = 'Brazil';
	hotel_collection_regions['NASA'][0]['key'] = 3;
	hotel_collection_regions['NASA'][1] = new Array();
	hotel_collection_regions['NASA'][1]['name'] = 'Canada';
	hotel_collection_regions['NASA'][1]['key'] = 4;
	hotel_collection_regions['NASA'][2] = new Array();
	hotel_collection_regions['NASA'][2]['name'] = 'Mexico';
	hotel_collection_regions['NASA'][2]['key'] = 17;
	hotel_collection_regions['NASA'][3] = new Array();
	hotel_collection_regions['NASA'][3]['name'] = 'United States';
	hotel_collection_regions['NASA'][3]['key'] = 27;
  var hotel_collection0 = new Array(); 
	hotel_collection0[0] = "Byron Bay";
	hotel_collection0[1] = "Central Coast";
	hotel_collection0[2] = "Hunter Valley";
	hotel_collection0[3] = "Kangaroo Island";
	hotel_collection0[4] = "Lord Howe Island";
	hotel_collection0[5] = "Margaret River";
	hotel_collection0[6] = "Ningaloo Reef";
	hotel_collection0[7] = "Northern Beaches";
	hotel_collection0[8] = "Queensland & Great Barrier Reef";
	hotel_collection0[9] = "Red Centre";
	hotel_collection0[10] = "Southern Forests";
	hotel_collection0[11] = "Top End";
	hotel_collections[0] = hotel_collection0;
	
  var hotel_collection1 = new Array(); 
	hotel_collection1[0] = "Zell Am See";
	hotel_collections[1] = hotel_collection1;
	
  var hotel_collection2 = new Array(); 
	hotel_collection2[0] = "Bhutan";
	hotel_collections[2] = hotel_collection2;
	
  var hotel_collection3 = new Array(); 
	hotel_collection3[0] = "Bahia";
	hotel_collection3[1] = "Rio De Janeiro";
	hotel_collections[3] = hotel_collection3;
	
  var hotel_collection4 = new Array(); 
	hotel_collection4[0] = "Toronto";
	hotel_collections[4] = hotel_collection4;
	
  var hotel_collection5 = new Array(); 
	hotel_collection5[0] = "Antigua & Barbuda";
	hotel_collection5[1] = "Barbados";
	hotel_collection5[2] = "Grenada";
	hotel_collection5[3] = "Mustique";
	hotel_collection5[4] = "St Barths";
	hotel_collection5[5] = "St Lucia";
	hotel_collection5[6] = "Turks & Caicos";
	hotel_collections[5] = hotel_collection5;
	
  var hotel_collection6 = new Array(); 
	hotel_collection6[0] = "Belize";
	hotel_collection6[1] = "Guatemala";
	hotel_collections[6] = hotel_collection6;
	
  var hotel_collection7 = new Array(); 
	hotel_collection7[0] = "Yangshuo";
	hotel_collections[7] = hotel_collection7;
	
  var hotel_collection8 = new Array(); 
	hotel_collection8[0] = "Limassol";
	hotel_collections[8] = hotel_collection8;
	
  var hotel_collection9 = new Array(); 
	hotel_collection9[0] = "Beaujolais";
	hotel_collection9[1] = "Côte D'azur (east)";
	hotel_collection9[2] = "Dordogne";
	hotel_collection9[3] = "Languedoc-Roussillon";
	hotel_collection9[4] = "Paris";
	hotel_collection9[5] = "Provence";
	hotel_collection9[6] = "St Tropez";
	hotel_collection9[7] = "Vaucluse, Provence";
	hotel_collections[9] = hotel_collection9;
	
  var hotel_collection10 = new Array(); 
	hotel_collection10[0] = "Mykonos";
	hotel_collection10[1] = "Santorini";
	hotel_collections[10] = hotel_collection10;
	
  var hotel_collection11 = new Array(); 
	hotel_collection11[0] = "Karnataka";
	hotel_collection11[1] = "Kerala";
	hotel_collections[11] = hotel_collection11;
	
  var hotel_collection12 = new Array(); 
	hotel_collection12[0] = "Maldives";
	hotel_collection12[1] = "Mauritius";
	hotel_collection12[2] = "Seychelles";
	hotel_collections[12] = hotel_collection12;
	
  var hotel_collection13 = new Array(); 
	hotel_collection13[0] = "Bali";
	hotel_collection13[1] = "Lombok";
	hotel_collection13[2] = "Yogyakarta";
	hotel_collections[13] = hotel_collection13;
	
  var hotel_collection14 = new Array(); 
	hotel_collection14[0] = "County Meath";
	hotel_collection14[1] = "Dublin";
	hotel_collections[14] = hotel_collection14;
	
  var hotel_collection15 = new Array(); 
	hotel_collection15[0] = "Aeolian Islands, Sicily";
	hotel_collection15[1] = "Amalfi Coast";
	hotel_collection15[2] = "Capri";
	hotel_collection15[3] = "Florence";
	hotel_collection15[4] = "Milan";
	hotel_collection15[5] = "Puglia";
	hotel_collection15[6] = "Rome";
	hotel_collection15[7] = "Sardinia";
	hotel_collection15[8] = "Sorrento";
	hotel_collection15[9] = "South Tyrol";
	hotel_collection15[10] = "Tuscany";
	hotel_collection15[11] = "Venice";
	hotel_collections[15] = hotel_collection15;
	
  var hotel_collection16 = new Array(); 
	hotel_collection16[0] = "Kuala Lumpur";
	hotel_collection16[1] = "Langkawi";
	hotel_collections[16] = hotel_collection16;
	
  var hotel_collection17 = new Array(); 
	hotel_collection17[0] = "Colima";
	hotel_collection17[1] = "Jalisco";
	hotel_collection17[2] = "Riviera Maya";
	hotel_collection17[3] = "Yucatán";
	hotel_collections[17] = hotel_collection17;
	
  var hotel_collection18 = new Array(); 
	hotel_collection18[0] = "Atlas Mountains";
	hotel_collection18[1] = "Essaouira";
	hotel_collection18[2] = "Marrakech";
	hotel_collection18[3] = "Ouarzazate";
	hotel_collections[18] = hotel_collection18;
	
  var hotel_collection19 = new Array(); 
	hotel_collection19[0] = "Amsterdam";
	hotel_collections[19] = hotel_collection19;
	
  var hotel_collection20 = new Array(); 
	hotel_collection20[0] = "Auckland";
	hotel_collection20[1] = "Bay Of Islands";
	hotel_collection20[2] = "Hawkes Bay";
	hotel_collection20[3] = "Kaikoura";
	hotel_collection20[4] = "Lake Taupo";
	hotel_collection20[5] = "Queenstown";
	hotel_collections[20] = hotel_collection20;
	
  var hotel_collection21 = new Array(); 
	hotel_collection21[0] = "Douro Valley";
	hotel_collections[21] = hotel_collection21;
	
  var hotel_collection22 = new Array(); 
	hotel_collection22[0] = "Cape Town";
	hotel_collection22[1] = "Garden Route & Winelands";
	hotel_collection22[2] = "Hermanus";
	hotel_collection22[3] = "Kruger National Park";
	hotel_collection22[4] = "North West Province";
	hotel_collection22[5] = "Western Limpopo";
	hotel_collections[22] = hotel_collection22;
	
  var hotel_collection23 = new Array(); 
	hotel_collection23[0] = "Barcelona";
	hotel_collection23[1] = "Empordà";
	hotel_collection23[2] = "Extremadura";
	hotel_collection23[3] = "Ibiza, Balearic Islands";
	hotel_collection23[4] = "Madrid";
	hotel_collection23[5] = "Mallorca, Balearic Islands";
	hotel_collection23[6] = "Marbella";
	hotel_collection23[7] = "Ronda, Andalucia";
	hotel_collection23[8] = "Seville Province";
	hotel_collections[23] = hotel_collection23;
	
  var hotel_collection24 = new Array(); 
	hotel_collection24[0] = "Hua Hin";
	hotel_collection24[1] = "Koh Phi Phi";
	hotel_collection24[2] = "Koh Samui";
	hotel_collection24[3] = "Krabi";
	hotel_collection24[4] = "Phuket & Khao Lak";
	hotel_collections[24] = hotel_collection24;
	
  var hotel_collection25 = new Array(); 
	hotel_collection25[0] = "Istanbul";
	hotel_collections[25] = hotel_collection25;
	
  var hotel_collection26 = new Array(); 
	hotel_collection26[0] = "Bath";
	hotel_collection26[1] = "Belfast";
	hotel_collection26[2] = "Berkshire";
	hotel_collection26[3] = "Cornwall";
	hotel_collection26[4] = "Cotswolds";
	hotel_collection26[5] = "Devon";
	hotel_collection26[6] = "Dorset";
	hotel_collection26[7] = "Edinburgh";
	hotel_collection26[8] = "Hampshire";
	hotel_collection26[9] = "Lake District";
	hotel_collection26[10] = "London";
	hotel_collection26[11] = "Norfolk";
	hotel_collection26[12] = "Northeast Somerset";
	hotel_collection26[13] = "Oxfordshire";
	hotel_collection26[14] = "Peak District";
	hotel_collection26[15] = "Wales";
	hotel_collection26[16] = "West Sussex";
	hotel_collection26[17] = "Wester Ross";
	hotel_collection26[18] = "Wiltshire";
	hotel_collections[26] = hotel_collection26;
	
  var hotel_collection27 = new Array(); 
	hotel_collection27[0] = "Berkshires";
	hotel_collection27[1] = "Los Angeles";
	hotel_collection27[2] = "Miami";
	hotel_collection27[3] = "Napa Valley";
	hotel_collection27[4] = "New York";
	hotel_collection27[5] = "Palm Springs";
	hotel_collection27[6] = "San Francisco";
	hotel_collection27[7] = "Smoky Mountains";
	hotel_collections[27] = hotel_collection27;
	
  var hotel_collection28 = new Array(); 
	hotel_collection28[0] = "Lower Zambezi";
	hotel_collections[28] = hotel_collection28;
	

function show_hotel_collections(country)
{
    var location_dd = $('location_select');
    var country_hidden = $('country_hidden');
	location_dd.options.length = 1;	
	if(country == '')
	{
		country_hidden.value = '';
	}
	else
	{		
		var option_length = hotel_collections[country].length + 1;			
		var j = 0;
		for (var i = 1; i < option_length; i++)
		{
			location_dd.options[i] 			= new Option();
			location_dd.options[i].text 	= hotel_collections[country][j];
			location_dd.options[i].value 	= hotel_collections[country][j];
			j++;
		}		
		country_hidden.value = hotel_collections_list[country];
	}
}

function show_countries_for_region(region)
{
	var region_dd = $('region_select');
	var country_dd = $('country_select');
	country_dd.options.length = 1;
	
	var regionArr = hotel_collection_regions[region_dd.value];
	var option_length = regionArr.length;
	var x = 1;
	
	if(region_dd.value == 'all')
	{
		$(hotel_collections_list).each(function(value, key)
		{
			country_dd.options[x]		= new Option();
			country_dd.options[x].text	= value;
			country_dd.options[x].value	= key;
			if(value == $('country_hidden').value)
			{
				country_dd.options[x].selected = true;
			}
			x++;
		});
	}
	else
	{
		$(regionArr).each(function(value)
		{
			country_dd.options[x]		= new Option();
			country_dd.options[x].text	= value['name'];
			country_dd.options[x].value	= value['key'];
			if(value['name'] == $('country_hidden').value)
			{
				country_dd.options[x].selected = true;
			}
			x++;
		});
	}
}

function set_country(country)
{
    var country_hidden = $('country_hidden');
	if(country == '')
	{
		country_hidden.value = '';
	}
	else
	{		
		country_hidden.value = hotel_collections_list[country];
	}
}

/*
	Event.observe(window, 'load', function() {
		hotelCollectionSubmit();

});
*/

Event.observe(window, 'load', function() {
	show_countries_for_region($('region_select').value);
});

