var tripObjects = jQuery.parseJSON('{"310":{"key":310,"sort":1,"main_start":"11.01.2025","main_start_raw":"2025-01-11","main_date":"11.-25.01.2025","main_headline":"3 Kurstage Ski+Board (Als Gesamtpaket)","main_payDate":"28.12.2024","main_payDate_raw":"2024-12-28","main_bookable_statusText":"Keine Anmeldung mehr möglich \/ Ausgebucht","main_bookable":0,"main_ageMin":6,"main_ageMax":99,"main_priceMin":106,"main_ageRange":"6-99 Jahre","option_level":3,"option_kurs":1},"307":{"key":307,"sort":2,"main_start":"11.01.2025","main_start_raw":"2025-01-11","main_date":"11.01.2025","main_headline":"Einzeltag Kurstage Ski+Board ","main_payDate":"28.12.2024","main_payDate_raw":"2024-12-28","main_bookable_statusText":"Keine Anmeldung mehr möglich \/ Ausgebucht","main_bookable":0,"main_ageMin":6,"main_ageMax":99,"main_priceMin":42,"main_ageRange":"6-99 Jahre","option_level":3,"option_kurs":1},"308":{"key":308,"sort":3,"main_start":"18.01.2025","main_start_raw":"2025-01-18","main_date":"18.01.2025","main_headline":"Einzeltag Kurstage Ski+Board ","main_payDate":"04.01.2025","main_payDate_raw":"2025-01-04","main_bookable_statusText":"Keine Anmeldung mehr möglich \/ Ausgebucht","main_bookable":0,"main_ageMin":6,"main_ageMax":99,"main_priceMin":42,"main_ageRange":"6-99 Jahre","option_level":3,"option_kurs":1},"309":{"key":309,"sort":4,"main_start":"25.01.2025","main_start_raw":"2025-01-25","main_date":"25.01.2025","main_headline":"Einzeltag Kurstage Ski+Board ","main_payDate":"11.01.2025","main_payDate_raw":"2025-01-11","main_bookable_statusText":"Keine Anmeldung mehr möglich \/ Ausgebucht","main_bookable":0,"main_ageMin":6,"main_ageMax":99,"main_priceMin":42,"main_ageRange":"6-99 Jahre","option_level":3,"option_kurs":1},"313":{"key":313,"sort":5,"main_start":"27.01.2025","main_start_raw":"2025-01-27","main_date":"27.01.2025","main_headline":"Kulinarischer Skitag","main_payDate":"13.01.2025","main_payDate_raw":"2025-01-13","main_bookable_statusText":"","main_bookable":1,"main_ageMin":18,"main_ageMax":90,"main_priceMin":64,"main_ageRange":"18-90 Jahre","option_level":3,"option_kurs":0},"312":{"key":312,"sort":6,"main_start":"02.02.2025","main_start_raw":"2025-02-02","main_date":"02.-09.02.2025","main_headline":"Genuss-Woche Südtirol","main_payDate":"19.01.2025","main_payDate_raw":"2025-01-19","main_bookable_statusText":"","main_bookable":1,"main_ageMin":18,"main_ageMax":90,"main_priceMin":675,"main_ageRange":"18-90 Jahre","option_level":3,"option_kurs":0},"311":{"key":311,"sort":7,"main_start":"14.02.2025","main_start_raw":"2025-02-14","main_date":"14.02.2025","main_headline":"Lady-Ski","main_payDate":"31.01.2025","main_payDate_raw":"2025-01-31","main_bookable_statusText":"","main_bookable":1,"main_ageMin":16,"main_ageMax":90,"main_priceMin":50,"main_ageRange":"16-90 Jahre","option_level":3,"option_kurs":0}}'); var tripObjectsSelect = jQuery.parseJSON('[{"key":310,"sort":1,"main_start":"11.01.2025","main_start_raw":"2025-01-11","main_date":"11.-25.01.2025","main_headline":"3 Kurstage Ski+Board (Als Gesamtpaket)","main_payDate":"28.12.2024","main_payDate_raw":"2024-12-28","main_bookable_statusText":"Keine Anmeldung mehr möglich \/ Ausgebucht","main_bookable":0,"main_ageMin":6,"main_ageMax":99,"main_priceMin":106,"main_ageRange":"6-99 Jahre","option_level":3,"option_kurs":1},{"key":307,"sort":2,"main_start":"11.01.2025","main_start_raw":"2025-01-11","main_date":"11.01.2025","main_headline":"Einzeltag Kurstage Ski+Board ","main_payDate":"28.12.2024","main_payDate_raw":"2024-12-28","main_bookable_statusText":"Keine Anmeldung mehr möglich \/ Ausgebucht","main_bookable":0,"main_ageMin":6,"main_ageMax":99,"main_priceMin":42,"main_ageRange":"6-99 Jahre","option_level":3,"option_kurs":1},{"key":308,"sort":3,"main_start":"18.01.2025","main_start_raw":"2025-01-18","main_date":"18.01.2025","main_headline":"Einzeltag Kurstage Ski+Board ","main_payDate":"04.01.2025","main_payDate_raw":"2025-01-04","main_bookable_statusText":"Keine Anmeldung mehr möglich \/ Ausgebucht","main_bookable":0,"main_ageMin":6,"main_ageMax":99,"main_priceMin":42,"main_ageRange":"6-99 Jahre","option_level":3,"option_kurs":1},{"key":309,"sort":4,"main_start":"25.01.2025","main_start_raw":"2025-01-25","main_date":"25.01.2025","main_headline":"Einzeltag Kurstage Ski+Board ","main_payDate":"11.01.2025","main_payDate_raw":"2025-01-11","main_bookable_statusText":"Keine Anmeldung mehr möglich \/ Ausgebucht","main_bookable":0,"main_ageMin":6,"main_ageMax":99,"main_priceMin":42,"main_ageRange":"6-99 Jahre","option_level":3,"option_kurs":1},{"key":313,"sort":5,"main_start":"27.01.2025","main_start_raw":"2025-01-27","main_date":"27.01.2025","main_headline":"Kulinarischer Skitag","main_payDate":"13.01.2025","main_payDate_raw":"2025-01-13","main_bookable_statusText":"","main_bookable":1,"main_ageMin":18,"main_ageMax":90,"main_priceMin":64,"main_ageRange":"18-90 Jahre","option_level":3,"option_kurs":0},{"key":312,"sort":6,"main_start":"02.02.2025","main_start_raw":"2025-02-02","main_date":"02.-09.02.2025","main_headline":"Genuss-Woche Südtirol","main_payDate":"19.01.2025","main_payDate_raw":"2025-01-19","main_bookable_statusText":"","main_bookable":1,"main_ageMin":18,"main_ageMax":90,"main_priceMin":675,"main_ageRange":"18-90 Jahre","option_level":3,"option_kurs":0},{"key":311,"sort":7,"main_start":"14.02.2025","main_start_raw":"2025-02-14","main_date":"14.02.2025","main_headline":"Lady-Ski","main_payDate":"31.01.2025","main_payDate_raw":"2025-01-31","main_bookable_statusText":"","main_bookable":1,"main_ageMin":16,"main_ageMax":90,"main_priceMin":50,"main_ageRange":"16-90 Jahre","option_level":3,"option_kurs":0}]'); var priceObjects = jQuery.parseJSON('{"310":{"895":{"option_bookings":9,"option_preis_bezeichnung":"Nichtmitglieder nur Bus","option_preis":125,"option_level":3,"option_age_min":12,"option_age_max":99,"option_age_range":"12 - 99 Jahre","option_ausgebucht":0,"option_kurs":0},"897":{"option_bookings":8,"option_preis_bezeichnung":"Nichtmitglieder Bus + Kurs Kinder","option_preis":178,"option_level":3,"option_age_min":6,"option_age_max":17,"option_age_range":"6 - 17 Jahre","option_ausgebucht":0,"option_kurs":1},"894":{"option_bookings":1,"option_preis_bezeichnung":"Nichtmitglieder Bus + Kurs Erwachsene","option_preis":214,"option_level":3,"option_age_min":18,"option_age_max":99,"option_age_range":"18 - 99 Jahre","option_ausgebucht":0,"option_kurs":1},"896":{"option_bookings":7,"option_preis_bezeichnung":"Mitglieder nur Bus","option_preis":106,"option_level":2,"option_age_min":12,"option_age_max":99,"option_age_range":"12 - 99 Jahre","option_ausgebucht":0,"option_kurs":0},"898":{"option_bookings":3,"option_preis_bezeichnung":"Mitglieder Bus + Kurs Kinder","option_preis":139,"option_level":2,"option_age_min":6,"option_age_max":17,"option_age_range":"6 - 17 Jahre","option_ausgebucht":0,"option_kurs":1},"893":{"option_preis_bezeichnung":"Mitglieder Bus + Kurs Erwachsene","option_preis":160,"option_level":2,"option_age_min":18,"option_age_max":99,"option_age_range":"18 - 99 Jahre","option_ausgebucht":0,"option_kurs":1}},"307":{"877":{"option_bookings":20,"option_preis_bezeichnung":"Nichtmitglieder nur Bus","option_preis":50,"option_level":3,"option_age_min":12,"option_age_max":99,"option_age_range":"12 - 99 Jahre","option_ausgebucht":0,"option_kurs":0},"879":{"option_bookings":3,"option_preis_bezeichnung":"Nichtmitglieder Bus + Kurs Kinder","option_preis":72,"option_level":3,"option_age_min":6,"option_age_max":17,"option_age_range":"6 - 17 Jahre","option_ausgebucht":0,"option_kurs":1},"878":{"option_bookings":4,"option_preis_bezeichnung":"Mitglieder nur Bus","option_preis":42,"option_level":2,"option_age_min":12,"option_age_max":99,"option_age_range":"12 - 99 Jahre","option_ausgebucht":0,"option_kurs":0},"880":{"option_bookings":2,"option_preis_bezeichnung":"Mitglieder Bus + Kurs Kinder","option_preis":56,"option_level":2,"option_age_min":6,"option_age_max":17,"option_age_range":"6 - 17 Jahre","option_ausgebucht":0,"option_kurs":1},"876":{"option_bookings":2,"option_preis_bezeichnung":"Nichtmitglieder Bus + Kurs Erwachsene","option_preis":85,"option_level":3,"option_age_min":18,"option_age_max":99,"option_age_range":"18 - 99 Jahre","option_ausgebucht":0,"option_kurs":1},"875":{"option_preis_bezeichnung":"Mitglieder Bus + Kurs Erwachsene","option_preis":64,"option_level":2,"option_age_min":18,"option_age_max":99,"option_age_range":"18 - 99 Jahre","option_ausgebucht":0,"option_kurs":1}},"308":{"883":{"option_bookings":22,"option_preis_bezeichnung":"Nichtmitglieder nur Bus","option_preis":50,"option_level":3,"option_age_min":12,"option_age_max":99,"option_age_range":"12 - 99 Jahre","option_ausgebucht":0,"option_kurs":0},"885":{"option_bookings":9,"option_preis_bezeichnung":"Nichtmitglieder Bus + Kurs Kinder","option_preis":72,"option_level":3,"option_age_min":6,"option_age_max":17,"option_age_range":"6 - 17 Jahre","option_ausgebucht":0,"option_kurs":1},"884":{"option_bookings":4,"option_preis_bezeichnung":"Mitglieder nur Bus","option_preis":42,"option_level":2,"option_age_min":12,"option_age_max":99,"option_age_range":"12 - 99 Jahre","option_ausgebucht":0,"option_kurs":0},"882":{"option_bookings":1,"option_preis_bezeichnung":"Nichtmitglieder Bus + Kurs Erwachsene","option_preis":85,"option_level":3,"option_age_min":18,"option_age_max":99,"option_age_range":"18 - 99 Jahre","option_ausgebucht":0,"option_kurs":1},"881":{"option_bookings":1,"option_preis_bezeichnung":"Mitglieder Bus + Kurs Erwachsene","option_preis":64,"option_level":2,"option_age_min":18,"option_age_max":99,"option_age_range":"18 - 99 Jahre","option_ausgebucht":0,"option_kurs":1},"886":{"option_preis_bezeichnung":"Mitglieder Bus + Kurs Kinder","option_preis":56,"option_level":2,"option_age_min":6,"option_age_max":17,"option_age_range":"6 - 17 Jahre","option_ausgebucht":0,"option_kurs":1}},"309":{"889":{"option_bookings":21,"option_preis_bezeichnung":"Nichtmitglieder nur Bus","option_preis":50,"option_level":3,"option_age_min":12,"option_age_max":99,"option_age_range":"12 - 99 Jahre","option_ausgebucht":0,"option_kurs":0},"891":{"option_bookings":8,"option_preis_bezeichnung":"Nichtmitglieder Bus + Kurs Kinder","option_preis":72,"option_level":3,"option_age_min":6,"option_age_max":17,"option_age_range":"6 - 17 Jahre","option_ausgebucht":0,"option_kurs":1},"890":{"option_bookings":5,"option_preis_bezeichnung":"Mitglieder nur Bus","option_preis":42,"option_level":2,"option_age_min":12,"option_age_max":99,"option_age_range":"12 - 99 Jahre","option_ausgebucht":0,"option_kurs":0},"888":{"option_bookings":1,"option_preis_bezeichnung":"Nichtmitglieder Bus + Kurs Erwachsene","option_preis":85,"option_level":3,"option_age_min":18,"option_age_max":99,"option_age_range":"18 - 99 Jahre","option_ausgebucht":0,"option_kurs":1},"887":{"option_bookings":1,"option_preis_bezeichnung":"Mitglieder Bus + Kurs Erwachsene","option_preis":64,"option_level":2,"option_age_min":18,"option_age_max":99,"option_age_range":"18 - 99 Jahre","option_ausgebucht":0,"option_kurs":1},"892":{"option_preis_bezeichnung":"Mitglieder Bus + Kurs Kinder","option_preis":56,"option_level":2,"option_age_min":6,"option_age_max":17,"option_age_range":"6 - 17 Jahre","option_ausgebucht":0,"option_kurs":1}},"313":{"903":{"option_bookings":2,"option_preis_bezeichnung":"Mitglieder Erwachsene","option_preis":64,"option_level":2,"option_age_min":18,"option_age_max":90,"option_age_range":"18 - 90 Jahre","option_ausgebucht":0,"option_kurs":0},"904":{"option_bookings":2,"option_preis_bezeichnung":"Nichtmitglieder Erwachsene","option_preis":77,"option_level":3,"option_age_min":18,"option_age_max":90,"option_age_range":"18 - 90 Jahre","option_ausgebucht":0,"option_kurs":0}},"312":{"902":{"option_bookings":14,"option_preis_bezeichnung":"Nichtmitglieder Erwachsene","option_preis":695,"option_level":3,"option_age_min":18,"option_age_max":90,"option_age_range":"18 - 90 Jahre","option_ausgebucht":0,"option_kurs":0},"901":{"option_bookings":6,"option_preis_bezeichnung":"Mitglieder Erwachsene","option_preis":675,"option_level":2,"option_age_min":18,"option_age_max":90,"option_age_range":"18 - 90 Jahre","option_ausgebucht":0,"option_kurs":0}},"311":{"900":{"option_bookings":27,"option_preis_bezeichnung":"Lady Nichtmitglied","option_preis":67,"option_level":3,"option_age_min":16,"option_age_max":90,"option_age_range":"16 - 90 Jahre","option_ausgebucht":0,"option_kurs":0},"899":{"option_bookings":4,"option_preis_bezeichnung":"Lady Mitglied","option_preis":50,"option_level":2,"option_age_min":16,"option_age_max":90,"option_age_range":"16 - 90 Jahre","option_ausgebucht":0,"option_kurs":0}}}'); var journeyObjects = jQuery.parseJSON('{"310":{"314":{"option_name":"Bus mit \/ ohne Kurs","option_spaces":20,"option_priceReduction":0,"option_reservation":0,"option_waitingList":0,"option_standard":0}},"307":{"311":{"option_name":"Bus mit \/ ohne Kurs","option_spaces":15,"option_priceReduction":0,"option_reservation":0,"option_waitingList":0,"option_standard":0}},"308":{"312":{"option_name":"Bus mit \/ ohne Kurs","option_spaces":15,"option_priceReduction":0,"option_reservation":0,"option_waitingList":0,"option_standard":0}},"309":{"313":{"option_name":"Bus mit \/ ohne Kurs","option_spaces":15,"option_priceReduction":0,"option_reservation":0,"option_waitingList":0,"option_standard":0}},"313":{"317":{"option_name":"Bus","option_spaces":40,"option_priceReduction":0,"option_reservation":0,"option_waitingList":0,"option_standard":0}},"312":{"316":{"option_name":"Eigenanreise","option_spaces":30,"option_priceReduction":0,"option_reservation":0,"option_waitingList":0,"option_standard":0}},"311":{"315":{"option_name":"Bus","option_spaces":50,"option_priceReduction":0,"option_reservation":0,"option_waitingList":0,"option_standard":0}}}'); var lessonObjects = jQuery.parseJSON('{"310":{"A1-677":{"option_id_kurs":677,"option_kursTitel":"Ski 1"},"A2-678":{"option_id_kurs":678,"option_kursTitel":"Ski 2"},"A3-679":{"option_id_kurs":679,"option_kursTitel":"Ski 3"},"A4-680":{"option_id_kurs":680,"option_kursTitel":"Ski 4"},"S1-681":{"option_id_kurs":681,"option_kursTitel":"Snowboard 1"},"S2-684":{"option_id_kurs":684,"option_kursTitel":"Snowboard 2"},"S3-683":{"option_id_kurs":683,"option_kursTitel":"Snowboard 3"},"S4-682":{"option_id_kurs":682,"option_kursTitel":"Snowboard 4"}},"307":{"A1-653":{"option_id_kurs":653,"option_kursTitel":"Ski 1"},"A2-654":{"option_id_kurs":654,"option_kursTitel":"Ski 2"},"A3-655":{"option_id_kurs":655,"option_kursTitel":"Ski 3"},"A4-656":{"option_id_kurs":656,"option_kursTitel":"Ski 4"},"S1-657":{"option_id_kurs":657,"option_kursTitel":"Snowboard 1"},"S2-660":{"option_id_kurs":660,"option_kursTitel":"Snowboard 2"},"S3-659":{"option_id_kurs":659,"option_kursTitel":"Snowboard 3"},"S4-658":{"option_id_kurs":658,"option_kursTitel":"Snowboard 4"}},"308":{"A1-661":{"option_id_kurs":661,"option_kursTitel":"Ski 1"},"A2-662":{"option_id_kurs":662,"option_kursTitel":"Ski 2"},"A3-663":{"option_id_kurs":663,"option_kursTitel":"Ski 3"},"A4-664":{"option_id_kurs":664,"option_kursTitel":"Ski 4"},"S1-665":{"option_id_kurs":665,"option_kursTitel":"Snowboard 1"},"S2-668":{"option_id_kurs":668,"option_kursTitel":"Snowboard 2"},"S3-667":{"option_id_kurs":667,"option_kursTitel":"Snowboard 3"},"S4-666":{"option_id_kurs":666,"option_kursTitel":"Snowboard 4"}},"309":{"A1-669":{"option_id_kurs":669,"option_kursTitel":"Ski 1"},"A2-670":{"option_id_kurs":670,"option_kursTitel":"Ski 2"},"A3-671":{"option_id_kurs":671,"option_kursTitel":"Ski 3"},"A4-672":{"option_id_kurs":672,"option_kursTitel":"Ski 4"},"S1-673":{"option_id_kurs":673,"option_kursTitel":"Snowboard 1"},"S2-676":{"option_id_kurs":676,"option_kursTitel":"Snowboard 2"},"S3-675":{"option_id_kurs":675,"option_kursTitel":"Snowboard 3"},"S4-674":{"option_id_kurs":674,"option_kursTitel":"Snowboard 4"}}}'); // Purpose: Display valid options // How it's done: Gather information from functions above // Status: IN USE function displayFormOptions() { var tripSelect = jQuery('#tripSelect').val(); var priceSelect = jQuery('#priceSelect').val(); var journeySelect = jQuery('#journeySelect').val(); var lessonSelect = jQuery('#lessonSelect').val(); // Hide all select elements, when no trip is selected // Reset selects (just to make sure) if(typeof tripSelect === 'undefined' | tripSelect === null || tripSelect === "") { jQuery('#priceSelectSection').addClass("d-none"); jQuery('#journeySelectSection').addClass("d-none"); jQuery('#lessonSelectSection').addClass("d-none"); jQuery('#tripBookingProgressbar').html("").addClass('d-none'); jQuery('#priceSelect').prop('selectedIndex', 0); jQuery('#journeySelect').prop('selectedIndex', 0); jQuery('#lessonSelect').prop('selectedIndex', 0); displayTripSelect(); return false; } else { jQuery('#tripSelect').removeClass("is-invalid").addClass("is-valid"); jQuery('#priceSelectHint').html('').addClass("d-none"); jQuery('#priceSelectSection').removeClass("d-none"); jQuery('#journeySelectSection').removeClass("d-none"); displayTripSelect(tripSelect); displayPriceSelect(tripSelect, priceSelect, lessonSelect); displayJourneySelect(tripSelect, journeySelect); //displayTripProgressBar(tripSelect); } } // Purpose: Fill select with trip data // How it's done: Rebuild a new JSON array which only contains the valid elements regarding age // Dependancies: calculateAge // Status: IN USE at displayFormOptions function displayTripSelect(tripSelect) { if(jQuery('#birthdate').val().length<10) { jQuery('#birthdayDayHint').removeClass('d-none'); jQuery('#tripSelectSection').addClass('d-none'); } var tripCount = 0; var selectElement = jQuery("#tripSelect"); var tripLength = Object.keys(tripObjectsSelect).length; jQuery("#tripSelect").empty(); var selectElement = jQuery("#tripSelect"); selectElement.append(jQuery(''); tripCount++; } }); // In the rare case, that no trips can be shown we hide the select section // Let's make sure to show a hint if the registrant is too young if(tripCount==0) { if(jQuery('#birthdate').val().length==10) { jQuery('#birthdayDayHint').addClass('d-none'); jQuery('#noTrips').remove(); jQuery('#tripSelectSection').removeClass('d-none').after(''); } jQuery('#priceSelectSection').addClass('d-none'); jQuery('#journeySelectSection').addClass('d-none'); jQuery('#lessonSelectSection').addClass('d-none'); } else { jQuery('#tripSelect').addClass('is-invalid'); jQuery('#birthdayDayHint').addClass('d-none'); jQuery('#noTrips').remove(); jQuery('#tripSelectSection').removeClass('d-none'); jQuery('#noTrips').remove(); } if(typeof tripSelect === 'undefined' | tripSelect === null || tripSelect === "") { } else { jQuery('#tripSelect'+tripSelect).prop("selected", true); } } // Purpose: Determine the priceOptions in regard of membership and age // How it's done: Rebuild a new JSON array which only contains the valid elements // Dependancies: calculateAge() function // Status: IN USE at displayPriceSelect function determinePriceOptions(tripSelect) { if(typeof tripSelect === 'undefined' | tripSelect === null || tripSelect === "") return false; var specificDate = tripObjects[tripSelect]["main_start"]; var age = calculateAge(specificDate); //var mitglied = jQuery("input[name='mitglied']:checked").val(); var mitglied = jQuery('#mitglied').val(); var validPriceObjects = {}; jQuery.each(priceObjects[tripSelect], function(key, value) { var age_min = priceObjects[tripSelect][key]['option_age_min']; var age_max = priceObjects[tripSelect][key]['option_age_max']; var option_kurs = priceObjects[tripSelect][key]['option_kurs']; var option_level = priceObjects[tripSelect][key]['option_level']; // Stage 1: Age if(age>=age_min && age<=age_max) { // Stage 2: Level if(mitglied==1 && option_level==2) { validPriceObjects[key] = priceObjects[tripSelect][key]; } else if(mitglied==0 && option_level!=2) { validPriceObjects[key] = priceObjects[tripSelect][key]; } } }); var validPriceObjectsJSON = JSON.stringify(validPriceObjects, null, 2); return validPriceObjectsJSON; } // Purpose: Display price options // How it's done: Gather information and build select options // Dependancy: determinePriceOptions // Status: IN USE at displayFormOptions function displayPriceSelect(tripSelect, priceSelect, lessonSelect) { var priceOptions = jQuery.parseJSON(determinePriceOptions(tripSelect)); var priceLength = Object.keys(priceOptions).length; // Name & prepare element var selectElement = jQuery("#priceSelect"); jQuery("#priceSelect").empty(); // If element has more than one option, then add a select option with no value if(priceLength>1) { selectElement.append(jQuery('