function locationChanged(){saveBookingDetail("location_id",$("#select_location").val())}function serviceTypeChanged(){saveBookingDetail("service_type_id",$("#select_service_type").val())}function serviceChanged(){saveBookingDetail("service_id",$("#select_service").val())}function employeeChanged(){saveBookingDetail("employee_id",$("#select_employee").val())}function groupSizeChanged(){saveBookingDetail("group_size",$("#select_group_size").val())}function unitsToBookChanged(){saveBookingDetail("units_to_book",$("#select_units_to_book").val())}function lengthChanged(){saveBookingDetail("length",$("#select_length").val())}function isPrivateChanged(){saveBookingDetail("private",$("#select_is_private").val())}function genderChanged(){saveBookingDetail("gender",$("#gender_choice").val())}function updateLateNight(n){var t=parseInt(n.slice(n.length-4,n.length));t>=2200||t<=500?$("#late_night").show():$("#late_night").hide()}function saveBookingDetail(n,t){var i=[];i.push({Name:n,Value:t});saveBookingDetails(i)}function saveBookingDetails(n){$("body").data("processing")!="1"&&($("body").data("processing","1"),$.ajax({url:"booking/changefield",type:"POST",data:JSON.stringify(n),contentType:"application/json",success:function(n){if($("body").data("processing","0"),n!=""){if(n=="cart"){window.location.href="payment";return}if(n=="refresh"){window.location.reload(!0);return}n=="$0.00"?$("#price_div").hide():($("#price_div").text("Price "+n),$("#price_div").show())}},error:function(){$("body").data("processing","0")}}))}function switchTab(){$(".descriptions").children().each(function(){$(this).toggleClass("selected")});$("#serv_desc_section").toggle();$("#emp_desc_section").toggle()}function acceptBookingPolicy(){var n={};n.optionId=2;n.value="true";$.ajax({url:"customerprofile/saveoption",type:"POST",data:JSON.stringify(n),contentType:"application/json",success:function(){book($("#booking_policy_holder").data("paynow"))},error:function(){$("body").data("processing","0")}})}function book(n){var t,i,r;if(checkBookingPolicy&&$("#booking_policy_holder").data("accepted")=="0"){$("#booking_policy_holder").data("paynow",n);$("#booking_policy_holder").modal("show");return}if(t=[],$(".next_avail_results").exists()&&(i=$(".next_avail_item.selected"),r=i.data("empid"),r>0&&t.push({Name:"employee_id",Value:r}),t.push({Name:"next_avail_data",Value:i.data("time")})),n&&t.push({Name:"payment",Value:"PayWithCreditCard"}),$("#book_no_reg_complete").exists()&&$("#book_no_reg_complete").is(":visible")){if($("#no_reg_fname").val()==""){UError("First name is required.");return}if($("#no_reg_lname").val()==""){UError("Last name is required.");return}if($("#no_reg_company").exists()&&$("#no_reg_company").val()==""){UError("Company is required.");return}if($("#no_reg_email").val()==""){UError("Email is required.");return}if($("#no_reg_cell").val()==""){UError("Cell Phone is required.");return}t.push({Name:"no_reg_fname",Value:$("#no_reg_fname").val()});t.push({Name:"no_reg_lname",Value:$("#no_reg_lname").val()});$("#no_reg_company").exists()&&t.push({Name:"no_reg_company",Value:$("#no_reg_company").val()});t.push({Name:"no_reg_email",Value:$("#no_reg_email").val()});t.push({Name:"no_reg_cell",Value:$("#no_reg_cell").val()})}t.push({Name:"book",Value:"1"});block_screen();$.ajax({url:"booking/changefield",type:"POST",data:JSON.stringify(t),contentType:"application/json",success:function(n){switch(n){case"login":var t=location.search&&location.search.includes("sbd")?location.search:"";window.location.href="/"+alias+"/account/login?returnUrl=/"+alias+"/booking"+t;break;case"not_customer":UError("You must be a customer to book.");unblock_screen();break;case"disable_booking":UError("Please call the location where you are trying to book.");unblock_screen();break;case"no_note":UError("You must enter a note to book.");unblock_screen();break;case"require_saved_card":UError("You must have a saved credit card in your profile to book.",function(){window.location.href="/"+alias+"/customerprofile"});unblock_screen();break;case"max_appointments":UError("You have exceeded your max appointments/minutes for the selected day.");unblock_screen();break;case"error":UInfo("This selected appointment is no longer available, please try again.",function(){location.reload()});unblock_screen();break;case"units":UError("There are not enough units remaining to complete your booking.");unblock_screen();break;case"units_upsell":UConfirmYesNo("There are not enough units remaining to complete your booking.  Would you like to buy the additional units required?",function(n){n&&(block_screen(),saveBookingDetail("units_upsell","1"))});unblock_screen();break;case"confirm":window.location.href="booking/confirmation";break;case"cart":window.location.href="payment";break;case"form":window.location.href="booking/form";break;case"refresh":window.location.reload(!0);break;default:UError(n);unblock_screen()}},error:function(n){UError(n)}})}if($("#accept_policy").exists())$("#accept_policy").on("click",function(){$("#booking_policy_holder").data("accepted","1");$("#booking_policy_holder").modal("hide");acceptBookingPolicy()});$(function(){if($("#booking_info").exists())$("#booking_info").on("click",function(){$.ajax({url:"booking/getbookinginfo",type:"GET",contentType:"application/json",success:function(n){$("#lsas").html(n.LocationSAS);$("#ssas").html(n.ServiceSAS);n.EmployeeSAS?($("#esas").html(n.EmployeeSAS),$("#esas").show()):$("#esas").hide();$("#avail").html(n.Availability);$("#booking_info_holder").modal("show")},error:function(n){UError(n)}})});if($("#systemMessageHolder").exists()){$("#accept_sm").on("click",function(){$.ajax({url:"booking/AcknowledgeSystemMessage",type:"POST",data:JSON.stringify({id:$(this).data("smid")}),contentType:"application/json",success:function(n){n=="ok"&&$("#systemMessageHolder").modal("hide")},error:function(n){UError(n)}})});setTimeout(function(){$("#systemMessageHolder").modal("show")},1e3)}$(".reg-select").each(function(){$(this).on("change",function(){var n=$(this).val(),t;n=="-1"?(t=$(this).attr("id").replace("reg-",""),$("#new-reg-"+t).show()):saveBookingDetail("booked_cust",n)})});$(".btn-cancel").each(function(){$(this).click(function(){var n=$(this).attr("id").replace("btn-new-reg-cancel-","");$("#new-reg-"+n).hide();$("#reg-"+n).prop("selectedIndex",0)})});$(".btn-save").each(function(){$(this).click(function(){var n=$(this).attr("id").replace("btn-new-reg-save-",""),t=$("#new-reg-name-"+n).val();$.ajax({url:"booking/event/AddChildCustomer",type:"POST",data:JSON.stringify({name:t}),contentType:"application/json",success:function(i){i=="err"?UError("an error happened"):($("#reg-"+n).append($("<option>",{value:i,text:t})),$("#reg-"+n).val(i),$("#new-reg-"+n).hide(),$("#new-reg-name-"+n).val(""))},error:function(n){UError(n)}})})});$("#save_note").click(function(){var n=$("#notes").val();saveBookingDetail("notes",n);n.length>0?$("#add_note").addClass("btn-info").removeClass("btn-default"):$("#add_note").addClass("btn-default").removeClass("btn-info");$("#note_holder").modal("hide")});$("#add_note").click(function(){"parentIFrame"in window&&parentIFrame.scrollToOffset(0,0);$("#note_holder").modal("show")});$("#note_holder").on("shown.bs.modal",function(){$("#notes").focus()});$("#add_waitlist").click(function(){"parentIFrame"in window&&parentIFrame.scrollToOffset(0,0);$("#waitlist_holder").modal("show")});$("#save_waitlist").click(function(){block_screen();$.ajax({url:"booking/addtowaitlist",type:"POST",data:JSON.stringify({evoId:0,notes:$("#waitlist_notes").val()}),contentType:"application/json",success:function(n){unblock_screen();n=="ok"?UAlert("You have been added to the waitlist.",function(){location.reload()}):UError(n)}})});$("#book").click(function(){book(!1)});$("#book_and_pay").click(function(){book(!0)});$(".next_avail_item").click(function(){$(".next_avail_item").each(function(){if($(this).hasClass("selected"))return $(this).removeClass("selected"),!1});$(this).addClass("selected");var n=$(this).data("time");updateLateNight(n)});$("#more_next_avail").click(function(){saveBookingDetail("more_next_avail",lastAvailTime)});$(".time_choices td").click(function(){if(!$(this).hasClass("selected")&&!$(this).hasClass("no_time")){$(".time_choices td").each(function(){if($(this).hasClass("selected"))return $(this).removeClass("selected"),!1});$(this).addClass("selected");var n=$(this).data("time");saveBookingDetail("time",n);updateLateNight(n)}});$("#payment_source").change(function(){saveBookingDetail("payment",$("#payment_source").val())});$(".resSelect").each(function(){$(this).change(function(){var n=$(this).attr("id").replace("resource","");saveBookingDetail("resource",n+"~"+$(this).val())})});$("#start_date").datepicker({format:dateFormat,inline:!0,startDate:new Date}).datepicker("setDate",chosenDate).on("changeDate",function(n){saveBookingDetail("start_date",n.date.getFormattedString())});if($("#show-extra-row").click(function(){$(".time_choices tr.extra").each(function(){$(this).show()});$("#hide-extra-row").show();$(this).hide()}),$("#hide-extra-row").click(function(){$(".time_choices tr.extra").each(function(){$(this).hide()});$("#show-extra-row").show();$(this).hide()}),$("#no_reg_holder").exists()){$("#book_now_no_reg").on("click",function(){"parentIFrame"in window&&parentIFrame.scrollToOffset(0,0);$("#no_reg_holder").modal("show")});$("#book_no_reg_complete").on("click",function(){book(!1)})}})