document.write('
'); var jQuery; var schoolaxisEventsData = {"mode":"school","events":[]}; var schoolaxisEventsHost = "ghastaging.schoolaxis.com"; var schoolaxisEventsScheme = "https"; var schoolaxisEventsRecaptchaHtml = "
"; var schoolaxisEventsSubmitting = false; if (window.jQuery === undefined || window.jQuery.fn.jquery !== "3.1.0") { var script_tag = document.createElement("script"); script_tag.setAttribute("type","text/javascript"); script_tag.setAttribute("src", "https://code.jquery.com/jquery-3.1.0.min.js"); if (script_tag.readyState) { script_tag.onreadystatechange = function () { if (this.readyState == "complete" || this.readyState == "loaded") schoolaxisEventsScriptLoadHandler(); }; } else { script_tag.onload = schoolaxisEventsScriptLoadHandler; } (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); } else { jQuery = window.jQuery; schoolaxisEventsMain(); } function schoolaxisEventsScriptLoadHandler() { jQuery = window.jQuery.noConflict(true); schoolaxisEventsMain(); } function schoolaxisEventsMain() { jQuery(document).ready(function($) { schoolaxisEventsRenderRoot(); }); } function schoolaxisEventsRenderRoot() { var $root = jQuery("#schoolaxiseventsembed"); $root.html(""); if ( schoolaxisEventsData.mode == "school" ) { schoolaxisEventsRenderEventList($root, schoolaxisEventsData.events); } else { schoolaxisEventsRenderInstanceList($root, schoolaxisEventsData.event, schoolaxisEventsData.event.instances); } } function schoolaxisEventsEsc(s) { return jQuery("
").text(s == undefined ? "" : s).html(); } function schoolaxisEventsFormatDate(dt) { if ( !dt ) return ""; var d = new Date(dt.replace(" ", "T")); if ( isNaN(d.getTime()) ) return dt; return d.toLocaleDateString(undefined, {weekday:"long", month:"long", day:"numeric", year:"numeric"}); } function schoolaxisEventsFormatTime(dt) { if ( !dt ) return ""; var d = new Date(dt.replace(" ", "T")); if ( isNaN(d.getTime()) ) return dt; return d.toLocaleTimeString(undefined, {hour:"numeric", minute:"2-digit", hour12:true}); } function schoolaxisEventsRow(label, value) { return "
" + label + ": " + value + "
"; } function schoolaxisEventsRenderEventList($root, events) { var html = '
'; if ( events.length == 0 ) { html += '

No events are currently open for booking.

'; } for ( var i = 0; i < events.length; i++ ) { var ev = events[i]; html += '
'; html += '

' + schoolaxisEventsEsc(ev.name) + "

"; if ( ev.duration ) html += schoolaxisEventsRow("Duration", schoolaxisEventsEsc(ev.duration)); if ( ev.location ) html += schoolaxisEventsRow("Location", schoolaxisEventsEsc(ev.location)); if ( ev.instances.length == 0 ) { html += '

No upcoming times available.

'; } else { html += schoolaxisEventsRow("Available Times", ev.instances.length); html += schoolaxisEventsRow("Next Available", schoolaxisEventsFormatDate(ev.instances[0].datetime)); html += "
"; html += ''; } html += "
"; } html += "
"; $root.html(html); window.schoolaxisEventsEventsCache = events; } function schoolaxisEventsShowInstances(idx) { var ev = window.schoolaxisEventsEventsCache[idx]; schoolaxisEventsRenderInstanceList(jQuery("#schoolaxiseventsembed"), ev, ev.instances, true); } function schoolaxisEventsRenderInstanceList($root, event, instances, showBack) { // Callers that come back from the booking form do not pass showBack: in a school embed the list always has a way back to all events. if ( showBack === undefined ) showBack = ( schoolaxisEventsData.mode == "school" ); var html = ""; if ( showBack ) html += '

← Back to all events

'; html += "

" + schoolaxisEventsEsc(event.name) + "

"; if ( instances.length == 0 ) { html += '

No upcoming times are available for this event.

'; } else { html += '
'; for ( var i = 0; i < instances.length; i++ ) { var inst = instances[i]; html += '
'; html += schoolaxisEventsRow("Date", schoolaxisEventsFormatDate(inst.datetime)); html += schoolaxisEventsRow("Time", schoolaxisEventsFormatTime(inst.datetime) + (inst.tz ? " " + schoolaxisEventsEsc(inst.tz) : "")); if ( inst.duration ) html += schoolaxisEventsRow("Duration", schoolaxisEventsEsc(inst.duration)); if ( inst.location ) html += schoolaxisEventsRow("Location", schoolaxisEventsEsc(inst.location)); html += schoolaxisEventsRow("Available Spots", inst.remaining); if ( inst.description ) html += schoolaxisEventsRow("Details", schoolaxisEventsEsc(inst.description)); html += "
"; html += ''; html += "
"; } html += "
"; } jQuery(($root && $root.length) ? $root : "#schoolaxiseventsembed").html(html); window.schoolaxisEventsInstancesCache = instances; window.schoolaxisEventsCurrentEvent = event; } function schoolaxisEventsShowBookingForm(idx) { var inst = window.schoolaxisEventsInstancesCache[idx]; var event = window.schoolaxisEventsCurrentEvent; var maxGuests = Math.max(0, inst.remaining - 1); var html = '

← Back to available times

'; html += "

" + schoolaxisEventsEsc(event.name) + "

"; html += schoolaxisEventsRow("Date", schoolaxisEventsFormatDate(inst.datetime)); html += schoolaxisEventsRow("Time", schoolaxisEventsFormatTime(inst.datetime) + (inst.tz ? " " + schoolaxisEventsEsc(inst.tz) : "")); if ( inst.duration ) html += schoolaxisEventsRow("Duration", schoolaxisEventsEsc(inst.duration)); if ( inst.location ) html += schoolaxisEventsRow("Location", schoolaxisEventsEsc(inst.location)); html += schoolaxisEventsRow("Available Spots", inst.remaining); html += '
'; html += '
'; html += '
'; html += '
'; html += '
'; html += '
'; if ( maxGuests > 0 ) { html += '
'; } html += '
'; html += '
'; html += ''; html += "
"; jQuery("#schoolaxiseventsembed").html(html); jQuery("#schoolaxisEventsCaptchaContainer").append(schoolaxisEventsRecaptchaHtml); } function schoolaxisEventsSubmit(instanceid) { if ( schoolaxisEventsSubmitting ) return; var email = jQuery("#schoolaxisEventsEmail").val(); if ( !email || email.indexOf("@") < 0 ) { jQuery("#schoolaxisEventsFormMessage").html('
A valid email is required.
'); return; } var email2 = jQuery("#schoolaxisEventsEmail2").val(); if ( jQuery.trim(email).toLowerCase() !== jQuery.trim(email2 || "").toLowerCase() ) { jQuery("#schoolaxisEventsFormMessage").html('
The email addresses do not match. Please check them and try again.
'); return; } schoolaxisEventsSubmitting = true; var payload = { firstname: jQuery("#schoolaxisEventsFirstname").val(), lastname: jQuery("#schoolaxisEventsLastname").val(), email: email, phone: jQuery("#schoolaxisEventsPhone").val(), additionalguests: jQuery("#schoolaxisEventsGuests").length ? jQuery("#schoolaxisEventsGuests").val() : 0, "g-recaptcha-response": (typeof grecaptcha !== "undefined") ? grecaptcha.getResponse() : "", callback: "schoolaxisEventsSubmitCallback" }; jQuery.ajax({ type: "post", async: true, url: schoolaxisEventsScheme + "://" + schoolaxisEventsHost + "/events/public/submitbooking/" + instanceid, data: payload, dataType: "jsonp", jsonpCallback: "schoolaxisEventsSubmitCallback" }).done(function(r) { schoolaxisEventsSubmitting = false; if ( r.error ) { jQuery("#schoolaxisEventsFormMessage").html('
' + r.message + "
"); if ( typeof grecaptcha !== "undefined" ) grecaptcha.reset(); } else if ( r.redirecturl && /^https?:\/\//i.test(r.redirecturl) ) { window.location.href = r.redirecturl; } else { jQuery("#schoolaxiseventsembed").html('
' + (r.confirmedmessage ? '
' + r.confirmedmessage + '
' : '') + '

Your booking is confirmed!

Save this link to manage your reservation later:

' + r.managelink + "

"); } }); }