$(document).ready(function(){
	if($('[name=hotel_auswahl]').length == 1)
	{
		if(Hotel_ID != "")
		{
			set_hotel_value(Hotel_ID);
			set_hotel_selection(Hotel_ID);
		} else {
			set_hotel_value('');
			set_hotel_selection(0);
		}
		$('[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");
		});
	}

       // if($('.sidebar_newsletter.preset').length > 1)
	//{
		$('.sidebar_newsletter.preset').focus(function(){
			$(this).val("");
			$(this).removeClass("preset");
		});
	//}
//        $('body').attr("itemscope", "");
//        $('body').attr("itemtype","http://schema.org/WebPage");
});


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());
	$('[name=hotel_auswahl] option[value='+hotel_id+']').attr( 'selected', 'selected' );
}


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('ferien_hotel');
	} else if(ferien_hotels3512[value] == true)	{
		show_form_elements('ferien_hotel3512');
	} else {
		show_form_elements('hotel');
	}
}


function show_form_elements(ferien_hotel)
{
	if(ferien_hotel == 'ferien_hotel')
	{
/*		$('.hotel').hide();
		$('.ferien_hotel3512').hide();
		$('.ferien_hotel').css("display", "block");*/
		
		$('.hotel :input').each(function(){
			$(this).attr('title', $(this).attr('name'));
			$(this).attr('name', '');
			$(this).parent().hide();
		});
		$('.ferien_hotel3512 :input').each(function(){
			$(this).attr('title', $(this).attr('name'));
			$(this).attr('name', '');
			$(this).parent().hide();
		});
		$('.ferien_hotel :input').each(function(){
			if($(this).attr('title') != '' && !$(this).attr('name') == '')
			{
				$(this).attr('name', $(this).attr('title'));
				$(this).attr('title', '');
			}
			$(this).parent('nobr').css("display", "block");
			$(this).parent('font').css("display", "inline");
		});
	} else if(ferien_hotel == 'ferien_hotel3512') {
/*		$('.hotel').hide();
		$('.ferien_hotel').hide();
		$('.ferien_hotel3512').css("display", "block");*/

		$('.hotel :input').each(function(){
			$(this).attr('title', $(this).attr('name'));
			$(this).attr('name', '');
			$(this).parent().hide();
		});
		$('.ferien_hotel :input').each(function(){
			$(this).attr('title', $(this).attr('name'));
			$(this).attr('name', '');
			$(this).parent().hide();
		});
		$('.ferien_hotel3512 :input').each(function(){
			if($(this).attr('title') != '' && $(this).attr('name') == '')
			{
				$(this).attr('name', $(this).attr('title'));
				$(this).attr('title', '');
			}
			$(this).parent('nobr').css("display", "block");
			$(this).parent('font').css("display", "inline");
		});
	} else {
/*		$('.hotel').css("display", "block");
		$('.ferien_hotel3512').hide();
		$('.ferien_hotel').hide();*/

		$('.ferien_hotel :input').each(function(){
			$(this).attr('title', $(this).attr('name'));
			$(this).attr('name', '');
			$(this).parent().hide();
		});
		$('.ferien_hotel3512 :input').each(function(){
			$(this).attr('title', $(this).attr('name'));
			$(this).attr('name', '');
			$(this).parent().hide();
		});
		$('.hotel :input').each(function(){
			if($(this).attr('title') != '' && !$(this).attr('name') == '')
			{
				$(this).attr('name', $(this).attr('title'));
				$(this).attr('title', '');
			}
			$(this).parent('nobr').css("display", "block");
			$(this).parent('font').css("display", "inline");
		});
	}
}



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


