(function($){
$(document).ready(function (){
tours.init();
});
var tours={
init: function (){
window.bookingRequest={};
window.bookingRequest.extraItems={};
window.bookingRequest.adults=1;
window.bookingRequest.children=0;
window.bookingRequest.extraItemsTotalPrice=0;
window.bookingRequest.totalPrice=0;
window.bookingRequest.totalTourOnlyPrice=0;
window.bookingRequest.totalDays=1;
$('.extra_items_total').html(tours.formatPrice(window.bookingRequest.extraItemsTotalPrice));
$('.total_price').html(tours.formatPrice(window.bookingRequest.totalPrice));
$('.reservation_total').html(tours.formatPrice(window.bookingRequest.totalTourOnlyPrice));
$('.toggle_breakdown').unbind('click');
$('.toggle_breakdown').on('click', function(e){
if($('.price_breakdown_row').hasClass('hidden')){
$('.price_breakdown_row').removeClass('hidden');
if(window.enableExtraItems){
$('.price_breakdown_row').show();
}else{
$('.price_breakdown_row:not(.extra_items_breakdown_row)').show();
}
$('.toggle_breakdown').html(window.hidePriceBreakdownLabel);
}else{
$('.price_breakdown_row').addClass('hidden');
$('.price_breakdown_row').hide();
$('.toggle_breakdown').html(window.showPriceBreakdownLabel);
}
e.preventDefault();
});
if(window.tourIsReservationOnly||!window.useWoocommerceForCheckout){
$('.tour-booking-form').validate({
onkeyup: false,
ignore: [],
invalidHandler: function(e, validator){
var errors=validator.numberOfInvalids();
if(errors){
var message=errors==1 ? window.formSingleError:window.formMultipleError.format(errors);
$("div.error div p").html(message);
$("div.error").show();
}else{
$("div.error").hide();
}},
submitHandler: function(){
tours.processTourBooking();
}});
$.each(window.bookingFormFields, function(index, field){
if(field.hide!=='1'&&field.id!==null&&field.id.length > 0){
var $input=null;
if(field.type=='text'||field.type=='email'){
$input=$('.tour-booking-form').find('input[name=' + field.id + ']');
}else if(field.type=='textarea'){
$input=$('.tour-booking-form').find('textarea[name=' + field.id + ']');
}
if($input!==null&&typeof($input)!=='undefined'){
if(field.required=='1'){
$input.rules('add', {
required: true,
messages: {
required: window.bookingFormRequiredError
}});
}
if(field.type=='email'){
$input.rules('add', {
email: true,
messages: {
required: window.bookingFormEmailError
}});
}}
}});
}
$('.booking-commands').hide();
$('#booking_form_adults').uniform();
$('#booking_form_children').uniform();
$('.extra_item_quantity').uniform();
$('.radio').bind('click.uniform',
function (e){
if($(this).find("span").hasClass('checked'))
$(this).find("input").attr('checked', true);
else
$(this).find("input").attr('checked', false);
}
);
tours.bindGallery();
tours.bindResetButton();
tours.bindNextButton();
tours.bindCancelButton();
if(window.enableExtraItems){
tours.bindExtraItemsQuantitySelect();
tours.buildExtraItemsTable();
tours.bindRequiredExtraItems();
}
tours.populateTourScheduleEntries(window.tourId, window.currentDay, window.currentMonth, window.currentYear, tours.bindTourDatePicker);
},
bindRequiredExtraItems: function(){
if(typeof(window.requiredExtraItems)!=='undefined'&&window.requiredExtraItems.length > 0){
$.each(window.requiredExtraItems, function(index, extraItemId){
tours.updateExtraItemSelection(extraItemId, 1);
$('#extra_item_quantity_' + extraItemId).val('1');
});
}},
bindGallery:function(){
$("#gallery").lightSlider({
item:1,
rtl: (window.enableRtl ? true:false),
slideMargin:0,
auto:true,
loop:true,
speed:1500,
pause:window.pauseBetweenSlides,
keyPress:true,
gallery:true,
thumbItem:8,
galleryMargin:3,
onSliderLoad: function(){
$('#gallery').removeClass('cS-hidden');
}});
},
bindNextButton:function(){
$('.book-tour-proceed').unbind('click');
$('.book-tour-proceed').on('click', function(event){
if(!window.tourIsReservationOnly&&window.useWoocommerceForCheckout){
tours.addProductToCart();
}else{
$('#wait_loading').show();
tours.showTourBookingForm();
$('#wait_loading').hide();
$('body,html').animate({
scrollTop: 0
}, 800);
}
event.preventDefault();
});
},
bindResetButton:function(){
$('.book-tour-reset').unbind('click');
$('.book-tour-reset').on('click', function(event){
window.bookingRequest={};
window.bookingRequest.extraItems={};
window.bookingRequest.adults=1;
window.bookingRequest.children=0;
window.bookingRequest.extraItemsTotalPrice=0;
window.bookingRequest.totalPrice=0;
window.bookingRequest.totalTourOnlyPrice=0;
window.bookingRequest.totalDays=1;
event.preventDefault();
$(".extra_item_quantity").val("0");
$("#booking_form_adults").val("1");
$("#booking_form_children").val("0");
$("span.adults_text").html("1");
$("span.children_text").html("0");
$("#start_date_span").html('');
$("#start_date").val('');
$(".dates_row").hide();
$(".price_row").hide();
$('.booking-commands').hide();
$('table.tour_price_breakdown thead').html('');
$('table.tour_price_breakdown tbody').html('');
$('table.tour_price_breakdown tfoot').html('');
$('.reservation_total').html(tours.formatPrice(window.bookingRequest.totalTourOnlyPrice));
$('.total_price').html(tours.formatPrice(window.bookingRequest.totalPrice));
$('.confirm_total_price_p').html(tours.formatPrice(window.bookingRequest.totalPrice));
$('.extra_items_total').html(tours.formatPrice(window.bookingRequest.extraItemsTotalPrice));
$('.extra_items_total').html(tours.formatPrice(window.bookingRequest.extraItemsTotalPrice));
$('table.extra_items_price_breakdown tbody').html('');
tours.bindRequiredExtraItems();
tours.populateTourScheduleEntries(window.tourId, window.currentDay, window.currentMonth, window.currentYear, tours.refreshDatePicker);
});
},
bindCancelButton: function(){
$('#cancel-tour-booking').unbind('click');
$('#cancel-tour-booking').on('click', function(event){
tours.hideTourBookingForm();
tours.showTourScreen();
event.preventDefault();
});
},
showTourScreen:function (){
$('.three-fourth .lSSlideOuter').show();
$('.three-fourth .inner-nav').show();
$('.three-fourth .tab-content').show();
$(".tab-content").hide();
$(".tab-content:first").show();
$(".inner-nav li:first").addClass("active");
},
showTourBookingForm:function (){
$('.booking_form_adults_p').html(window.bookingRequest.adults);
$('.booking_form_children_p').html(window.bookingRequest.children);
$('.booking_form_tour_date_p').html($("#start_date_span").html());
$('.booking_form_tour_name_p').html(window.tourTitle);
$('.booking_form_reservation_total_p').html(tours.formatPrice(window.bookingRequest.totalTourOnlyPrice));
$('.booking_form_extra_items_total_p').html(tours.formatPrice(window.bookingRequest.extraItemsTotalPrice));
$('.booking_form_total_p').html(tours.formatPrice(window.bookingRequest.totalPrice));
$('.three-fourth .lSSlideOuter').hide();
$('.three-fourth .inner-nav').hide();
$('.three-fourth .tab-content').hide();
$('#tour-booking-form').show();
$('html, body').animate({
scrollTop: $('#tour-booking-form').offset().top
}, 1000);
},
hideTourBookingForm:function (){
$('#tour-booking-form').hide();
},
showTourConfirmationForm:function (){
$('#tour-confirmation-form').show();
},
selectStartDate: function(time, dateText){
$(".price_row").show();
$('.dates_row').show();
$('.booking-commands').show();
$('table.tour_price_breakdown thead').html('');
$('table.tour_price_breakdown tbody').html('');
$('table.tour_price_breakdown tfoot').html('');
$("#start_date").val(time);
$("#start_date_span").html(dateText);
window.bookingRequest.selectedTime=time;
window.bookingRequest.selectedDate=dateText;
var tourStartDate=tours.convertLocalToUTC(new Date(parseInt($("#start_date").val())));
tourStartDate=tourStartDate.getFullYear() + "-" + (tourStartDate.getMonth() + 1) + "-" + tourStartDate.getDate();
window.bookingRequest.scheduleId=tours.getTourScheduleId(window.tourId, tourStartDate);
window.bookingRequest.maxCount=tours.getMaxPeople(window.bookingRequest.scheduleId);
window.bookingRequest.maxCount=window.bookingRequest.maxCount > 0 ? window.bookingRequest.maxCount:1;
window.bookingRequest.totalDays=tours.getTourScheduleDurationDays(window.bookingRequest.scheduleId);
$("#duration_days").val(window.bookingRequest.totalDays);
$("#duration_days_span").html(window.bookingRequest.totalDays);
tours.bindTourDropDowns();
},
getSelectedStartTime: function (){
if($("#start_date").val()){
return parseInt($("#start_date").val());
}
return null;
},
getSelectedStartDate: function (){
if($("#start_date").val()){
return tours.convertLocalToUTC(new Date(parseInt($("#start_date").val())));
}
return null;
},
addProductToCart:function (){
var tourDate=tours.getSelectedStartDate();
tourDate=tourDate.getFullYear() + "-" + (tourDate.getMonth() + 1) + "-" + tourDate.getDate();
var tourScheduleId=tours.getTourScheduleId(window.tourId, tourDate);
window.bookingRequest.adults=$("#booking_form_adults").val();
window.bookingRequest.children=$("#booking_form_children").val();
var dataObj={
'action':'tour_booking_add_to_cart_ajax_request',
'user_id':window.currentUserId,
'tour_id':window.tourId,
'tour_schedule_id':tourScheduleId,
'tour_date':tourDate,
'extra_items':window.bookingRequest.extraItems,
'adults':window.bookingRequest.adults,
'children':window.bookingRequest.children,
'nonce':BYTAjax.nonce
};
$.each(window.bookingFormFields, function(index, field){
if(field.hide!=='1'){
dataObj[field.id]=$('#' + field.id).val();
}});
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
success:function(data){
tours.redirectToCart();
},
error: function(errorThrown){
console.log(errorThrown);
}});
},
redirectToCart:function(){
top.location.href=window.wooCartPageUri;
},
bindTourRatesTable:function (){
$(".price_row").show();
$('table.tour_price_breakdown thead').html('');
$('table.tour_price_breakdown tfoot').html('');
$('table.tour_price_breakdown tbody').html('');
var adults=$('#booking_form_adults').val();
if(!adults)
adults=1;
var children=$('#booking_form_children').val();
if(!children)
children=0;
var selectedStartDate=tours.getSelectedStartDate();
var selectedStartTime=selectedStartDate.valueOf();
var colCount=2;
var headerRow='<tr class="rates_head_row">';
headerRow +='<th>' + window.dateLabel + '</th>';
if(!window.tourIsPricePerGroup){
headerRow +='<th>' + window.adultCountLabel + '</th>';
headerRow +='<th>' + window.pricePerAdultLabel + '</th>';
headerRow +='<th>' + window.childCountLabel + '</th>';
headerRow +='<th>' + window.pricePerChildLabel + '</th>';
colCount=6;
}
headerRow +='<th>' + window.pricePerDayLabel + '</th>';
headerRow +='</tr>';
$('table.tour_price_breakdown thead').append(headerRow);
var footerRow='<tr>';
footerRow +='<th colspan="' + (colCount - 1) + '">' + window.priceTotalLabel + '</th>';
footerRow +='<td class="reservation_total">0</td>';
footerRow +='</tr>';
$('table.tour_price_breakdown tfoot').append(footerRow);
if(selectedStartTime){
window.bookingRequest.totalPrice=0;
window.bookingRequest.totalTourOnlyPrice=0;
tours.buildTourRateRow(selectedStartTime, adults, children);
}},
buildTourRateRow:function (startTime, adults, children){
var d=new Date(startTime);
var day=d.getDate();
var month=d.getMonth() + 1;
var year=d.getFullYear();
var dateValue=day + "-" + month + "-" + year;
var dataObj={
'action':'tour_get_price_request',
'tourId':window.tourId,
'dateValue':dateValue,
'nonce':BYTAjax.nonce
};
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
dataType: 'json',
success:function(prices){
var tableRow='';
window.rateTableRowIndex++;
var pricePerTour=parseFloat(prices.price);
var pricePerChild=0;
var totalPrice=0;
tableRow +='<tr>';
tableRow +='<td>' + dateValue + '</td>';
if(!window.tourIsPricePerGroup){
pricePerChild=parseFloat(prices.child_price);
tableRow +='<td>' + adults + '</td>';
tableRow +='<td>' + tours.formatPrice(pricePerTour) + '</td>';
tableRow +='<td>' + children + '</td>';
tableRow +='<td>' + tours.formatPrice(pricePerChild) + '</td>';
totalPrice=(pricePerTour * adults) + (pricePerChild * children);
}else{
totalPrice=pricePerTour;
}
tableRow +='<td>' + tours.formatPrice(totalPrice) + '</td>';
window.bookingRequest.totalPrice=totalPrice + window.bookingRequest.extraItemsTotalPrice;
window.bookingRequest.totalTourOnlyPrice=totalPrice;
tableRow +='</tr>';
$('table.tour_price_breakdown tbody').append(tableRow);
$('.reservation_total').html(tours.formatPrice(window.bookingRequest.totalTourOnlyPrice));
$('.total_price').html(tours.formatPrice(window.bookingRequest.totalPrice));
$(".confirm_total_price_p").html(tours.formatPrice(window.bookingRequest.totalPrice));
$('#datepicker_loading').hide();
$("table.responsive").trigger('updated');
},
error: function(errorThrown){
console.log(errorThrown);
}});
},
bindTourDropDowns:function(){
var countOffset=window.bookingRequest.maxCount - window.bookingRequest.adults - window.bookingRequest.children;
var maxAdultCount=window.bookingRequest.adults + countOffset;
if(maxAdultCount < window.bookingRequest.adults){
maxAdultCount=parseInt(window.bookingRequest.adults);
}else if(maxAdultCount > window.bookingRequest.maxCount){
maxAdultCount=parseInt(window.bookingRequest.adults);
}
$('#booking_form_adults').unbind();
$('#booking_form_adults').find('option').remove();
for(var i=1; i <=maxAdultCount; i++){
$('<option ' + (i==window.bookingRequest.adults ? 'selected':'') + '>').val(i).text(i).appendTo('#booking_form_adults');
}
$('#booking_form_adults').change(function (e){
window.bookingRequest.adults=parseInt($(this).val());
$('span.adults_text').html(window.bookingRequest.adults);
tours.bindTourDropDowns();
tours.bindTourRatesTable();
tours.recalculateExtraItemTotals();
});
$.uniform.update("#booking_form_adults");
countOffset=window.bookingRequest.maxCount - window.bookingRequest.adults - window.bookingRequest.children;
var maxChildrenCount=window.bookingRequest.children + countOffset;
if(maxChildrenCount < window.bookingRequest.children){
maxChildrenCount=parseInt(window.bookingRequest.children);
}else if(maxChildrenCount > window.bookingRequest.maxCount){
maxChildrenCount=parseInt(window.bookingRequest.children);
}
$('#booking_form_children').unbind();
$('#booking_form_children').find('option').remove();
$('<option selected>').val(0).text(0).appendTo('#booking_form_children');
for(var j=1; j <=maxChildrenCount; j++){
$('<option ' + (j==window.bookingRequest.children ? 'selected':'') + '>').val(j).text(j).appendTo('#booking_form_children');
}
$('#booking_form_children').change(function (e){
window.bookingRequest.children=parseInt($(this).val());
$('span.children_text').html(window.bookingRequest.children);
tours.bindTourDropDowns();
tours.bindTourRatesTable();
tours.recalculateExtraItemTotals();
});
$.uniform.update("#booking_form_children");
},
recalculateExtraItemTotals: function(){
if(Object.size(window.bookingRequest.extraItems) > 0){
if(window.bookingRequest.extraItemsTotalPrice > 0){
window.bookingRequest.totalPrice=window.bookingRequest.totalTourOnlyPrice;
window.bookingRequest.extraItemsTotalPrice=0;
}
$.each(window.bookingRequest.extraItems, function(id, extraItem){
var extraItemPrice=extraItem.price;
if(extraItem.pricePerPerson){
var adjustedChildren=window.bookingRequest.children;
adjustedChildren=adjustedChildren > 0 ? adjustedChildren:0;
extraItemPrice=(window.bookingRequest.adults * extraItemPrice) + (adjustedChildren * extraItemPrice);
}
if(extraItem.pricePerDay){
extraItemPrice=extraItemPrice * window.bookingRequest.totalDays;
}
extraItem.summedPrice=extraItem.quantity * extraItemPrice;
window.bookingRequest.totalPrice +=extraItem.summedPrice;
window.bookingRequest.extraItemsTotalPrice +=extraItem.summedPrice;
});
$('.extra_items_total').html(tours.formatPrice(window.bookingRequest.extraItemsTotalPrice));
$('.total_price').html(tours.formatPrice(window.bookingRequest.totalPrice));
}},
buildExtraItemsTable:function(){
$('table.extra_items_price_breakdown thead').html('');
$('table.extra_items_price_breakdown tfoot').html('');
$('table.extra_items_price_breakdown tbody').html('');
var headerRow='';
headerRow +='<tr class="rates_head_row">';
headerRow +='<th>' + window.itemLabel + '</th>';
headerRow +='<th>' + window.priceLabel + '</th>';
headerRow +='</tr>';
$('table.extra_items_price_breakdown thead').append(headerRow);
var footerRow='';
footerRow +='<tr>';
footerRow +='<th>' + window.priceTotalLabel + '</th>';
footerRow +='<td class="extra_items_total">' + tours.formatPrice(0) + '</td>';
footerRow +='</tr>';
$('table.extra_items_price_breakdown tfoot').append(footerRow);
},
bindExtraItemsQuantitySelect: function(){
$('select.extra_item_quantity').unbind('change');
$('select.extra_item_quantity').on('change', function(e){
var quantity=parseInt($(this).val());
var extraItemId=$(this).attr('id').replace('extra_item_quantity_', '');
tours.updateExtraItemSelection(extraItemId, quantity);
});
},
updateExtraItemSelection: function(extraItemId, quantity){
if(extraItemId > 0){
var extraItemPrice=parseFloat($('#extra_item_price_' + extraItemId).val());
var extraItemTitle=$('#extra_item_title_' + extraItemId).html();
var extraItemPricePerPerson=parseInt($('#extra_item_price_per_person_' + extraItemId).val());
var extraItemPricePerDay=parseInt($('#extra_item_price_per_day_' + extraItemId).val());
var oldExtraItem=null;
var extraItem={};
var extraItemRows='';
var pricingMethod='';
if(extraItemId in window.bookingRequest.extraItems){
oldExtraItem=window.bookingRequest.extraItems[extraItemId];
window.bookingRequest.totalPrice -=parseFloat(oldExtraItem.summedPrice);
window.bookingRequest.extraItemsTotalPrice -=parseFloat(oldExtraItem.summedPrice);
delete window.bookingRequest.extraItems[extraItemId];
}
$('table.extra_items_price_breakdown tbody').html('');
if(quantity > 0){
extraItem.quantity=quantity;
extraItem.id=extraItemId;
extraItem.price=extraItemPrice;
extraItem.pricePerPerson=extraItemPricePerPerson;
extraItem.pricePerDay=extraItemPricePerDay;
if(extraItem.pricePerPerson){
var adjustedChildren=window.bookingRequest.children;
adjustedChildren=adjustedChildren > 0 ? adjustedChildren:0;
extraItemPrice=(window.bookingRequest.adults * extraItemPrice) + (adjustedChildren * extraItemPrice);
}
if(extraItem.pricePerDay){
extraItemPrice=extraItemPrice * window.bookingRequest.totalDays;
}
extraItem.summedPrice=extraItem.quantity * extraItemPrice;
extraItem.title=extraItemTitle;
window.bookingRequest.totalPrice +=extraItem.summedPrice;
window.bookingRequest.extraItemsTotalPrice +=extraItem.summedPrice;
window.bookingRequest.extraItems[extraItemId]=extraItem;
}
if(Object.size(window.bookingRequest.extraItems) > 0){
$.each(window.bookingRequest.extraItems, function(index, value){
pricingMethod='';
if(value.pricePerDay&&value.pricePerPerson)
pricingMethod='(' + window.pricedPerDayPerPersonLabel + ')';
else if(value.pricePerDay)
pricingMethod='(' + window.pricedPerDayLabel + ')';
else if(value.pricePerPerson)
pricingMethod='(' + window.pricedPerPersonLabel + ')';
extraItemRows +='<tr class="extra_item_row_' + value.Id + '"><td>' + value.quantity + ' x ' + value.title + ' ' + (pricingMethod) + ' </td><td>' + tours.formatPrice(value.summedPrice) + '</td></tr>';
});
}
$('table.extra_items_price_breakdown tbody').html(extraItemRows);
$('.extra_items_total').html(tours.formatPrice(window.bookingRequest.extraItemsTotalPrice));
$('.total_price').html(tours.formatPrice(window.bookingRequest.totalPrice));
$.uniform.update(".extra_item_quantity");
}},
bindTourDatePicker:function  (){
if(typeof $('.tour_schedule_datepicker')!=='undefined'){
$('.tour_schedule_datepicker').datepicker({
dateFormat: window.datepickerDateFormat,
numberOfMonths: [2, 2],
minDate: 0,
beforeShowDay: function(d){
var dUtc=Date.UTC(d.getFullYear(), d.getMonth(), d.getDate());
var selectedTime=null;
if($("#start_date").val()){
selectedTime=parseInt($("#start_date").val());
}
if(window.tourScheduleEntries){
var dateTextForCompare=d.getFullYear() + '-' + ("0" + (d.getMonth() + 1)).slice(-2) + '-' + ("0" + d.getDate()).slice(-2);
var dateTextForCompare2=d.getFullYear() + '-' + ("0" + (d.getMonth() + 1)).slice(-2) + '-' + ("0" + d.getDate()).slice(-2) + ' 00:00:00';
if(dUtc==selectedTime)
return [false, 'dp-hightlight dp-highlight-selected'];
if($.inArray(dateTextForCompare, window.tourScheduleEntries)==-1&&$.inArray(dateTextForCompare2, window.tourScheduleEntries)==-1)
return [false, 'ui-datepicker-unselectable ui-state-disabled'];
}
return [true, "dp-highlight"];
},
onSelect: function(dateText, inst){
var selectedTime=Date.UTC(inst.currentYear, inst.currentMonth, inst.currentDay);
tours.selectStartDate(selectedTime, dateText);
tours.bindTourRatesTable();
tours.recalculateExtraItemTotals();
},
onChangeMonthYear: function (year, month, inst){
window.currentMonth=month;
window.currentYear=year;
window.currentDay=1;
tours.populateTourScheduleEntries(window.tourId, window.currentDay, window.currentMonth, window.currentYear,tours.refreshDatePicker);
}});
}},
refreshDatePicker:function(){
if(typeof $('.tour_schedule_datepicker')!=='undefined'){
$('.tour_schedule_datepicker').datepicker("refresh");
}
$('#wait_loading').hide();
},
processTourBooking:function (){
$('#wait_loading').show();
var tourDate=tours.getSelectedStartDate();
tourDate=tourDate.getFullYear() + "-" + (tourDate.getMonth() + 1) + "-" + tourDate.getDate();
var tourScheduleId=tours.getTourScheduleId(window.tourId, tourDate);
var tourStartDateText=$("#start_date_span").html();
var adults=$("#booking_form_adults").val();
var children=$("#booking_form_children").val();
var cValS=$('#c_val_s_tour').val();
var cVal1=$('#c_val_1_tour').val();
var cVal2=$('#c_val_2_tour').val();
var dataObj={
'action':'tour_process_booking_ajax_request',
'user_id':window.currentUserId,
'tour_schedule_id':tourScheduleId,
'tour_date':tourDate,
'extra_items':window.bookingRequest.extraItems,
'adults':window.bookingRequest.adults,
'children':window.bookingRequest.children,
'c_val_s':cValS,
'c_val_1':cVal1,
'c_val_2':cVal2,
'nonce':BYTAjax.nonce
};
$.each(window.bookingFormFields, function(index, field){
if(field.hide!=='1'){
dataObj[field.id]=$('#' + field.id).val();
$('.confirm_' + field.id + '_p').html($('#' + field.id).val());
}});
$(".confirm_tour_date_p").html(tourStartDateText);
$(".confirm_tour_title_p").html(window.tourTitle);
$(".confirm_adults_p").html(adults);
$(".confirm_children_p").html(children);
$(".confirm_reservation_total_p").html(tours.formatPrice(window.bookingRequest.totalTourOnlyPrice));
$(".confirm_extra_items_total_p").html(tours.formatPrice(window.bookingRequest.extraItemsTotalPrice));
$(".confirm_total_price_p").html(tours.formatPrice(window.bookingRequest.totalPrice));
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
success:function(data){
if(data=='captcha_error'){
$("div.error div p").html(window.InvalidCaptchaMessage);
$("div.error").show();
}else{
$("div.error div p").html('');
$("div.error").hide();
tours.hideTourBookingForm();
tours.showTourConfirmationForm();
}
$('#wait_loading').hide();
},
error: function(errorThrown){
console.log(errorThrown);
}});
},
getTourScheduleId:function (tourId, date){
var scheduleId=0;
var dataObj={
'action':'tour_available_schedule_id_request',
'tourId':tourId,
'dateValue':date,
'nonce':BYTAjax.nonce
};
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
async: false,
success:function(data){
scheduleId=data;
},
error: function(errorThrown){
console.log(errorThrown);
}});
return scheduleId;
},
getMaxPeople:function (tourScheduleId){
var tourStartDate=tours.getSelectedStartDate();
tourStartDate=tourStartDate.getFullYear() + "-" + (tourStartDate.getMonth() + 1) + "-" + tourStartDate.getDate();
var max_people=0;
var dataObj={
'action':'tour_max_people_ajax_request',
'tourScheduleId':tourScheduleId,
'tourId':window.tourId,
'dateValue':tourStartDate,
'nonce':BYTAjax.nonce
};
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
async: false,
success:function(data){
max_people=data;
},
error: function(errorThrown){
console.log(errorThrown);
}});
return max_people;
},
getTourScheduleDurationDays:function (scheduleId){
var days=0;
var dataObj={
'action':'tour_get_schedule_duration_days_request',
'schedule_id':scheduleId,
'nonce':BYTAjax.nonce
};
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
async: false,
success:function(data){
days=parseInt(data);
},
error: function(errorThrown){
}});
return days;
},
getTourIsReservationOnly:function (tourId){
var isReservationOnly=0;
var dataObj={
'action':'tour_is_reservation_only_request',
'tour_id':tourId,
'nonce':BYTAjax.nonce
};
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
async: false,
success:function(data){
isReservationOnly=parseInt(data);
},
error: function(errorThrown){
}});
return isReservationOnly;
},
populateTourScheduleEntries:function (tourId, day, month, year, callDelegate){
var dateArray=[];
var dataObj={
'action':'tour_schedule_dates_request',
'tourId':tourId,
'month':month,
'year':year,
'day':day,
'nonce':BYTAjax.nonce
};
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
async: true,
success:function(json){
var scheduleDates=JSON.parse(json);
var i=0;
for (i=0; i < scheduleDates.length; ++i){
if(scheduleDates[i].tour_date!==null){
dateArray.push(scheduleDates[i].tour_date);
}}
window.tourScheduleEntries=dateArray;
if(typeof(callDelegate)!=='undefined'){
callDelegate();
}},
error: function(errorThrown){
console.log(errorThrown);
}});
},
convertLocalToUTC:function (date){
return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
},
formatPrice: function(price){
if(window.currencySymbolShowAfter)
return price.toFixed(window.priceDecimalPlaces) + ' ' + window.currencySymbol;
else
return window.currencySymbol + ' ' + price.toFixed(window.priceDecimalPlaces);
},
};})(jQuery);
(function($){
$(document).ready(function (){
reviews.init();
});
var reviews={
init: function (){
$('.review-' + window.postType).on('click', function(event){
reviews.showReviewForm();
event.preventDefault();
});
$('.cancel-' + window.postType + '-review').on('click', function(event){
reviews.hideReviewForm();
event.preventDefault();
});
$('.review-' + window.postType + '-form').validate({
onkeyup: false,
rules: {
likes: "required",
dislikes: "required"
},
invalidHandler: function(e, validator){
var errors=validator.numberOfInvalids();
if(errors){
var message=errors==1 ? window.formSingleError:window.formMultipleError.format(errors);
$("div.error div p").html(message);
$("div.error").show();
}else{
$("div.error").hide();
}},
messages: {
likes: window.reviewFormLikesError,
dislikes: window.reviewFormDislikesError
},
submitHandler: function(){ reviews.processReview(); }});
},
showReviewForm:function (){
$('.three-fourth').hide();
$('.right-sidebar').hide();
$('.full-width.review-' + window.postType + '-section').show();
$('html, body').animate({
scrollTop: $('.full-width.review-' + window.postType + '-section').offset().top
}, 1000);
},
hideReviewForm:function (){
$('.three-fourth').show();
$('.right-sidebar').show();
$('.full-width.review-' + window.postType + '-section').hide();
},
processReview:function (){
var likes=$('#likes').val();
var dislikes=$('#dislikes').val();
var dataObj={
'action':'review_ajax_request',
'likes':likes,
'dislikes':dislikes,
'userId':window.currentUserId,
'postId':window.postId,
'nonce':BYTAjax.nonce
};
for (var i=0; i < window.reviewFields.length; i++){
var slug=window.reviewFields[i];
dataObj["reviewField_" + slug]=$("input[type='radio'][name='reviewField_" + slug + "']:checked").val();
}
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
success:function(data){
$('.review-' + window.postType).hide();
$('.review-form-thank-you').show();
reviews.hideReviewForm();
},
error: function(errorThrown){
}});
}};})(jQuery);
(function($){
$(document).ready(function (){
inquiry.init();
});
var inquiry={
init: function (){
$('.contact-' + window.postType).on('click', function(event){
inquiry.showInquiryForm();
event.preventDefault();
});
$('.cancel-' + window.postType + '-inquiry').on('click', function(event){
inquiry.hideInquiryForm();
event.preventDefault();
});
$('.' + window.postType + '-inquiry-form').validate({
onkeyup: false,
ignore: [],
invalidHandler: function(e, validator){
var errors=validator.numberOfInvalids();
if(errors){
var message=errors==1 ? window.formSingleError:window.formMultipleError.format(errors);
$("div.error div p").html(message);
$("div.error").show();
}else{
$("div.error").hide();
}},
submitHandler: function(){ inquiry.processInquiry(); }});
$.each(window.inquiryFormFields, function(index, field){
if(field.hide!=='1'&&field.id!==null&&field.id.length > 0){
var $input=null;
if(field.type=='text'||field.type=='email'){
$input=$('.' + window.postType + '-inquiry-form').find('input[name=' + field.id + ']');
}else if(field.type=='textarea'){
$input=$('.' + window.postType + '-inquiry-form').find('textarea[name=' + field.id + ']');
}
if($input!==null&&typeof($input)!=='undefined'){
if(field.required=='1'){
$input.rules('add', {
required: true,
messages: {
required: window.inquiryFormRequiredError
}});
}
if(field.type=='email'){
$input.rules('add', {
email: true,
messages: {
required: window.inquiryFormEmailError
}});
}}
}});
},
showInquiryForm:function (){
$('.three-fourth').hide();
$('.right-sidebar').hide();
$('.full-width.' + window.postType + '-inquiry-section').show();
$('html, body').animate({
scrollTop: $('.full-width.' + window.postType + '-inquiry-section').offset().top
}, 1000);
},
hideInquiryForm:function (){
$('.three-fourth').show();
$('.right-sidebar').show();
$('.full-width.' + window.postType + '-inquiry-section').hide();
},
processInquiry:function (){
var cValS=$('#c_val_s_inq').val();
var cVal1=$('#c_val_1_inq').val();
var cVal2=$('#c_val_2_inq').val();
var dataObj={
'action':'inquiry_ajax_request',
'userId':window.currentUserId,
'postId':window.postId,
'c_val_s':cValS,
'c_val_1':cVal1,
'c_val_2':cVal2,
'nonce':BYTAjax.nonce
};
$.each(window.inquiryFormFields, function(index, field){
if(field.hide!=='1'){
dataObj[field.id]=$('#' + field.id).val();
}});
$.ajax({
url: BYTAjax.ajaxurl,
data: dataObj,
success:function(data){
if(data=='captcha_error'){
$("div.error div p").html(window.InvalidCaptchaMessage);
$("div.error").show();
}else{
$("div.error div p").html('');
$("div.error").hide();
$('.contact-' + window.postType).hide();
inquiry.hideInquiryForm();
$('.inquiry-form-thank-you').show();
}},
error: function(errorThrown){
}});
}};})(jQuery);
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,n){function a(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!o&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[s]={exports:{}};t[s][0].call(p.exports,function(e){var r=t[s][1][e];return a(r||e)},p,p.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)a(n[s]);return a}({1:[function(e,t,r){"use strict";var n=e("./init"),a={init:function(e){this.get=n(e),e&&e.callback&&"function"==typeof e.callback&&e.callback(this.get)}};t.exports=a},{"./init":6}],2:[function(e,t,r){"use strict";var n=e("./terms"),a=e("./helpers/utils"),i={containers:{current:"sbjs_current",current_extra:"sbjs_current_add",first:"sbjs_first",first_extra:"sbjs_first_add",session:"sbjs_session",udata:"sbjs_udata",promocode:"sbjs_promo"},service:{migrations:"sbjs_migrations"},delimiter:"|||",aliases:{main:{type:"typ",source:"src",medium:"mdm",campaign:"cmp",content:"cnt",term:"trm",id:"id",platform:"plt",format:"fmt",tactic:"tct"},extra:{fire_date:"fd",entrance_point:"ep",referer:"rf"},session:{pages_seen:"pgs",current_page:"cpg"},udata:{visits:"vst",ip:"uip",agent:"uag"},promo:"code"},pack:{main:function(e){return i.aliases.main.type+"="+e.type+i.delimiter+i.aliases.main.source+"="+e.source+i.delimiter+i.aliases.main.medium+"="+e.medium+i.delimiter+i.aliases.main.campaign+"="+e.campaign+i.delimiter+i.aliases.main.content+"="+e.content+i.delimiter+i.aliases.main.term+"="+e.term+i.delimiter+i.aliases.main.id+"="+e.id+i.delimiter+i.aliases.main.platform+"="+e.platform+i.delimiter+i.aliases.main.format+"="+e.format+i.delimiter+i.aliases.main.tactic+"="+e.tactic},extra:function(e){return i.aliases.extra.fire_date+"="+a.setDate(new Date,e)+i.delimiter+i.aliases.extra.entrance_point+"="+document.location.href+i.delimiter+i.aliases.extra.referer+"="+(document.referrer||n.none)},user:function(e,t){return i.aliases.udata.visits+"="+e+i.delimiter+i.aliases.udata.ip+"="+t+i.delimiter+i.aliases.udata.agent+"="+navigator.userAgent},session:function(e){return i.aliases.session.pages_seen+"="+e+i.delimiter+i.aliases.session.current_page+"="+document.location.href},promo:function(e){return i.aliases.promo+"="+a.setLeadingZeroToInt(a.randomInt(e.min,e.max),e.max.toString().length)}}};t.exports=i},{"./helpers/utils":5,"./terms":9}],3:[function(e,t,r){"use strict";var n=e("../data").delimiter;t.exports={useBase64:!1,setBase64Flag:function(e){this.useBase64=e},encodeData:function(e){return encodeURIComponent(e).replace(/\!/g,"%21").replace(/\~/g,"%7E").replace(/\*/g,"%2A").replace(/\'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")},decodeData:function(e){try{return decodeURIComponent(e).replace(/\%21/g,"!").replace(/\%7E/g,"~").replace(/\%2A/g,"*").replace(/\%27/g,"'").replace(/\%28/g,"(").replace(/\%29/g,")")}catch(t){try{return unescape(e)}catch(r){return""}}},set:function(e,t,r,n,a){var i,s;if(r){var o=new Date;o.setTime(o.getTime()+60*r*1e3),i="; expires="+o.toGMTString()}else i="";s=n&&!a?";domain=."+n:"";var c=this.encodeData(t);this.useBase64&&(c=btoa(c).replace(/=+$/,"")),document.cookie=this.encodeData(e)+"="+c+i+s+"; path=/"},get:function(e){for(var t=this.encodeData(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var a=r[n];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(t)){var i=a.substring(t.length,a.length);if(/^[A-Za-z0-9+/]+$/.test(i))try{i=atob(i.padEnd(4*Math.ceil(i.length/4),"="))}catch(s){}return this.decodeData(i)}}return null},destroy:function(e,t,r){this.set(e,"",-1,t,r)},parse:function(e){var t=[],r={};if("string"==typeof e)t.push(e);else for(var a in e)e.hasOwnProperty(a)&&t.push(e[a]);for(var i=0;i<t.length;i++){var s;r[this.unsbjs(t[i])]={},s=this.get(t[i])?this.get(t[i]).split(n):[];for(var o=0;o<s.length;o++){var c=s[o].split("="),u=c.splice(0,1);u.push(c.join("=")),r[this.unsbjs(t[i])][u[0]]=this.decodeData(u[1])}}return r},unsbjs:function(e){return e.replace("sbjs_","")}}},{"../data":2}],4:[function(e,t,r){"use strict";t.exports={parse:function(e){for(var t=this.parseOptions,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={},a=14;a--;)n[t.key[a]]=r[a]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,function(e,r,a){r&&(n[t.q.name][r]=a)}),n},parseOptions:{strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},getParam:function(e){for(var t={},r=(e||window.location.search.substring(1)).split("&"),n=0;n<r.length;n++){var a=r[n].split("=");if("undefined"==typeof t[a[0]])t[a[0]]=a[1];else if("string"==typeof t[a[0]]){var i=[t[a[0]],a[1]];t[a[0]]=i}else t[a[0]].push(a[1])}return t},getHost:function(e){return this.parse(e).host.replace("www.","")}}},{}],5:[function(e,t,r){"use strict";t.exports={escapeRegexp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},setDate:function(e,t){var r=e.getTimezoneOffset()/60,n=e.getHours(),a=t||0===t?t:-r;return e.setHours(n+r+a),e.getFullYear()+"-"+this.setLeadingZeroToInt(e.getMonth()+1,2)+"-"+this.setLeadingZeroToInt(e.getDate(),2)+" "+this.setLeadingZeroToInt(e.getHours(),2)+":"+this.setLeadingZeroToInt(e.getMinutes(),2)+":"+this.setLeadingZeroToInt(e.getSeconds(),2)},setLeadingZeroToInt:function(e,t){for(var r=e+"";r.length<t;)r="0"+r;return r},randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e}}},{}],6:[function(e,t,r){"use strict";var n=e("./data"),a=e("./terms"),i=e("./helpers/cookies"),s=e("./helpers/uri"),o=e("./helpers/utils"),c=e("./params"),u=e("./migrations");t.exports=function(e){var t,r,p,f,m,d,l,g,h,y,_,v,b,x=c.fetch(e),k=s.getParam(),w=x.domain.host,q=x.domain.isolate,I=x.lifetime;function j(e){switch(e){case a.traffic.utm:t=a.traffic.utm,r="undefined"!=typeof k.utm_source?k.utm_source:"undefined"!=typeof k.gclid?"google":"undefined"!=typeof k.yclid?"yandex":a.none,p="undefined"!=typeof k.utm_medium?k.utm_medium:"undefined"!=typeof k.gclid?"cpc":"undefined"!=typeof k.yclid?"cpc":a.none,f="undefined"!=typeof k.utm_campaign?k.utm_campaign:"undefined"!=typeof k[x.campaign_param]?k[x.campaign_param]:"undefined"!=typeof k.gclid?"google_cpc":"undefined"!=typeof k.yclid?"yandex_cpc":a.none,m="undefined"!=typeof k.utm_content?k.utm_content:"undefined"!=typeof k[x.content_param]?k[x.content_param]:a.none,l=k.utm_id||a.none,g=k.utm_source_platform||a.none,h=k.utm_creative_format||a.none,y=k.utm_marketing_tactic||a.none,d="undefined"!=typeof k.utm_term?k.utm_term:"undefined"!=typeof k[x.term_param]?k[x.term_param]:function(){var e=document.referrer;if(k.utm_term)return k.utm_term;if(!(e&&s.parse(e).host&&s.parse(e).host.match(/^(?:.*\.)?yandex\..{2,9}$/i)))return!1;try{return s.getParam(s.parse(document.referrer).query).text}catch(t){return!1}}()||a.none;break;case a.traffic.organic:t=a.traffic.organic,r=r||s.getHost(document.referrer),p=a.referer.organic,f=a.none,m=a.none,d=a.none,l=a.none,g=a.none,h=a.none,y=a.none;break;case a.traffic.referral:t=a.traffic.referral,r=r||s.getHost(document.referrer),p=p||a.referer.referral,f=a.none,m=s.parse(document.referrer).path,d=a.none,l=a.none,g=a.none,h=a.none,y=a.none;break;case a.traffic.typein:t=a.traffic.typein,r=x.typein_attributes.source,p=x.typein_attributes.medium,f=a.none,m=a.none,d=a.none,l=a.none,g=a.none,h=a.none,y=a.none;break;default:t=a.oops,r=a.oops,p=a.oops,f=a.oops,m=a.oops,d=a.oops,l=a.oops,g=a.oops,h=a.oops,y=a.oops}var i={type:t,source:r,medium:p,campaign:f,content:m,term:d,id:l,platform:g,format:h,tactic:y};return n.pack.main(i)}function R(e){var t=document.referrer;switch(e){case a.traffic.organic:return!!t&&H(t)&&function(e){var t=new RegExp("^(?:.*\\.)?"+o.escapeRegexp("yandex")+"\\..{2,9}$"),n=new RegExp(".*"+o.escapeRegexp("text")+"=.*"),a=new RegExp("^(?:www\\.)?"+o.escapeRegexp("google")+"\\..{2,9}$");if(s.parse(e).query&&s.parse(e).host.match(t)&&s.parse(e).query.match(n))return r="yandex",!0;if(s.parse(e).host.match(a))return r="google",!0;if(!s.parse(e).query)return!1;for(var i=0;i<x.organics.length;i++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(x.organics[i].host)+"$","i"))&&s.parse(e).query.match(new RegExp(".*"+o.escapeRegexp(x.organics[i].param)+"=.*","i")))return r=x.organics[i].display||x.organics[i].host,!0;if(i+1===x.organics.length)return!1}}(t);case a.traffic.referral:return!!t&&H(t)&&function(e){if(!(x.referrals.length>0))return r=s.getHost(e),!0;for(var t=0;t<x.referrals.length;t++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(x.referrals[t].host)+"$","i")))return r=x.referrals[t].display||x.referrals[t].host,p=x.referrals[t].medium||a.referer.referral,!0;if(t+1===x.referrals.length)return r=s.getHost(e),!0}}(t);default:return!1}}function H(e){if(x.domain){if(q)return s.getHost(e)!==s.getHost(w);var t=new RegExp("^(?:.*\\.)?"+o.escapeRegexp(w)+"$","i");return!s.getHost(e).match(t)}return s.getHost(e)!==s.getHost(document.location.href)}function D(){i.set(n.containers.current_extra,n.pack.extra(x.timezone_offset),I,w,q),i.get(n.containers.first_extra)||i.set(n.containers.first_extra,n.pack.extra(x.timezone_offset),I,w,q)}return i.setBase64Flag(x.base64),u.go(I,w,q),i.set(n.containers.current,function(){var e;if("undefined"!=typeof k.utm_source||"undefined"!=typeof k.utm_medium||"undefined"!=typeof k.utm_campaign||"undefined"!=typeof k.utm_content||"undefined"!=typeof k.utm_term||"undefined"!=typeof k.utm_id||"undefined"!=typeof k.utm_source_platform||"undefined"!=typeof k.utm_creative_format||"undefined"!=typeof k.utm_marketing_tactic||"undefined"!=typeof k.gclid||"undefined"!=typeof k.yclid||"undefined"!=typeof k[x.campaign_param]||"undefined"!=typeof k[x.term_param]||"undefined"!=typeof k[x.content_param])D(),e=j(a.traffic.utm);else if(R(a.traffic.organic))D(),e=j(a.traffic.organic);else if(!i.get(n.containers.session)&&R(a.traffic.referral))D(),e=j(a.traffic.referral);else{if(i.get(n.containers.first)||i.get(n.containers.current))return i.get(n.containers.current);D(),e=j(a.traffic.typein)}return e}(),I,w,q),i.get(n.containers.first)||i.set(n.containers.first,i.get(n.containers.current),I,w,q),i.get(n.containers.udata)?(_=parseInt(i.parse(n.containers.udata)[i.unsbjs(n.containers.udata)][n.aliases.udata.visits])||1,_=i.get(n.containers.session)?_:_+1,v=n.pack.user(_,x.user_ip)):(_=1,v=n.pack.user(_,x.user_ip)),i.set(n.containers.udata,v,I,w,q),i.get(n.containers.session)?(b=parseInt(i.parse(n.containers.session)[i.unsbjs(n.containers.session)][n.aliases.session.pages_seen])||1,b+=1):b=1,i.set(n.containers.session,n.pack.session(b),x.session_length,w,q),x.promocode&&!i.get(n.containers.promocode)&&i.set(n.containers.promocode,n.pack.promo(x.promocode),I,w,q),i.parse(n.containers)}},{"./data":2,"./helpers/cookies":3,"./helpers/uri":4,"./helpers/utils":5,"./migrations":7,"./params":8,"./terms":9}],7:[function(e,t,r){"use strict";var n=e("./data"),a=e("./helpers/cookies");t.exports={go:function(e,t,r){var i,s=this.migrations,o={l:e,d:t,i:r};if(a.get(n.containers.first)||a.get(n.service.migrations)){if(!a.get(n.service.migrations))for(i=0;i<s.length;i++)s[i].go(s[i].id,o)}else{var c=[];for(i=0;i<s.length;i++)c.push(s[i].id);var u="";for(i=0;i<c.length;i++)u+=c[i]+"=1",i<c.length-1&&(u+=n.delimiter);a.set(n.service.migrations,u,o.l,o.d,o.i)}},migrations:[{id:"1418474375998",version:"1.0.0-beta",go:function(e,t){var r=e+"=1",i=e+"=0",s=function(e,t,r){return t||r?e:n.delimiter};try{var o=[];for(var c in n.containers)n.containers.hasOwnProperty(c)&&o.push(n.containers[c]);for(var u=0;u<o.length;u++)if(a.get(o[u])){var p=a.get(o[u]).replace(/(\|)?\|(\|)?/g,s);a.destroy(o[u],t.d,t.i),a.destroy(o[u],t.d,!t.i),a.set(o[u],p,t.l,t.d,t.i)}a.get(n.containers.session)&&a.set(n.containers.session,n.pack.session(0),t.l,t.d,t.i),a.set(n.service.migrations,r,t.l,t.d,t.i)}catch(f){a.set(n.service.migrations,i,t.l,t.d,t.i)}}}]}},{"./data":2,"./helpers/cookies":3}],8:[function(e,t,r){"use strict";var n=e("./terms"),a=e("./helpers/uri");t.exports={fetch:function(e){var t=e||{},r={};if(r.lifetime=this.validate.checkFloat(t.lifetime)||6,r.lifetime=parseInt(30*r.lifetime*24*60),r.session_length=this.validate.checkInt(t.session_length)||30,r.timezone_offset=this.validate.checkInt(t.timezone_offset),r.base64=t.base64||!1,r.campaign_param=t.campaign_param||!1,r.term_param=t.term_param||!1,r.content_param=t.content_param||!1,r.user_ip=t.user_ip||n.none,t.promocode?(r.promocode={},r.promocode.min=parseInt(t.promocode.min)||1e5,r.promocode.max=parseInt(t.promocode.max)||999999):r.promocode=!1,t.typein_attributes&&t.typein_attributes.source&&t.typein_attributes.medium?(r.typein_attributes={},r.typein_attributes.source=t.typein_attributes.source,r.typein_attributes.medium=t.typein_attributes.medium):r.typein_attributes={source:"(direct)",medium:"(none)"},t.domain&&this.validate.isString(t.domain)?r.domain={host:t.domain,isolate:!1}:t.domain&&t.domain.host?r.domain=t.domain:r.domain={host:a.getHost(document.location.hostname),isolate:!1},r.referrals=[],t.referrals&&t.referrals.length>0)for(var i=0;i<t.referrals.length;i++)t.referrals[i].host&&r.referrals.push(t.referrals[i]);if(r.organics=[],t.organics&&t.organics.length>0)for(var s=0;s<t.organics.length;s++)t.organics[s].host&&t.organics[s].param&&r.organics.push(t.organics[s]);return r.organics.push({host:"bing.com",param:"q",display:"bing"}),r.organics.push({host:"yahoo.com",param:"p",display:"yahoo"}),r.organics.push({host:"about.com",param:"q",display:"about"}),r.organics.push({host:"aol.com",param:"q",display:"aol"}),r.organics.push({host:"ask.com",param:"q",display:"ask"}),r.organics.push({host:"globososo.com",param:"q",display:"globo"}),r.organics.push({host:"go.mail.ru",param:"q",display:"go.mail.ru"}),r.organics.push({host:"rambler.ru",param:"query",display:"rambler"}),r.organics.push({host:"tut.by",param:"query",display:"tut.by"}),r.referrals.push({host:"t.co",display:"twitter.com"}),r.referrals.push({host:"plus.url.google.com",display:"plus.google.com"}),r},validate:{checkFloat:function(e){return!(!e||!this.isNumeric(parseFloat(e)))&&parseFloat(e)},checkInt:function(e){return!(!e||!this.isNumeric(parseInt(e)))&&parseInt(e)},isNumeric:function(e){return!isNaN(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)}}}},{"./helpers/uri":4,"./terms":9}],9:[function(e,t,r){"use strict";t.exports={traffic:{utm:"utm",organic:"organic",referral:"referral",typein:"typein"},referer:{referral:"referral",organic:"organic",social:"social"},none:"(none)",oops:"(Houston, we have a problem)"}},{}]},{},[1])(1)});
!function(t){"use strict";const e=t.params,n=(document.querySelector.bind(document),(t,e)=>e.split(".").reduce((t,e)=>t&&t[e],t)),s=()=>null,i=t=>null===t||t===undefined?"":t,o="wc/store/checkout";function a(t){window.wp&&window.wp.data&&window.wp.data.dispatch&&window.wc&&window.wc.wcBlocksData&&window.wp.data.dispatch(window.wc.wcBlocksData.CHECKOUT_STORE_KEY).setExtensionData("woocommerce/order-attribution",t,!0)}function r(){return"undefined"!=typeof sbjs}function c(){if(window.wp&&window.wp.data&&"function"==typeof window.wp.data.subscribe){const e=window.wp.data.subscribe(function(){e(),a(t.getAttributionData())},o)}}t.getAttributionData=function(){const i=e.allowTracking&&r()?n:s,o=r()?sbjs.get:{},a=Object.entries(t.fields).map(([t,e])=>[t,i(o,e)]);return Object.fromEntries(a)},t.setOrderTracking=function(n){if(e.allowTracking=n,n){if(!r())return;sbjs.init({lifetime:Number(e.lifetime),session_length:Number(e.session),base64:Boolean(e.base64),timezone_offset:"0"})}else!function(){const t=window.location.hostname;["sbjs_current","sbjs_current_add","sbjs_first","sbjs_first_add","sbjs_session","sbjs_udata","sbjs_migrations","sbjs_promo"].forEach(e=>{document.cookie=`${e}=; path=/; max-age=-999; domain=.${t};`})}();const s=t.getAttributionData();!function(t){for(const e of document.querySelectorAll("wc-order-attribution-inputs"))e.values=t}(s),a(s)},t.setOrderTracking(e.allowTracking),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",c):c(),window.customElements.define("wc-order-attribution-inputs",class extends HTMLElement{constructor(){if(super(),this._fieldNames=Object.keys(t.fields),this.hasOwnProperty("_values")){let t=this.values;delete this.values,this.values=t||{}}}connectedCallback(){this.innerHTML="";const t=new DocumentFragment;for(const n of this._fieldNames){const s=document.createElement("input");s.type="hidden",s.name=`${e.prefix}${n}`,s.value=i(this.values&&this.values[n]||""),t.appendChild(s)}this.appendChild(t)}set values(t){if(this._values=t,this.isConnected)for(const t of this._fieldNames){const n=this.querySelector(`input[name="${e.prefix}${t}"]`);n?n.value=i(this.values[t]):console.warn(`Field "${t}" not found. `+"Most likely, the '<wc-order-attribution-inputs>' element was manipulated.")}}get values(){return this._values}})}(window.wc_order_attribution);
!function(){var e={6879:function(e){!function(t){var n=function(e,t,n){"use strict";var a,i;if(function(){var t,n={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",fastLoadedClass:"ls-is-cached",iframeLoadMode:0,srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};for(t in i=e.lazySizesConfig||e.lazysizesConfig||{},n)t in i||(i[t]=n[t])}(),!t||!t.getElementsByClassName)return{init:function(){},cfg:i,noSupport:!0};var r=t.documentElement,o=e.HTMLPictureElement,s="addEventListener",l="getAttribute",c=e[s].bind(e),d=e.setTimeout,u=e.requestAnimationFrame||d,f=e.requestIdleCallback,m=/^picture$/i,v=["load","error","lazyincluded","_lazyloaded"],y={},g=Array.prototype.forEach,p=function(e,t){return y[t]||(y[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),y[t].test(e[l]("class")||"")&&y[t]},z=function(e,t){p(e,t)||e.setAttribute("class",(e[l]("class")||"").trim()+" "+t)},h=function(e,t){var n;(n=p(e,t))&&e.setAttribute("class",(e[l]("class")||"").replace(n," "))},b=function(e,t,n){var a=n?s:"removeEventListener";n&&b(e,t),v.forEach((function(n){e[a](n,t)}))},C=function(e,n,i,r,o){var s=t.createEvent("Event");return i||(i={}),i.instance=a,s.initEvent(n,!r,!o),s.detail=i,e.dispatchEvent(s),s},A=function(t,n){var a;!o&&(a=e.picturefill||i.pf)?(n&&n.src&&!t[l]("srcset")&&t.setAttribute("srcset",n.src),a({reevaluate:!0,elements:[t]})):n&&n.src&&(t.src=n.src)},E=function(e,t){return(getComputedStyle(e,null)||{})[t]},_=function(e,t,n){for(n=n||e.offsetWidth;n<i.minSize&&t&&!e._lazysizesWidth;)n=t.offsetWidth,t=t.parentNode;return n},w=(ze=[],he=[],be=ze,Ce=function(){var e=be;for(be=ze.length?he:ze,ge=!0,pe=!1;e.length;)e.shift()();ge=!1},Ae=function(e,n){ge&&!n?e.apply(this,arguments):(be.push(e),pe||(pe=!0,(t.hidden?d:u)(Ce)))},Ae._lsFlush=Ce,Ae),M=function(e,t){return t?function(){w(e)}:function(){var t=this,n=arguments;w((function(){e.apply(t,n)}))}},N=function(e){var t,a=0,r=i.throttleDelay,o=i.ricTimeout,s=function(){t=!1,a=n.now(),e()},l=f&&o>49?function(){f(s,{timeout:o}),o!==i.ricTimeout&&(o=i.ricTimeout)}:M((function(){d(s)}),!0);return function(e){var i;(e=!0===e)&&(o=33),t||(t=!0,(i=r-(n.now()-a))<0&&(i=0),e||i<9?l():d(l,i))}},x=function(e){var t,a,i=99,r=function(){t=null,e()},o=function(){var e=n.now()-a;e<i?d(o,i-e):(f||r)(r)};return function(){a=n.now(),t||(t=d(o,i))}},L=(K=/^img$/i,Q=/^iframe$/i,V="onscroll"in e&&!/(gle|ing)bot/.test(navigator.userAgent),X=0,Y=0,Z=0,ee=-1,te=function(e){Z--,(!e||Z<0||!e.target)&&(Z=0)},ne=function(e){return null==J&&(J="hidden"==E(t.body,"visibility")),J||!("hidden"==E(e.parentNode,"visibility")&&"hidden"==E(e,"visibility"))},ae=function(e,n){var a,i=e,o=ne(e);for(I-=n,G+=n,j-=n,U+=n;o&&(i=i.offsetParent)&&i!=t.body&&i!=r;)(o=(E(i,"opacity")||1)>0)&&"visible"!=E(i,"overflow")&&(a=i.getBoundingClientRect(),o=U>a.left&&j<a.right&&G>a.top-1&&I<a.bottom+1);return o},ie=function(){var e,n,o,s,c,d,u,f,m,v,y,g,p=a.elements;if((D=i.loadMode)&&Z<8&&(e=p.length)){for(n=0,ee++;n<e;n++)if(p[n]&&!p[n]._lazyRace)if(!V||a.prematureUnveil&&a.prematureUnveil(p[n]))fe(p[n]);else if((f=p[n][l]("data-expand"))&&(d=1*f)||(d=Y),v||(v=!i.expand||i.expand<1?r.clientHeight>500&&r.clientWidth>500?500:370:i.expand,a._defEx=v,y=v*i.expFactor,g=i.hFac,J=null,Y<y&&Z<1&&ee>2&&D>2&&!t.hidden?(Y=y,ee=0):Y=D>1&&ee>1&&Z<6?v:X),m!==d&&($=innerWidth+d*g,q=innerHeight+d,u=-1*d,m=d),o=p[n].getBoundingClientRect(),(G=o.bottom)>=u&&(I=o.top)<=q&&(U=o.right)>=u*g&&(j=o.left)<=$&&(G||U||j||I)&&(i.loadHidden||ne(p[n]))&&(R&&Z<3&&!f&&(D<3||ee<4)||ae(p[n],d))){if(fe(p[n]),c=!0,Z>9)break}else!c&&R&&!s&&Z<4&&ee<4&&D>2&&(P[0]||i.preloadAfterLoad)&&(P[0]||!f&&(G||U||j||I||"auto"!=p[n][l](i.sizesAttr)))&&(s=P[0]||p[n]);s&&!c&&fe(s)}},re=N(ie),oe=function(e){var t=e.target;t._lazyCache?delete t._lazyCache:(te(e),z(t,i.loadedClass),h(t,i.loadingClass),b(t,le),C(t,"lazyloaded"))},se=M(oe),le=function(e){se({target:e.target})},ce=function(e,t){var n=e.getAttribute("data-load-mode")||i.iframeLoadMode;0==n?e.contentWindow.location.replace(t):1==n&&(e.src=t)},de=function(e){var t,n=e[l](i.srcsetAttr);(t=i.customMedia[e[l]("data-media")||e[l]("media")])&&e.setAttribute("media",t),n&&e.setAttribute("srcset",n)},ue=M((function(e,t,n,a,r){var o,s,c,u,f,v;(f=C(e,"lazybeforeunveil",t)).defaultPrevented||(a&&(n?z(e,i.autosizesClass):e.setAttribute("sizes",a)),s=e[l](i.srcsetAttr),o=e[l](i.srcAttr),r&&(u=(c=e.parentNode)&&m.test(c.nodeName||"")),v=t.firesLoad||"src"in e&&(s||o||u),f={target:e},z(e,i.loadingClass),v&&(clearTimeout(k),k=d(te,2500),b(e,le,!0)),u&&g.call(c.getElementsByTagName("source"),de),s?e.setAttribute("srcset",s):o&&!u&&(Q.test(e.nodeName)?ce(e,o):e.src=o),r&&(s||u)&&A(e,{src:o})),e._lazyRace&&delete e._lazyRace,h(e,i.lazyClass),w((function(){var t=e.complete&&e.naturalWidth>1;v&&!t||(t&&z(e,i.fastLoadedClass),oe(f),e._lazyCache=!0,d((function(){"_lazyCache"in e&&delete e._lazyCache}),9)),"lazy"==e.loading&&Z--}),!0)})),fe=function(e){if(!e._lazyRace){var t,n=K.test(e.nodeName),a=n&&(e[l](i.sizesAttr)||e[l]("sizes")),r="auto"==a;(!r&&R||!n||!e[l]("src")&&!e.srcset||e.complete||p(e,i.errorClass)||!p(e,i.lazyClass))&&(t=C(e,"lazyunveilread").detail,r&&W.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,Z++,ue(e,t,r,a,n))}},me=x((function(){i.loadMode=3,re()})),ve=function(){3==i.loadMode&&(i.loadMode=2),me()},ye=function(){R||(n.now()-H<999?d(ye,999):(R=!0,i.loadMode=3,re(),c("scroll",ve,!0)))},{_:function(){H=n.now(),a.elements=t.getElementsByClassName(i.lazyClass),P=t.getElementsByClassName(i.lazyClass+" "+i.preloadClass),c("scroll",re,!0),c("resize",re,!0),c("pageshow",(function(e){if(e.persisted){var n=t.querySelectorAll("."+i.loadingClass);n.length&&n.forEach&&u((function(){n.forEach((function(e){e.complete&&fe(e)}))}))}})),e.MutationObserver?new MutationObserver(re).observe(r,{childList:!0,subtree:!0,attributes:!0}):(r[s]("DOMNodeInserted",re,!0),r[s]("DOMAttrModified",re,!0),setInterval(re,999)),c("hashchange",re,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach((function(e){t[s](e,re,!0)})),/d$|^c/.test(t.readyState)?ye():(c("load",ye),t[s]("DOMContentLoaded",re),d(ye,2e4)),a.elements.length?(ie(),w._lsFlush()):re()},checkElems:re,unveil:fe,_aLSL:ve}),W=(T=M((function(e,t,n,a){var i,r,o;if(e._lazysizesWidth=a,a+="px",e.setAttribute("sizes",a),m.test(t.nodeName||""))for(r=0,o=(i=t.getElementsByTagName("source")).length;r<o;r++)i[r].setAttribute("sizes",a);n.detail.dataAttr||A(e,n.detail)})),F=function(e,t,n){var a,i=e.parentNode;i&&(n=_(e,i,n),(a=C(e,"lazybeforesizes",{width:n,dataAttr:!!t})).defaultPrevented||(n=a.detail.width)&&n!==e._lazysizesWidth&&T(e,i,a,n))},O=x((function(){var e,t=B.length;if(t)for(e=0;e<t;e++)F(B[e])})),{_:function(){B=t.getElementsByClassName(i.autosizesClass),c("resize",O)},checkElems:O,updateElem:F}),S=function(){!S.i&&t.getElementsByClassName&&(S.i=!0,W._(),L._())};var B,T,F,O;var P,R,k,D,H,$,q,I,j,U,G,J,K,Q,V,X,Y,Z,ee,te,ne,ae,ie,re,oe,se,le,ce,de,ue,fe,me,ve,ye;var ge,pe,ze,he,be,Ce,Ae;return d((function(){i.init&&S()})),a={cfg:i,autoSizer:W,loader:L,init:S,uP:A,aC:z,rC:h,hC:p,fire:C,gW:_,rAF:w}}(t,t.document,Date);t.lazySizes=n,e.exports&&(e.exports=n)}("undefined"!=typeof window?window:{})}},t={};function n(a){var i=t[a];if(void 0!==i)return i.exports;var r=t[a]={exports:{}};return e[a](r,r.exports,n),r.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=n(6879),t=n.n(e);document.addEventListener("lazybeforeunveil",(function(e){!function(e){var t=e.getAttribute("data-bg-image"),n="background-image";if(t||(t=e.getAttribute("data-bg"),n="background"),t){var a=t.replace(/\s*\!\s*important/i,""),i=a!==t?"important":"";e.style.setProperty(n,a,i)}}(e.target)})),t().init()}()}();
(function($){function Countdown(){this.regional=[];this.regional['']={labels:['Years','Months','Weeks','Days','Hours','Minutes','Seconds'],labels1:['Year','Month','Week','Day','Hour','Minute','Second'],compactLabels:['y','m','w','d'],whichLabels:null,timeSeparator:':',isRTL:false};this._defaults={until:null,since:null,timezone:null,serverSync:null,format:'dHMS',layout:'',compact:false,significant:0,description:'',expiryUrl:'',expiryText:'',alwaysExpire:false,onExpiry:null,onTick:null,tickInterval:1};$.extend(this._defaults,this.regional['']);this._serverSyncs=[]}var w='countdown';var Y=0;var O=1;var W=2;var D=3;var H=4;var M=5;var S=6;$.extend(Countdown.prototype,{markerClassName:'hasCountdown',_timer:setInterval(function(){$.countdown._updateTargets()},980),_timerTargets:[],setDefaults:function(a){this._resetExtraLabels(this._defaults,a);extendRemove(this._defaults,a||{})},UTCDate:function(a,b,c,e,f,g,h,i){if(typeof b=='object'&&b.constructor==Date){i=b.getMilliseconds();h=b.getSeconds();g=b.getMinutes();f=b.getHours();e=b.getDate();c=b.getMonth();b=b.getFullYear()}var d=new Date();d.setUTCFullYear(b);d.setUTCDate(1);d.setUTCMonth(c||0);d.setUTCDate(e||1);d.setUTCHours(f||0);d.setUTCMinutes((g||0)-(Math.abs(a)<30?a*60:a));d.setUTCSeconds(h||0);d.setUTCMilliseconds(i||0);return d},periodsToSeconds:function(a){return a[0]*31557600+a[1]*2629800+a[2]*604800+a[3]*86400+a[4]*3600+a[5]*60+a[6]},_settingsCountdown:function(a,b){if(!b){return $.countdown._defaults}var c=$.data(a,w);return(b=='all'?c.options:c.options[b])},_attachCountdown:function(a,b){var c=$(a);if(c.hasClass(this.markerClassName)){return}c.addClass(this.markerClassName);var d={options:$.extend({},b),_periods:[0,0,0,0,0,0,0]};$.data(a,w,d);this._changeCountdown(a)},_addTarget:function(a){if(!this._hasTarget(a)){this._timerTargets.push(a)}},_hasTarget:function(a){return($.inArray(a,this._timerTargets)>-1)},_removeTarget:function(b){this._timerTargets=$.map(this._timerTargets,function(a){return(a==b?null:a)})},_updateTargets:function(){for(var i=this._timerTargets.length-1;i>=0;i--){this._updateCountdown(this._timerTargets[i])}},_updateCountdown:function(a,b){var c=$(a);b=b||$.data(a,w);if(!b){return}c.html(this._generateHTML(b));c[(this._get(b,'isRTL')?'add':'remove')+'Class']('countdown_rtl');var d=this._get(b,'onTick');if(d){var e=b._hold!='lap'?b._periods:this._calculatePeriods(b,b._show,this._get(b,'significant'),new Date());var f=this._get(b,'tickInterval');if(f==1||this.periodsToSeconds(e)%f==0){d.apply(a,[e])}}var g=b._hold!='pause'&&(b._since?b._now.getTime()<b._since.getTime():b._now.getTime()>=b._until.getTime());if(g&&!b._expiring){b._expiring=true;if(this._hasTarget(a)||this._get(b,'alwaysExpire')){this._removeTarget(a);var h=this._get(b,'onExpiry');if(h){h.apply(a,[])}var i=this._get(b,'expiryText');if(i){var j=this._get(b,'layout');b.options.layout=i;this._updateCountdown(a,b);b.options.layout=j}var k=this._get(b,'expiryUrl');if(k){window.location=k}}b._expiring=false}else if(b._hold=='pause'){this._removeTarget(a)}$.data(a,w,b)},_changeCountdown:function(a,b,c){b=b||{};if(typeof b=='string'){var d=b;b={};b[d]=c}var e=$.data(a,w);if(e){this._resetExtraLabels(e.options,b);extendRemove(e.options,b);this._adjustSettings(a,e);$.data(a,w,e);var f=new Date();if((e._since&&e._since<f)||(e._until&&e._until>f)){this._addTarget(a)}this._updateCountdown(a,e)}},_resetExtraLabels:function(a,b){var c=false;for(var n in b){if(n!='whichLabels'&&n.match(/[Ll]abels/)){c=true;break}}if(c){for(var n in a){if(n.match(/[Ll]abels[0-9]/)){a[n]=null}}}},_adjustSettings:function(a,b){var c;var d=this._get(b,'serverSync');var e=0;var f=null;for(var i=0;i<this._serverSyncs.length;i++){if(this._serverSyncs[i][0]==d){f=this._serverSyncs[i][1];break}}if(f!=null){e=(d?f:0);c=new Date()}else{var g=(d?d.apply(a,[]):null);c=new Date();e=(g?c.getTime()-g.getTime():0);this._serverSyncs.push([d,e])}var h=this._get(b,'timezone');h=(h==null?-c.getTimezoneOffset():h);b._since=this._get(b,'since');if(b._since!=null){b._since=this.UTCDate(h,this._determineTime(b._since,null));if(b._since&&e){b._since.setMilliseconds(b._since.getMilliseconds()+e)}}b._until=this.UTCDate(h,this._determineTime(this._get(b,'until'),c));if(e){b._until.setMilliseconds(b._until.getMilliseconds()+e)}b._show=this._determineShow(b)},_destroyCountdown:function(a){var b=$(a);if(!b.hasClass(this.markerClassName)){return}this._removeTarget(a);b.removeClass(this.markerClassName).empty();$.removeData(a,w)},_pauseCountdown:function(a){this._hold(a,'pause')},_lapCountdown:function(a){this._hold(a,'lap')},_resumeCountdown:function(a){this._hold(a,null)},_hold:function(a,b){var c=$.data(a,w);if(c){if(c._hold=='pause'&&!b){c._periods=c._savePeriods;var d=(c._since?'-':'+');c[c._since?'_since':'_until']=this._determineTime(d+c._periods[0]+'y'+d+c._periods[1]+'o'+d+c._periods[2]+'w'+d+c._periods[3]+'d'+d+c._periods[4]+'h'+d+c._periods[5]+'m'+d+c._periods[6]+'s');this._addTarget(a)}c._hold=b;c._savePeriods=(b=='pause'?c._periods:null);$.data(a,w,c);this._updateCountdown(a,c)}},_getTimesCountdown:function(a){var b=$.data(a,w);return(!b?null:(!b._hold?b._periods:this._calculatePeriods(b,b._show,this._get(b,'significant'),new Date())))},_get:function(a,b){return(a.options[b]!=null?a.options[b]:$.countdown._defaults[b])},_determineTime:function(k,l){var m=function(a){var b=new Date();b.setTime(b.getTime()+a*1000);return b};var n=function(a){a=a.toLowerCase();var b=new Date();var c=b.getFullYear();var d=b.getMonth();var e=b.getDate();var f=b.getHours();var g=b.getMinutes();var h=b.getSeconds();var i=/([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;var j=i.exec(a);while(j){switch(j[2]||'s'){case's':h+=parseInt(j[1],10);break;case'm':g+=parseInt(j[1],10);break;case'h':f+=parseInt(j[1],10);break;case'd':e+=parseInt(j[1],10);break;case'w':e+=parseInt(j[1],10)*7;break;case'o':d+=parseInt(j[1],10);e=Math.min(e,$.countdown._getDaysInMonth(c,d));break;case'y':c+=parseInt(j[1],10);e=Math.min(e,$.countdown._getDaysInMonth(c,d));break}j=i.exec(a)}return new Date(c,d,e,f,g,h,0)};var o=(k==null?l:(typeof k=='string'?n(k):(typeof k=='number'?m(k):k)));if(o)o.setMilliseconds(0);return o},_getDaysInMonth:function(a,b){return 32-new Date(a,b,32).getDate()},_normalLabels:function(a){return a},_generateHTML:function(c){var d=this._get(c,'significant');c._periods=(c._hold?c._periods:this._calculatePeriods(c,c._show,d,new Date()));var e=false;var f=0;var g=d;var h=$.extend({},c._show);for(var i=Y;i<=S;i++){e|=(c._show[i]=='?'&&c._periods[i]>0);h[i]=(c._show[i]=='?'&&!e?null:c._show[i]);f+=(h[i]?1:0);g-=(c._periods[i]>0?1:0)}var j=[false,false,false,false,false,false,false];for(var i=S;i>=Y;i--){if(c._show[i]){if(c._periods[i]){j[i]=true}else{j[i]=g>0;g--}}}var k=this._get(c,'compact');var l=this._get(c,'layout');var m=(k?this._get(c,'compactLabels'):this._get(c,'labels'));var n=this._get(c,'whichLabels')||this._normalLabels;var o=this._get(c,'timeSeparator');var p=this._get(c,'description')||'';var q=function(a){var b=$.countdown._get(c,'compactLabels'+n(c._periods[a]));return(h[a]?c._periods[a]+(b?b[a]:m[a])+' ':'')};var r=function(a){var b=$.countdown._get(c,'labels'+n(c._periods[a]));return((!d&&h[a])||(d&&j[a])?'<span class="countdown_section"><span class="countdown_amount">'+c._periods[a]+'</span><br/>'+(b?b[a]:m[a])+'</span>':'')};return(l?this._buildLayout(c,h,l,k,d,j):((k?'<span class="countdown_row countdown_amount'+(c._hold?' countdown_holding':'')+'">'+q(Y)+q(O)+q(W)+q(D)+(h[H]?this._minDigits(c._periods[H],2):'')+(h[M]?(h[H]?o:'')+this._minDigits(c._periods[M],2):'')+(h[S]?(h[H]||h[M]?o:'')+this._minDigits(c._periods[S],2):''):'<span class="countdown_row countdown_show'+(d||f)+(c._hold?' countdown_holding':'')+'">'+r(Y)+r(O)+r(W)+r(D)+r(H)+r(M)+r(S))+'</span>'+(p?'<span class="countdown_row countdown_descr">'+p+'</span>':'')))},_buildLayout:function(c,d,e,f,g,h){var j=this._get(c,(f?'compactLabels':'labels'));var k=this._get(c,'whichLabels')||this._normalLabels;var l=function(a){return($.countdown._get(c,(f?'compactLabels':'labels')+k(c._periods[a]))||j)[a]};var m=function(a,b){return Math.floor(a/b)%10};var o={desc:this._get(c,'description'),sep:this._get(c,'timeSeparator'),yl:l(Y),yn:c._periods[Y],ynn:this._minDigits(c._periods[Y],2),ynnn:this._minDigits(c._periods[Y],3),y1:m(c._periods[Y],1),y10:m(c._periods[Y],10),y100:m(c._periods[Y],100),y1000:m(c._periods[Y],1000),ol:l(O),on:c._periods[O],onn:this._minDigits(c._periods[O],2),onnn:this._minDigits(c._periods[O],3),o1:m(c._periods[O],1),o10:m(c._periods[O],10),o100:m(c._periods[O],100),o1000:m(c._periods[O],1000),wl:l(W),wn:c._periods[W],wnn:this._minDigits(c._periods[W],2),wnnn:this._minDigits(c._periods[W],3),w1:m(c._periods[W],1),w10:m(c._periods[W],10),w100:m(c._periods[W],100),w1000:m(c._periods[W],1000),dl:l(D),dn:c._periods[D],dnn:this._minDigits(c._periods[D],2),dnnn:this._minDigits(c._periods[D],3),d1:m(c._periods[D],1),d10:m(c._periods[D],10),d100:m(c._periods[D],100),d1000:m(c._periods[D],1000),hl:l(H),hn:c._periods[H],hnn:this._minDigits(c._periods[H],2),hnnn:this._minDigits(c._periods[H],3),h1:m(c._periods[H],1),h10:m(c._periods[H],10),h100:m(c._periods[H],100),h1000:m(c._periods[H],1000),ml:l(M),mn:c._periods[M],mnn:this._minDigits(c._periods[M],2),mnnn:this._minDigits(c._periods[M],3),m1:m(c._periods[M],1),m10:m(c._periods[M],10),m100:m(c._periods[M],100),m1000:m(c._periods[M],1000),sl:l(S),sn:c._periods[S],snn:this._minDigits(c._periods[S],2),snnn:this._minDigits(c._periods[S],3),s1:m(c._periods[S],1),s10:m(c._periods[S],10),s100:m(c._periods[S],100),s1000:m(c._periods[S],1000)};var p=e;for(var i=Y;i<=S;i++){var q='yowdhms'.charAt(i);var r=new RegExp('\\{'+q+'<\\}(.*)\\{'+q+'>\\}','g');p=p.replace(r,((!g&&d[i])||(g&&h[i])?'$1':''))}$.each(o,function(n,v){var a=new RegExp('\\{'+n+'\\}','g');p=p.replace(a,v)});return p},_minDigits:function(a,b){a=''+a;if(a.length>=b){return a}a='0000000000'+a;return a.substr(a.length-b)},_determineShow:function(a){var b=this._get(a,'format');var c=[];c[Y]=(b.match('y')?'?':(b.match('Y')?'!':null));c[O]=(b.match('o')?'?':(b.match('O')?'!':null));c[W]=(b.match('w')?'?':(b.match('W')?'!':null));c[D]=(b.match('d')?'?':(b.match('D')?'!':null));c[H]=(b.match('h')?'?':(b.match('H')?'!':null));c[M]=(b.match('m')?'?':(b.match('M')?'!':null));c[S]=(b.match('s')?'?':(b.match('S')?'!':null));return c},_calculatePeriods:function(c,d,e,f){c._now=f;c._now.setMilliseconds(0);var g=new Date(c._now.getTime());if(c._since){if(f.getTime()<c._since.getTime()){c._now=f=g}else{f=c._since}}else{g.setTime(c._until.getTime());if(f.getTime()>c._until.getTime()){c._now=f=g}}var h=[0,0,0,0,0,0,0];if(d[Y]||d[O]){var i=$.countdown._getDaysInMonth(f.getFullYear(),f.getMonth());var j=$.countdown._getDaysInMonth(g.getFullYear(),g.getMonth());var k=(g.getDate()==f.getDate()||(g.getDate()>=Math.min(i,j)&&f.getDate()>=Math.min(i,j)));var l=function(a){return(a.getHours()*60+a.getMinutes())*60+a.getSeconds()};var m=Math.max(0,(g.getFullYear()-f.getFullYear())*12+g.getMonth()-f.getMonth()+((g.getDate()<f.getDate()&&!k)||(k&&l(g)<l(f))?-1:0));h[Y]=(d[Y]?Math.floor(m/12):0);h[O]=(d[O]?m-h[Y]*12:0);f=new Date(f.getTime());var n=(f.getDate()==i);var o=$.countdown._getDaysInMonth(f.getFullYear()+h[Y],f.getMonth()+h[O]);if(f.getDate()>o){f.setDate(o)}f.setFullYear(f.getFullYear()+h[Y]);f.setMonth(f.getMonth()+h[O]);if(n){f.setDate(o)}}var p=Math.floor((g.getTime()-f.getTime())/1000);var q=function(a,b){h[a]=(d[a]?Math.floor(p/b):0);p-=h[a]*b};q(W,604800);q(D,86400);q(H,3600);q(M,60);q(S,1);if(p>0&&!c._since){var r=[1,12,4.3482,7,24,60,60];var s=S;var t=1;for(var u=S;u>=Y;u--){if(d[u]){if(h[s]>=t){h[s]=0;p=1}if(p>0){h[u]++;p=0;s=u;t=1}}t*=r[u]}}if(e){for(var u=Y;u<=S;u++){if(e&&h[u]){e--}else if(!e){h[u]=0}}}return h}});function extendRemove(a,b){$.extend(a,b);for(var c in b){if(b[c]==null){a[c]=null}}return a}$.fn.countdown=function(a){var b=Array.prototype.slice.call(arguments,1);if(a=='getTimes'||a=='settings'){return $.countdown['_'+a+'Countdown'].apply($.countdown,[this[0]].concat(b))}return this.each(function(){if(typeof a=='string'){$.countdown['_'+a+'Countdown'].apply($.countdown,[this].concat(b))}else{$.countdown._attachCountdown(this,a)}})};$.countdown=new Countdown()})(jQuery);