$(document).ready(function() {
    $("#von_select_date").change(function(event) {
	if (this.value == 1) {
	    $('#VON_date_von_bis').css('display', 'block');
	    $('#VON_date_real_time').css('display', 'none');
	} else {
	    $('#VON_date_von_bis').css('display', 'none');
	    $('#VON_date_real_time').css('display', 'block');
	}
    });
    $("#von_select_date_nach").change(function(event) {
	if (this.value == 1) {
	    $('#NACH_date_von_bis').css('display', 'block');
	    $('#NACH_date_real_time').css('display', 'none');
	} else {
	    $('#NACH_date_von_bis').css('display', 'none');
	    $('#NACH_date_real_time').css('display', 'block');
	}
    });

    $("#von_land option").mouseover(function(event) {
	$('#von_land_div').html(this.value);
	$('#von_land_div').css('display', 'block');

	opt_index = parseInt($(this).index());

	if (opt_index > 19) {
	    divbox_height = $('#von_land_div').css('top').split('px');
	    new_div_box_height = parseInt(divbox_height[0])
	} else {
	    new_div_box_height = (opt_index * 15);
	}

	$('#von_land_div').css('top', new_div_box_height + 'px');

    });

    $("#von_land option").click(function(event) {
	$('#von_land_div').css('display', 'none');
    });

    $("#von_land option").mouseout(function(event) {
	$('#von_land_div').css('display', 'none');
    });

    $("#nach_land option").mouseover(function(event) {
	$('#nach_land_div').html(this.value);
	$('#nach_land_div').css('display', 'block');

	opt_index = parseInt($(this).index());

	if (opt_index > 19) {
	    divbox_height = $('#von_land_div').css('top').split('px');
	    new_div_box_height = parseInt(divbox_height[0])
	} else {
	    new_div_box_height = (opt_index * 15);
	}

	$('#nach_land_div').css('top', new_div_box_height + 'px');

    });

    $("#nach_land option").click(function(event) {
	$('#nach_land_div').css('display', 'none');
    });

    $("#nach_land option").mouseout(function(event) {
	$('#nach_land_div').css('display', 'none');
    });

    $('#datepicker').change(function() {
	$('.dt_d').val(this.value);
    })

    $('#datepicker_2').change(function() {
	$('.dt_e').val(this.value);
    })

    $('#von_wohnung').change(function() {
	if (this.value == 'haus') {
	    $('#von_etage').css('display', 'none');
	    $('#von_haus').css('display', 'none');
	    $('#von_span_etage').css('display', 'none');
	} else {
	    $('#von_etage').css('display', 'inline');
	    $('#von_haus').css('display', 'inline');
	    $('#von_span_etage').css('display', 'inline');
	}
    })

    $('#nach_wohnung').change(function() {
	if (this.value == 'haus') {
	    $('#nach_etage').css('display', 'none');
	    $('#nach_haus').css('display', 'none');
	    $('#nach_span_etage').css('display', 'none');
	} else {
	    $('#nach_etage').css('display', 'inline');
	    $('#nach_haus').css('display', 'inline');
	    $('#nach_span_etage').css('display', 'inline');
	}
    })
});

$(function() {
    $("#datepicker").datepicker();
});
$(function() {
    $("#datepicker_2").datepicker();
});
$(function() {
    $("#datepicker_3").datepicker();
});
$(function() {
    $("#datepicker_4").datepicker();
});
$(function() {
    $("#datepicker_5").datepicker();
});
$(function() {
    $("#datepicker_6").datepicker();
});
$(function() {
    $("#callback_datepicker").datepicker();
});
$(function() {
    $("#datepicker_aus").datepicker();
});
$(function() {
    $("#datepicker_ein").datepicker();
});

jQuery(function($) {
    $.datepicker.regional['de'] = {
	clearText : 'löschen',
	clearStatus : 'aktuelles Datum löschen',
	closeText : 'schließen',
	closeStatus : 'ohne Änderungen schließen',
	prevText : '&#x3c;zurück',
	prevStatus : 'letzten Monat zeigen',
	nextText : 'Vor&#x3e;',
	nextStatus : 'nächsten Monat zeigen',
	currentText : 'heute',
	currentStatus : '',
	monthNames : [ 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni',
		'Juli', 'August', 'September', 'Oktober', 'November',
		'Dezember' ],
	monthNamesShort : [ 'Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul',
		'Aug', 'Sep', 'Okt', 'Nov', 'Dez' ],
	monthStatus : 'anderen Monat anzeigen',
	yearStatus : 'anderes Jahr anzeigen',
	weekHeader : 'Wo',
	weekStatus : 'Woche des Monats',
	dayNames : [ 'Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag',
		'Freitag', 'Samstag' ],
	dayNamesShort : [ 'So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa' ],
	dayNamesMin : [ 'So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa' ],
	dayStatus : 'Setze DD als ersten Wochentag',
	dateStatus : 'Wähle D, M d',
	dateFormat : 'dd.mm.yy',
	firstDay : 1,
	initStatus : 'Wähle ein Datum',
	isRTL : false
    };
    $.datepicker.setDefaults($.datepicker.regional['de']);
});

