
$(document).ready(function(){
	$('#date_from').datepicker({
		dateFormat: 'dd.mm.yy',
		regional: 'de',
		changeMonth: true,
		changeYear: true,
		minDate: '+5D',
		maxDate: '01.12.' + ((new Date).getFullYear() + 1),
		onSelect: function(dateText, inst){
			if (dateText != '') {
				$('#date_to').datepicker('enable');
				$('#date_to').datepicker('option', 'minDate', dateText);
			}
			else {
				$('#date_to').datepicker('disable');
			}
		},
		beforeShowDay: checkDate,
		showOn: 'both',
		buttonImage: '../fileadmin/ang/template/img/calendar.gif',
		buttonImageOnly: true,
		buttonText: 'Anreisedatum wählen'
	});
	$('#date_to').datepicker({
		dateFormat: 'dd.mm.yy',
		regional: 'de',
		changeMonth: true,
		changeYear: true,
		minDate: '+5D',
		maxDate: '01.12.' + ((new Date).getFullYear() + 1),
		disabled: true,
		beforeShowDay: checkDate,
		showOn: 'both',
		buttonImage: '../fileadmin/ang/template/img/calendar.gif',
		buttonImageOnly: true,
		buttonText: 'Abreisedatum wählen'
	});
	
	if ($('#date_from').val() == '') {
		$('#date_to').datepicker('disable');
	}
	else {
		$('#date_to').datepicker('option', 'minDate', $('#date_from').val());
	}
	
});

function checkDate(date){
	var week_day = date.toString().substring(0, 3).toLowerCase();
	var show_day = ($('#arrival_days_' + week_day).val() == '1');
	return new Array(show_day, '', '');
}

function showFerryOptions(){
	if($('#ferry').attr('checked') == 'checked'){
		$('#ferry_options').show();
	}
	else{
		$('#ferry_options').hide();
	}
}

function showCarDimension(no_of_car){
	var car = $('#car' + no_of_car).val();
	if (car >= 1) {
		$('#div_car_dimension' + no_of_car).show();
	}
	else {
		$('#div_car_dimension' + no_of_car).hide();
	}
}

function showTrailerDimension(no_of_trailer){
	var trailer = $('#trailer' + no_of_trailer).val();
	if (trailer == 2) {
		$('#div_trailer_dimension' + no_of_trailer).show();
	}
	else {
		$('#div_trailer_dimension' + no_of_trailer).hide();
	}
}

function showFlightOptions(){
	if($('#flight').attr('checked') == 'checked'){
		$('#flight_options').show();
	}
	else{
		$('#flight_options').hide();
	}
}
