$(document).ready(function(){
	if($('[name=hotel_auswahl]').length == 1)
	{
		if(Hotel_ID != "")
		{
			set_hotel_value(Hotel_ID);
			set_hotel_selection(Hotel_ID);
		}
		$('[name=hotel_auswahl]').change(function(){change_hotel_value();});
		$('.submit_fake').click(function(){show_hotel_selection_warning()});
		
		$('.header_search.preset').focus(function(){
			$(this).val("");
			$(this).removeClass("preset");
		});
	}
});


function show_hotel_selection_warning()
{
	$('.hotel_warning').show();
}


function set_hotel_selection(hotel_id)
{
	$('[name=hotel_auswahl]').val($('[name=hotel_auswahl] option[value='+hotel_id+']').text());
}


function change_hotel_value()
{
	var new_val = $('[name=hotel_auswahl]').val();
	set_hotel_value(new_val);
}


function set_hotel_value(value)
{
	if(hotels[value] != "")
	{
		$('.submit_fake').hide();
		$('.submit_real').show();
	}
	else
	{
		$('.submit_fake').show();
		$('.submit_real').hide();		
	}
	set_buchung_form_values(value, hotels[value]);
	if(ferien_hotels[value] == true)
	{
		show_form_elements(true);
	}
	else
	{
		show_form_elements(false);
	}
}


function show_form_elements(ferien_hotel)
{
	if(ferien_hotel)
	{
		$('.hotel').hide();
		$('.ferien_hotel').css("display", "block");
	}
	else
	{
		$('.hotel').css("display", "block");
		$('.ferien_hotel').hide();
	}
}



function set_buchung_form_values(hotel_id, form_address)
{
	$('[name=hotel_id]').val(hotel_id);
	$('#sidebar form').attr('action', form_address);
}

