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] = "Central America"; 	
	hotel_collections_list[2] = "Cyprus"; 	
	hotel_collections_list[3] = "Czech Republic"; 	
	hotel_collections_list[4] = "Denmark"; 	
	hotel_collections_list[5] = "France"; 	
	hotel_collections_list[6] = "Indian Ocean"; 	
	hotel_collections_list[7] = "Indonesia"; 	
	hotel_collections_list[8] = "Italy"; 	
	hotel_collections_list[9] = "Malaysia"; 	
	hotel_collections_list[10] = "Mexico"; 	
	hotel_collections_list[11] = "Morocco"; 	
	hotel_collections_list[12] = "New Zealand"; 	
	hotel_collections_list[13] = "Portugal"; 	
	hotel_collections_list[14] = "South Africa"; 	
	hotel_collections_list[15] = "Spain"; 	
	hotel_collections_list[16] = "Thailand"; 	
	hotel_collections_list[17] = "United Kingdom"; 	
	hotel_collections_list[18] = "United States"; 	
	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'] = 'Indonesia';
	hotel_collection_regions['ASIAPAC'][1]['key'] = 7;
	hotel_collection_regions['ASIAPAC'][2] = new Array();
	hotel_collection_regions['ASIAPAC'][2]['name'] = 'Malaysia';
	hotel_collection_regions['ASIAPAC'][2]['key'] = 9;
	hotel_collection_regions['ASIAPAC'][3] = new Array();
	hotel_collection_regions['ASIAPAC'][3]['name'] = 'New Zealand';
	hotel_collection_regions['ASIAPAC'][3]['key'] = 12;
	hotel_collection_regions['ASIAPAC'][4] = new Array();
	hotel_collection_regions['ASIAPAC'][4]['name'] = 'Thailand';
	hotel_collection_regions['ASIAPAC'][4]['key'] = 16;
hotel_collection_regions['EMEA'] = new Array();
	hotel_collection_regions['EMEA'][0] = new Array();
	hotel_collection_regions['EMEA'][0]['name'] = 'Cyprus';
	hotel_collection_regions['EMEA'][0]['key'] = 2;
	hotel_collection_regions['EMEA'][1] = new Array();
	hotel_collection_regions['EMEA'][1]['name'] = 'Czech Republic';
	hotel_collection_regions['EMEA'][1]['key'] = 3;
	hotel_collection_regions['EMEA'][2] = new Array();
	hotel_collection_regions['EMEA'][2]['name'] = 'Denmark';
	hotel_collection_regions['EMEA'][2]['key'] = 4;
	hotel_collection_regions['EMEA'][3] = new Array();
	hotel_collection_regions['EMEA'][3]['name'] = 'France';
	hotel_collection_regions['EMEA'][3]['key'] = 5;
	hotel_collection_regions['EMEA'][4] = new Array();
	hotel_collection_regions['EMEA'][4]['name'] = 'Italy';
	hotel_collection_regions['EMEA'][4]['key'] = 8;
	hotel_collection_regions['EMEA'][5] = new Array();
	hotel_collection_regions['EMEA'][5]['name'] = 'Morocco';
	hotel_collection_regions['EMEA'][5]['key'] = 11;
	hotel_collection_regions['EMEA'][6] = new Array();
	hotel_collection_regions['EMEA'][6]['name'] = 'Portugal';
	hotel_collection_regions['EMEA'][6]['key'] = 13;
	hotel_collection_regions['EMEA'][7] = new Array();
	hotel_collection_regions['EMEA'][7]['name'] = 'South Africa';
	hotel_collection_regions['EMEA'][7]['key'] = 14;
	hotel_collection_regions['EMEA'][8] = new Array();
	hotel_collection_regions['EMEA'][8]['name'] = 'Spain';
	hotel_collection_regions['EMEA'][8]['key'] = 15;
	hotel_collection_regions['EMEA'][9] = new Array();
	hotel_collection_regions['EMEA'][9]['name'] = 'United Kingdom';
	hotel_collection_regions['EMEA'][9]['key'] = 17;
