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] = "Belgium"; 	
	hotel_collections_list[1] = "France"; 	
	hotel_collections_list[2] = "United Kingdom"; 	
	hotel_collection_regions['EMEA'] = new Array();
	hotel_collection_regions['EMEA'][0] = new Array();
	hotel_collection_regions['EMEA'][0]['name'] = 'Belgium';
	hotel_collection_regions['EMEA'][0]['key'] = 0;
	hotel_collection_regions['EMEA'][1] = new Array();
	hotel_collection_regions['EMEA'][1]['name'] = 'France';
	hotel_collection_regions['EMEA'][1]['key'] = 1;
	hotel_collection_regions['EMEA'][2] = new Array();
	hotel_collection_regions['EMEA'][2]['name'] = 'United Kingdom';
	hotel_collection_regions['EMEA'][2]['key'] = 2;
  var hotel_collection0 = new Array(); 
	hotel_collection0[0] = "Antwerp";
	hotel_collection0[1] = "Brussels";
	hotel_collections[0] = hotel_collection0;
	
  var hotel_collection1 = new Array(); 
	hotel_collection1[0] = "Bordeaux";
	hotel_collection1[1] = "Côte D'azur (east)";
	hotel_collection1[2] = "Languedoc-Roussillon";
	hotel_collection1[3] = "Paris";
	hotel_collection1[4] = "Pays Basque";
	hotel_collections[1] = hotel_collection1;
	
  var hotel_collection2 = new Array(); 
	hotel_collection2[0] = "London";
	hotel_collections[2] = hotel_collection2;
	

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

