$(document).ready(function () { function pxcChangeDate(mode, dateInput) { var timeInput = dateInput.data('timeinput'); if (!timeInput) { timeInput = "#CalendarEntriesTime"; } timeInput = $(timeInput); var value = dateInput.val(); if (value != "") { if (dateInput.data('loadingval') != value) { dateInput.data('loadingval', value); dateInput.removeClass("input-validation-error"); loadTimes(timeInput, value); } } else { timeInput .prop('disabled', true) .html('') .removeClass("input-validation-error"); dateInput .removeClass("input-validation-error"); } $(".error").hide(); } function loadTimes(timeInput, value) { timeInput.attr('disabled', true); var format = timeInput.data("format") ? timeInput.data("format") : ""; var modelId = -1; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "http://www.toefi.de/de/wto.html?path=Home%2FListCalenderentries&request=json", data: '{"selectedDate": "' + value + '", "format": "' + format + '"}', dataType: "json", success: function (data) { timeInput.find('option').remove().end().append(''); $.each(data.Times, function (id, value) { var starttime = value.Text.split('-'); if (value.Id == modelId || (starttime[0] == $('#start-date').html() && mode == true)) { timeInput.append(''); if (starttime[0] == $('#start-date').html()) { pxcChangeTime(); } } else { timeInput.append(''); } }); timeInput.removeAttr('disabled'); $("#sto_overlay").hide(); } }); } function pxcChangeTime(timeInput) { var dateInput = timeInput.data('dateinput'); if (!dateInput) { dateInput = "#CalendarEntriesDate"; } dateInput = $(dateInput); var selectedTime = timeInput.val(); var selectedDate = dateInput.val(); if (selectedTime != "") { if (timeInput.data('loadingval') != selectedTime) { timeInput .data('loadingval', selectedTime) .removeClass("input-validation-error"); $("#infoBoxAfter").hide(); $("#infoBoxBefore").hide(); $(".error").hide(); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "http://www.toefi.de/de/wto.html?path=Home%2FGetPrice&request=json", data: '{ "selectedTime": "' + selectedTime + '", "selectedDate": "' + selectedDate + '", "locationId": ' + $('#standort').val() + ' }', dataType: "json", success: function(data) { $("#price").html(data.Price); if (data.ShowAfter) { $("#infoBoxAfter").show(); } if (data.ShowBefore) { $("#infoBoxBefore").show(); } $("#summaryDate").html(dateInput.val()); var timestring = $("option:selected", timeInput).html(); var time = timestring.split(TXT_CLOCK); $("#summaryTime").html(time[0] + TXT_CLOCK); $("#divSummary").show(); $("#sto_overlay").hide(); } }); } } } if ($("#CalendarEntriesDate").val()) { pxcChangeDate(true, $("#CalendarEntriesDate")); } $(".CalendarEntriesDate") .each(function (i, e) { if ($(e).val()) { pxcChangeDate(true, $(e)); }; }); $("#CalendarEntriesDate").change(function () { $("#divSummary").hide(); pxcChangeDate(false, $(this)); }); $(".CalendarEntriesDate").change(function () { pxcChangeDate(false, $(this)); }); $("#CalendarEntriesTime").change(function () { $("#divSummary").hide(); pxcChangeTime($("#CalendarEntriesTime")); }); $(".CalendarEntriesTime").change(function () { }); });