hotel_collection_regions['NASA'] = new Array();
	hotel_collection_regions['NASA'][0] = new Array();
	hotel_collection_regions['NASA'][0]['name'] = 'Mexico';
	hotel_collection_regions['NASA'][0]['key'] = 10;
	hotel_collection_regions['NASA'][1] = new Array();
	hotel_collection_regions['NASA'][1]['name'] = 'United States';
	hotel_collection_regions['NASA'][1]['key'] = 18;
  var hotel_collection0 = new Array(); 
	hotel_collection0[0] = "Blue Mountains";
	hotel_collection0[1] = "Central Coast";
	hotel_collection0[2] = "Clare Valley";
	hotel_collection0[3] = "Hobart";
	hotel_collection0[4] = "Kangaroo Island";
	hotel_collection0[5] = "Launceston";
	hotel_collection0[6] = "Lord Howe Island";
	hotel_collection0[7] = "Melbourne";
	hotel_collection0[8] = "Northern Beaches";
	hotel_collection0[9] = "Queensland & Great Barrier Reef";
	hotel_collection0[10] = "The Grampians";
	hotel_collections[0] = hotel_collection0;
	
  var hotel_collection1 = new Array(); 
	hotel_collection1[0] = "Belize";
	hotel_collections[1] = hotel_collection1;
	
  var hotel_collection2 = new Array(); 
	hotel_collection2[0] = "Limassol";
	hotel_collections[2] = hotel_collection2;
	
  var hotel_collection3 = new Array(); 
	hotel_collection3[0] = "Tábor";
	hotel_collections[3] = hotel_collection3;
	
  var hotel_collection4 = new Array(); 
	hotel_collection4[0] = "Copenhagen";
	hotel_collections[4] = hotel_collection4;
	
  var hotel_collection5 = new Array(); 
	hotel_collection5[0] = "Brittany";
	hotel_collection5[1] = "Dordogne";
	hotel_collection5[2] = "Normandy";
	hotel_collection5[3] = "Paris";
	hotel_collections[5] = hotel_collection5;
	
  var hotel_collection6 = new Array(); 
	hotel_collection6[0] = "Seychelles";
	hotel_collections[6] = hotel_collection6;
	
  var hotel_collection7 = new Array(); 
	hotel_collection7[0] = "Bali";
	hotel_collection7[1] = "Sumba";
	hotel_collection7[2] = "Yogyakarta";
	hotel_collections[7] = hotel_collection7;
	
  var hotel_collection8 = new Array(); 
	hotel_collection8[0] = "Florence";
	hotel_collection8[1] = "Puglia";
	hotel_collection8[2] = "Rome";
	hotel_collection8[3] = "Tuscany";
	hotel_collections[8] = hotel_collection8;
	
  var hotel_collection9 = new Array(); 
	hotel_collection9[0] = "Langkawi";
	hotel_collections[9] = hotel_collection9;
	
  var hotel_collection10 = new Array(); 
	hotel_collection10[0] = "Colima";
	hotel_collection10[1] = "Riviera Maya";
	hotel_collections[10] = hotel_collection10;
	
  var hotel_collection11 = new Array(); 
	hotel_collection11[0] = "Essaouira";
	hotel_collection11[1] = "Marrakech";
	hotel_collections[11] = hotel_collection11;
	
  var hotel_collection12 = new Array(); 
	hotel_collection12[0] = "Auckland";
	hotel_collection12[1] = "Bay Of Islands";
	hotel_collection12[2] = "Hawkes Bay";
	hotel_collection12[3] = "Kaikoura";
	hotel_collection12[4] = "Lake Taupo";
	hotel_collection12[5] = "Queenstown";
	hotel_collection12[6] = "Wairarapa";
	hotel_collection12[7] = "Wellington";
	hotel_collections[12] = hotel_collection12;
	
  var hotel_collection13 = new Array(); 
	hotel_collection13[0] = "Douro Valley";
	hotel_collections[13] = hotel_collection13;
	
  var hotel_collection14 = new Array(); 
	hotel_collection14[0] = "Cape Town";
	hotel_collection14[1] = "Garden Route & Winelands";
	hotel_collections[14] = hotel_collection14;
	
  var hotel_collection15 = new Array(); 
	hotel_collection15[0] = "Ibiza, Balearic Islands";
	hotel_collection15[1] = "Ronda, Andalucia";
	hotel_collections[15] = hotel_collection15;
	
  var hotel_collection16 = new Array(); 
	hotel_collection16[0] = "Bangkok";
	hotel_collection16[1] = "Koh Samui";
	hotel_collections[16] = hotel_collection16;
	
  var hotel_collection17 = new Array(); 
	hotel_collection17[0] = "Belfast";
	hotel_collection17[1] = "Berkshire";
	hotel_collection17[2] = "Cardigan Bay";
	hotel_collection17[3] = "Cornwall";
	hotel_collection17[4] = "Cotswolds";
	hotel_collection17[5] = "Devon";
	hotel_collection17[6] = "Dorset";
	hotel_collection17[7] = "East Sussex";
	hotel_collection17[8] = "Edinburgh";
	hotel_collection17[9] = "Hampshire";
	hotel_collection17[10] = "Liverpool";
	hotel_collection17[11] = "London";
	hotel_collection17[12] = "Norfolk";
	hotel_collection17[13] = "North Yorkshire";
	hotel_collection17[14] = "Northeast Somerset";
	hotel_collection17[15] = "Oxfordshire";
	hotel_collection17[16] = "Suffolk";
	hotel_collection17[17] = "Wales";
	hotel_collection17[18] = "West Sussex";
	hotel_collection17[19] = "Wiltshire";
	hotel_collection17[20] = "Worcestershire";
	hotel_collections[17] = hotel_collection17;
	
  var hotel_collection18 = new Array(); 
	hotel_collection18[0] = "Hamptons";
	hotel_collection18[1] = "Los Angeles";
	hotel_collection18[2] = "Napa Valley";
	hotel_collection18[3] = "Palm Springs";
	hotel_collection18[4] = "Smoky Mountains";
	hotel_collections[18] = hotel_collection18;
	

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);
});

