PageSourceSearch

https://www.durst.de/wp-content/plugins/booking/js/client.js?ver=9.1

js durst.de collected 2026-10-06 03:23:45 UTC 79,089 bytes, 1,609 lines download raw bytes

1var is_booking_without_payment = false;
2var date_approved = [];
3var date2approve = [];
4var date_admin_blank = [];
5var dates_additional_info = [];
6var is_all_days_available = [];
7var avalaibility_filters = [];
8var is_show_cost_in_tooltips = false;
9var is_show_cost_in_date_cell = false;
10var is_show_availability_in_tooltips = false;
11var global_avalaibility_times = [];   
12var numbb = 0;
13
14//var is_use_visitors_number_for_availability;
15var timeoutID_of_thank_you_page = null;
16
17/**
18 * Booking Calendar -  JavaScript Settings
19 *
20 * Example or redefine some settings:
21 * <script type="text/javascript">  wpbc_settings.set_option( 'pending_days_selectable', true ); </script>
22 * [booking type=1]
23 *
24 //FixIn: 8.6.1.18
25 */
26var wpbc_settings = (function ( obj, $) {
27
28	// Define private property
29	var p_options = obj.options = obj.options || [];
30
31	p_options['pending_days_selectable'] = false;
32
33	// Get Option
34	obj.get_option = function ( item_id ) {
35
36		return p_options[ item_id ];
37	};
38
39	// Set Option
40	obj.set_option = function ( item_id, item_value ) {
41
42		p_options[ item_id ] = item_value;
43	};
44
45	return obj;
46
47}(wpbc_settings || {}, jQuery ));
48
49
50/**
51 * Calendar Init
52 *
53 * @param bk_type			- resource ID
54 * @param date_approved_par
55 * @param my_num_month
56 * @param start_day_of_week
57 * @param start_bk_month
58 * @returns {boolean}
59 */
60function init_datepick_cal(bk_type,  date_approved_par, my_num_month, start_day_of_week, start_bk_month  ){
61
62        if ( jQuery('#calendar_booking'+ bk_type).hasClass('hasDatepick') == true ) { // If the calendar with the same Booking resource is activated already, then exist.
63            return false;
64        }
65
66        var cl = document.getElementById('calendar_booking'+ bk_type);if (cl === null) return; // Get calendar instance and exit if its not exist
67
68        date_approved[ bk_type ] = date_approved_par;
69
70        var isRangeSelect = false;
71        var bkMultiDaysSelect   = 365;
72        if ( bk_days_selection_mode==='dynamic' ) { isRangeSelect     = true; bkMultiDaysSelect = 0; }
73        if ( bk_days_selection_mode==='single' )    bkMultiDaysSelect = 0;
74
75        var bkMinDate = 0;
76        var bkMaxDate = booking_max_monthes_in_calendar;
77
78        var is_this_admin = false;
79        if (   ( location.href.indexOf('page=wpbc-new') != -1 )
80            && ( location.href.indexOf('booking_hash') != -1 )                  // Comment this line for ability to add  booking in past days at  Booking > Add booking page.
81            ){
82            is_this_admin = true; 
83            bkMinDate = null;
84            bkMaxDate = null;
85        }
86
87        function click_on_cal_td(){
88            if(typeof( selectDayPro ) == 'function') {selectDayPro(  bk_type);}
89        }
90
91        function selectDay(date) {
92
93			// Set unselectable,  if only Availability Calendar  here (and we do not insert Booking form by mistake).
94			var is_calendar_booking_unselectable = jQuery( '#calendar_booking_unselectable' + bk_type );				//FixIn: 8.0.1.2
95			var is_booking_form_also = jQuery( '#booking_form_div' + bk_type );
96			if ( ( is_calendar_booking_unselectable.length > 0 ) && ( is_booking_form_also.length <= 0 ) ){
97
98				wpbc_unselect_all_days( bk_type );
99				jQuery('.wpbc_only_calendar .popover_calendar_hover').remove();                      					//Hide all opened popovers
100				return false;
101			}																											//FixIn: 8.0.1.2 end
102
103			//console.log( jQuery.fn.popover.Constructor.VERSION );   // Check if this minimum BS version, and then proced
104//Deprecated: FixIn: 9.0.1.1.1
105// if ( 'function' === typeof( jQuery( ".datepick-days-cell" ).popover ) ){    								    //FixIn: 7.0.1.2  - 2016-12-10
106//     jQuery( '.datepick-days-cell' ).popover( 'hide' );
107// }
108
109			jQuery( '#date_booking' + bk_type ).val( date );
110
111			if ( typeof( bkDisableBookedTimeSlots ) == 'function' ){
112//Deprecated: FixIn: 9.0.1.1.1
113//if(typeof( prepare_tooltip ) == 'function') {setTimeout("prepare_tooltip("+bk_type+");",1000);}
114				// HERE WE WILL DISABLE ALL OPTIONS IN RANGE TIME INTERVALS FOR SINGLE DAYS SELECTIONS FOR THAT DAYS WHERE HOURS ALREADY BOOKED
115				bkDisableBookedTimeSlots( jQuery( '#date_booking' + bk_type ).val(), bk_type );
116			}
117			if ( typeof( selectDayPro ) == 'function' ){
118				selectDayPro( date, bk_type );
119			}
120			jQuery( ".booking_form_div" ).trigger( "date_selected", [ bk_type, date ] );
121        }
122
123        function hoverDay(value, date){
124
125			if ( typeof( hoverDayTime ) == 'function' ){
126				hoverDayTime( value, date, bk_type );
127			}
128
129			if ( (location.href.indexOf( 'page=wpbc' ) == -1) ||
130				(location.href.indexOf( 'page=wpbc-new' ) > 0) ){ // Do not show it (range) at the main admin page
131				if ( typeof( hoverDayPro ) == 'function' ){
132					hoverDayPro( value, date, bk_type );
133				}
134			}
135
136			var is_calendar_booking_unselectable = jQuery( '#calendar_booking_unselectable' + bk_type );				//FixIn: 8.0.1.2
137			var is_booking_form_also = jQuery( '#booking_form_div' + bk_type );
138			// Set unselectable,  if only Availability Calendar  here (and we do not insert Booking form by mistake).
139			if ( ( is_calendar_booking_unselectable.length == 1 ) && ( is_booking_form_also.length != 1 ) ){
140				jQuery( '#calendar_booking' + bk_type + ' .datepick-days-cell-over' ).removeClass( 'datepick-days-cell-over' );        // clear all highlight days selections
141				jQuery( '.wpbc_only_calendar #calendar_booking' + bk_type + ' .datepick-days-cell, ' +
142						'.wpbc_only_calendar #calendar_booking' + bk_type + ' .datepick-days-cell a' ).css( 'cursor', 'default' );
143				return false;
144			}																											//FixIn: 8.0.1.2	end
145		}
146
147        function applyCSStoDays(date ){
148            var class_day = (date.getMonth()+1) + '-' + date.getDate() + '-' + date.getFullYear();
149            var additional_class = ' wpbc_weekday_' + date.getDay() + '  ';
150
151            //Block today date if current today  time older than  18:00
152            if ( ( false ) && ( date.getDate() == (wpdev_bk_today[2] )  ) && ( date.getMonth() == (wpdev_bk_today[1]-1)  ) &&( date.getFullYear() == (wpdev_bk_today[0])  ) ){
153				var my_test_date1 = new Date( wpdev_bk_today[ 0 ], (wpdev_bk_today[ 1 ] - 1), wpdev_bk_today[ 2 ], wpdev_bk_today[ 3 ], wpdev_bk_today[ 4 ], 0 );  //Get today
154				var my_test_date2 = new Date( wpdev_bk_today[ 0 ], (wpdev_bk_today[ 1 ] - 1), wpdev_bk_today[ 2 ], 18, 0, 0 );      //Today 18:00
155				if ( my_test_date2.getTime() < my_test_date1.getTime() )
156					return [ false, 'cal4date-' + class_day + ' date_user_unavailable' ];
157			}
158
159            if(typeof( prices_per_day  ) !== 'undefined')
160                if(typeof(  prices_per_day[bk_type] ) !== 'undefined')
161                    if(typeof(  prices_per_day[bk_type][class_day] ) !== 'undefined') {
162                        additional_class += ' rate_'+prices_per_day[bk_type][class_day];
163                    }
164
165            // define season filter names as classes
166            if(typeof( wpdev_bk_season_filter  ) !== 'undefined')
167                    if(typeof(  wpdev_bk_season_filter[class_day] ) !== 'undefined') {
168                        additional_class += ' '+wpdev_bk_season_filter[class_day].join(' ');
169                    }
170
171            if (is_this_admin == false) {
172                var my_test_date = new Date( wpdev_bk_today[0],(wpdev_bk_today[1]-1), wpdev_bk_today[2] ,0,0,0 );  //Get today
173                if ( (days_between( date, my_test_date)) < block_some_dates_from_today ) 
174                    return [false, 'cal4date-' + class_day +' date_user_unavailable']; 
175                
176                if( typeof( wpbc_available_days_num_from_today  ) !== 'undefined')
177                    if ( parseInt( '0' + wpbc_available_days_num_from_today ) > 0 )
178                        if ( (days_between( date, my_test_date)) > parseInt( '0' + wpbc_available_days_num_from_today ) ) 
179                            return [false, 'cal4date-' + class_day +' date_user_unavailable']; 
180            }
181
182            if (typeof( is_this_day_available ) == 'function') {
183                var is_day_available = is_this_day_available( date, bk_type);
184                var season_filter = '';                                         //FixIn: 6.0.1.8
185                if ( is_day_available instanceof Array ) {
186                    season_filter = ' season_filter_id_' + is_day_available[1];
187                    is_day_available = is_day_available[0];                    
188                }
189                if (! is_day_available) {return [false, 'cal4date-' + class_day +' date_user_unavailable ' + season_filter ];}                
190            }
191
192            // Time availability
193            if (typeof( check_global_time_availability ) == 'function') {check_global_time_availability( date, bk_type );}
194
195            var blank_admin_class_day = '';
196            if(typeof(date_admin_blank[ bk_type ]) !== 'undefined')
197                if(typeof(date_admin_blank[ bk_type ][ class_day ]) !== 'undefined') {
198                    blank_admin_class_day = ' date_admin_blank ';
199                }
200
201            // Check availability per day for BL
202            var reserved_days_count = 1;
203            if(typeof(availability_per_day) !== 'undefined')
204            if(typeof(availability_per_day[ bk_type ]) !== 'undefined')
205               if(typeof(availability_per_day[ bk_type ][ class_day ]) !== 'undefined') {
206                  reserved_days_count = parseInt( availability_per_day[ bk_type ][ class_day ] );}
207
208            // Number of Check In Dates for BL      
209            var checkin_days_count = [0 ,0];
210            if(typeof(wpbc_check_in_dates) !== 'undefined')
211            if(typeof(wpbc_check_in_dates[ bk_type ]) !== 'undefined')
212               if(typeof(wpbc_check_in_dates[ bk_type ][ class_day ]) !== 'undefined') {
213                   // [ Number of check in bookings, Pending or Approved status ]
214                  checkin_days_count = [ wpbc_check_in_dates[ bk_type ][ class_day ][ 0 ] ,  wpbc_check_in_dates[ bk_type ][ class_day ][ 1 ] ];
215              }
216
217            // Number of Check Out Dates for BL 
218            var checkout_days_count = [0 ,0];
219            if(typeof(wpbc_check_out_dates) !== 'undefined')
220            if(typeof(wpbc_check_out_dates[ bk_type ]) !== 'undefined')
221               if(typeof(wpbc_check_out_dates[ bk_type ][ class_day ]) !== 'undefined') {
222                   // [ Number of check Out bookings, Pending or Approved status ]
223                  checkout_days_count = [ wpbc_check_out_dates[ bk_type ][ class_day ][ 0 ] , wpbc_check_out_dates[ bk_type ][ class_day ][ 1 ] ];
224              }
225
226            // Booked both  check  in/out dates in the same child resources  
227            var both_check_in_out_num = 0;
228            if ( typeof( getNumberClosedCheckInOutDays ) == 'function' ) {                       
229                  both_check_in_out_num =  getNumberClosedCheckInOutDays( bk_type, class_day );
230            }
231
232
233            // we have 0 available at this day - Only for resources, which have childs
234            if (  wpdev_in_array( parent_booking_resources, bk_type ) )
235                    if (reserved_days_count <= 0) {
236                            if(typeof(date2approve[ bk_type ]) !== 'undefined')
237                               if(typeof(date2approve[ bk_type ][ class_day ]) !== 'undefined')
238                                 return [false, 'cal4date-' + class_day +' date2approve date_unavailable_for_all_childs ' + blank_admin_class_day];
239                             return [false, 'cal4date-' + class_day +' date_approved date_unavailable_for_all_childs ' + blank_admin_class_day];
240                    }
241
242            var th=0;
243            var tm=0;
244            var ts=0;
245            var time_return_value = false;
246
247            var is_set_pending_days_selectable = wpbc_settings.get_option( 'pending_days_selectable' );                 // set pending days selectable          //FixIn: 8.6.1.18
248
249            // Select dates which need to approve, its exist only in Admin
250            if(typeof(date2approve[ bk_type ]) !== 'undefined')
251               if(typeof(date2approve[ bk_type ][ class_day ]) !== 'undefined') {
252
253                  for (var ia=0;ia<date2approve[ bk_type ][ class_day ].length;ia++) {
254
255                      th = date2approve[ bk_type ][ class_day ][ia][3];
256                      tm = date2approve[ bk_type ][ class_day ][ia][4];
257                      ts = date2approve[ bk_type ][ class_day ][ia][5];
258                      if ( ( th == 0 ) && ( tm == 0 ) && ( ts == 0 ) ) {
259                            return [ is_set_pending_days_selectable, 'cal4date-' + class_day +' date2approve' + blank_admin_class_day];             // Orange       //FixIn: 8.6.1.18
260                      } else {
261                          if ( is_booking_used_check_in_out_time === true ) {
262                              if (ts == '1')  additional_class += ' check_in_time' + ' check_in_time_date2approve';         //FixIn: 6.0.1.2
263                              if (ts == '2')  additional_class += ' check_out_time'+ ' check_out_time_date2approve';        //FixIn: 6.0.1.2
264                          } else {
265                              additional_class += ' times_clock';                                                           //FixIn: 8.2.1.27
266                          }
267                          time_return_value = [true, 'date_available cal4date-' + class_day +' date2approve timespartly' + additional_class];       // Times
268                          if(typeof( isDayFullByTime ) == 'function') {
269                              if ( isDayFullByTime(bk_type, class_day ) ) {
270                                    return [ is_set_pending_days_selectable, 'cal4date-' + class_day +' date2approve' + blank_admin_class_day];     // Orange       //FixIn: 8.6.1.18
271                              }
272                          }
273                      }
274
275                  }
276
277               }
278
279            //select Approved dates
280            if(typeof(date_approved[ bk_type ]) !== 'undefined')
281              if(typeof(date_approved[ bk_type ][ class_day ]) !== 'undefined') {
282
283                  for (var ia=0;ia<date_approved[ bk_type ][ class_day ].length;ia++) {
284
285                      th = date_approved[ bk_type ][ class_day ][ia][3];
286                      tm = date_approved[ bk_type ][ class_day ][ia][4];
287                      ts = date_approved[ bk_type ][ class_day ][ia][5];
288                      if ( ( th == 0 ) && ( tm == 0 ) && ( ts == 0 ) )
289                        return [false, 'cal4date-' + class_day +' date_approved' + blank_admin_class_day]; //Blue or Grey in client
290                      else {
291                          if ( is_booking_used_check_in_out_time === true ) {
292                              if (ts == '1')  additional_class += ' check_in_time' + ' check_in_time_date_approved';        //FixIn: 6.0.1.2
293                              if (ts == '2')  additional_class += ' check_out_time'+ ' check_out_time_date_approved';       //FixIn: 6.0.1.2
294                          } else {
295                              additional_class += ' times_clock';                                                           //FixIn: 8.2.1.27
296                          }
297                        time_return_value = [true,  'date_available cal4date-' + class_day +' date_approved timespartly' + additional_class]; // Times
298                        if(typeof( isDayFullByTime ) == 'function') {
299                            if ( isDayFullByTime(bk_type, class_day ) ) return [false, 'cal4date-' + class_day +' date_approved' + blank_admin_class_day]; // Blue or Grey in client
300                        }
301                      }
302
303                  }
304              }
305
306
307            for (var i=0; i<user_unavilable_days.length;i++) {
308                if (date.getDay()==user_unavilable_days[i])   return [false, 'cal4date-' + class_day +' date_user_unavailable' ];
309            }
310
311            var is_datepick_unselectable = '';
312			//FixIn: 8.0.1.2
313            /*
314            var is_calendar_booking_unselectable = jQuery('#calendar_booking_unselectable' + bk_type);            
315            var is_booking_form_also             = jQuery('#booking_form_div' + bk_type);            
316            // Set unselectable,  if only Availability Calendar  here (and we do not insert Booking form by mistake).
317            if (  ( is_calendar_booking_unselectable.length == 1 ) && ( is_booking_form_also.length != 1 )  ){        
318                is_datepick_unselectable = 'datepick-unselectable';  // 'ui-datepicker-unselectable ui-state-disabled';
319            }*/
320
321
322            //FixIn: 8.1.2.3
323            if ( false ){
324				if ( (time_return_value !== false) && (time_return_value[ 1 ].indexOf( 'timespartly' ) != -1) && (is_booking_used_check_in_out_time !== true) ){
325					time_return_value[ 1 ] = time_return_value[ 1 ].replace( "date_approved", "" );
326					time_return_value[ 1 ] = time_return_value[ 1 ].replace( "date2approve", "" );
327				}
328			}
329            var is_exist_check_in_out_for_parent_resource = Math.max( checkin_days_count[0], checkout_days_count[0] );
330            //FixIn: 8.4.7.29
331            if (  ! wpdev_in_array( parent_booking_resources, bk_type ) ) {
332                is_exist_check_in_out_for_parent_resource = 0;
333            }
334
335            if ( ( time_return_value !== false ) && ( is_exist_check_in_out_for_parent_resource == 0 ) ) { // Check  this only for single booking resources - is_exist_check_in_out_for_parent_resource == 0
336                if ( is_booking_used_check_in_out_time === true ) {
337                    // If the date is cehck in/out and the check in/out time is activated so  then  this date is unavailbale
338                    if ( ( additional_class.indexOf('check_in_time') != -1 ) && ( additional_class.indexOf('check_out_time') != -1 ) ){ 
339                        // Make this date unavailbale
340                        time_return_value[0] = false;                             
341                        //FixIn: 6.0.1.2                                                 
342                        if ( ! (
343                                    ( ( additional_class.indexOf('check_in_time_date_approved') != -1 ) && ( additional_class.indexOf('check_out_time_date2approve') != -1 ) )
344                                  || ( ( additional_class.indexOf('check_out_time_date_approved') != -1 ) && ( additional_class.indexOf('check_in_time_date2approve') != -1 ) )
345                            ) ) { 
346                            // Remove CSS classes from this date
347                            /*  //FixIn: 8.9.4.13.1  - Show diagonal line in dates, where we have check in/out bookings with  the same status (pending or approved) */
348                            // time_return_value[1]=time_return_value[1].replace("check_in_time","");
349                            // time_return_value[1]=time_return_value[1].replace("check_out_time","");
350                            // time_return_value[1]=time_return_value[1].replace("timespartly","");
351                        }
352                        time_return_value[1]=time_return_value[1].replace("date_available",""); 
353                    }
354                }
355                if (  (  wpdev_in_array( parent_booking_resources, bk_type ) ) && ( (reserved_days_count - both_check_in_out_num ) <= 0 ) ) {    //FixIn: 6.0.1.2
356                    time_return_value[0] = false;  
357                    time_return_value[1]=time_return_value[1].replace("check_in_time",""); 
358                    time_return_value[1]=time_return_value[1].replace("check_out_time",""); 
359                    time_return_value[1]=time_return_value[1].replace("timespartly","");                                
360                    time_return_value[1]=time_return_value[1].replace("date_available","");                     
361                }
362                return time_return_value;
363
364            } else { 
365                
366                if ( 
367                          ( is_booking_used_check_in_out_time === true ) 
368                       && (  ( is_exist_check_in_out_for_parent_resource > 0 ) || ( (reserved_days_count - both_check_in_out_num ) <= 0 )  )
369                    ) { // Check  Check  In / Out dates for the parent resources. // reserved_days_count - number of available items,  including check in/out dates ||  both_check_in_out_num number of items with both  check in/out   //FixIn: 6.0.1.12
370
371                    // Unavailable 
372                    if ( (reserved_days_count - both_check_in_out_num ) <= 0 ) {
373                        // Check  Pending or Approved by the Check In date
374                        if ( checkin_days_count[1] == 1 )   additional_class = ' date_approved';    
375                        else                                additional_class = ' date2approve';                                                       
376                        return [false, 'cal4date-' + class_day + additional_class + blank_admin_class_day]; 
377                    }
378
379                    // Recheck  if this date check in/out
380                    if ( (reserved_days_count - both_check_in_out_num - checkin_days_count[0]) <= 0 ) {
381                        if ( checkin_days_count[1] == 1 )   additional_class += ' date_approved';
382                        else                                additional_class += ' date2approve';                           
383                        additional_class += ' timespartly check_in_time';
384                    }
385                    if ( (reserved_days_count - both_check_in_out_num  - checkout_days_count[0]) <= 0 ) {
386                        if ( checkout_days_count[1] == 1 )  additional_class += ' date_approved';
387                        else                                additional_class += ' date2approve';
388                        additional_class += ' timespartly check_out_time';
389                    }                                               
390                }
391
392                return [true, 'date_available cal4date-' + class_day +' reserved_days_count' + reserved_days_count + ' '  + is_datepick_unselectable + additional_class+ ' '];
393            }
394        }
395
396        function changeMonthYear(year, month){ 
397//Deprecated: FixIn: 9.0.1.1.1
398// if(typeof( prepare_tooltip ) == 'function') {
399//     setTimeout("prepare_tooltip("+bk_type+");",1000);
400// }
401            if(typeof( prepare_highlight ) == 'function') {
402             setTimeout("prepare_highlight();",1000);
403            }
404        }
405        // Configure and show calendar
406        jQuery('#calendar_booking'+ bk_type).text('');
407        jQuery('#calendar_booking'+ bk_type).datepick(
408                {beforeShowDay: applyCSStoDays,
409                    onSelect: selectDay,
410                    onHover:hoverDay,
411                    onChangeMonthYear:changeMonthYear,
412                    showOn: 'both',
413                    multiSelect: bkMultiDaysSelect,
414                    numberOfMonths: my_num_month,
415                    stepMonths: 1,
416                    prevText: '&laquo;',
417                    nextText: '&raquo;',
418                    dateFormat: 'dd.mm.yy',
419                    changeMonth: false, 
420                    changeYear: false,
421                    minDate: bkMinDate, maxDate: bkMaxDate, //'1Y',
422                    // minDate: new Date(2020, 2, 1), maxDate: new Date(2020, 9, 31),             // Ability to set any  start and end date in calendar
423                    showStatus: false,
424                    multiSeparator: ', ',
425                    closeAtTop: false,
426                    firstDay:start_day_of_week,
427                    gotoCurrent: false,
428                    hideIfNoPrevNext:true,
429                    rangeSelect:isRangeSelect,
430                    // showWeeks: true, 
431                    useThemeRoller :false // ui-cupertino.datepick.css
432                }
433        );
434        
435        //FixIn: 7.1.2.8
436        setTimeout( function ( ) {
437            jQuery( '.datepick-days-cell.datepick-today.datepick-days-cell-over' ).removeClass( 'datepick-days-cell-over' );
438        }, 500 );
439        
440        if ( start_bk_month != false ) {
441            var inst = jQuery.datepick._getInst(document.getElementById('calendar_booking'+bk_type));
442            inst.cursorDate = new Date();
443            inst.cursorDate.setFullYear( start_bk_month[0], (start_bk_month[1]-1) ,  1 );
444            // In some cases,  the setFullYear can  set  only Year,  and not the Month and day      //FixIn:6.2.3.5
445            inst.cursorDate.setMonth( parseInt( start_bk_month[1] - 1 ) );
446            inst.cursorDate.setDate( 1 );
447
448            inst.drawMonth = inst.cursorDate.getMonth();
449            inst.drawYear = inst.cursorDate.getFullYear();
450
451            jQuery.datepick._notifyChange(inst);
452            jQuery.datepick._adjustInstDate(inst);
453            jQuery.datepick._showDate(inst);
454            jQuery.datepick._updateDatepick(inst);
455        }
456//Deprecated: FixIn: 9.0.1.1.1
457// if ( typeof( prepare_tooltip ) == 'function' ){
458// 	setTimeout( "prepare_tooltip(" + bk_type + ");", 1000 );
459// }
460}
461
462
463////////////////////////////////////////////////////////////////////////////
464// Days Selections - support functions 
465////////////////////////////////////////////////////////////////////////////
466
467// Get fisrst day of selection
468function get_first_day_of_selection(dates) {
469
470    // Multiple days selections
471    if ( dates.indexOf(',') != -1 ){                  
472        var dates_array =dates.split(/,\s*/);
473        var length = dates_array.length;
474        var element = null;
475        var new_dates_array = [];
476
477        for (var i = 0; i < length; i++) {
478
479          element = dates_array[i].split(/\./);
480
481          new_dates_array[new_dates_array.length] = element[2]+'.' + element[1]+'.' + element[0];       //2013.12.20
482        }        
483        new_dates_array.sort();
484
485        element = new_dates_array[0].split(/\./);
486
487        return element[2]+'.' + element[1]+'.' + element[0];                    //20.12.2013
488    }
489
490    // Range days selection
491    if ( dates.indexOf(' - ') != -1 ){                  
492        var start_end_date = dates.split(" - ");
493        return start_end_date[0];
494    }
495
496    // Single day selection 
497    return dates;                                                               //20.12.2013
498}
499
500
501// Get fisrst day of selection
502function get_last_day_of_selection(dates) {
503
504    // Multiple days selections
505    if ( dates.indexOf(',') != -1 ){                  
506        var dates_array =dates.split(/,\s*/);
507        var length = dates_array.length;
508        var element = null;
509        var new_dates_array = [];
510
511        for (var i = 0; i < length; i++) {
512
513          element = dates_array[i].split(/\./);
514
515          new_dates_array[new_dates_array.length] = element[2]+'.' + element[1]+'.' + element[0];       //2013.12.20
516        }        
517        new_dates_array.sort();
518
519        element = new_dates_array[(new_dates_array.length-1)].split(/\./);
520
521        return element[2]+'.' + element[1]+'.' + element[0];                    //20.12.2013
522    }
523
524    // Range days selection
525    if ( dates.indexOf(' - ') != -1 ){                  
526        var start_end_date = dates.split(" - ");
527        return start_end_date[(start_end_date.length-1)];
528    }
529
530    // Single day selection 
531    return dates;                                                               //20.12.2013
532}
533
534
535// Set selected days at calendar as UnAvailable
536function setUnavailableSelectedDays( bk_type ){
537    var sel_dates = jQuery('#calendar_booking'+bk_type).datepick('getDate');
538    var class_day2;
539    for( var i =0; i <sel_dates.length; i++) {
540      class_day2 = (sel_dates[i].getMonth()+1) + '-' + sel_dates[i].getDate() + '-' + sel_dates[i].getFullYear();
541      date_approved[ bk_type ][ class_day2 ] = [ (sel_dates[i].getMonth()+1) ,  sel_dates[i].getDate(),  sel_dates[i].getFullYear(),0,0,0];
542      jQuery('#calendar_booking'+bk_type+' td.cal4date-'+class_day2).html(sel_dates[i].getDate());
543      // jQuery('#calendar_booking'+bk_type).datepick('refresh');
544    }
545}
546
547
548// After reservation action is done
549function setReservedSelectedDates( bk_type ){
550
551    var is_pay_now = false;
552
553    if (document.getElementById('calendar_booking'+bk_type) === null )  {
554        
555        jQuery( '#submiting' + bk_type ).html( '' );
556        jQuery( '#booking_form_div' + bk_type ).hide();
557        makeScroll( '#ajax_respond_insert'+bk_type );
558
559        if ( ( document.getElementById('gateway_payment_forms'+bk_type) != null ) && 
560             ( document.getElementById('gateway_payment_forms'+bk_type).innerHTML != '' ) )
561                is_pay_now = true;
562
563        if ( (! is_pay_now) || ( is_booking_without_payment == true ) )             
564            if (type_of_thank_you_message == 'page') {      // Page
565                timeoutID_of_thank_you_page = setTimeout(function ( ) {location.href= thank_you_page_URL;} ,1000);
566            } else {                                        // Message
567                document.getElementById('submiting'+bk_type).innerHTML = '<div class=\"submiting_content wpdev-help-message alert alert-warning alert-success\" >'+new_booking_title+'</div>';
568                jQuery('.submiting_content').fadeOut( new_booking_title_time );
569                setTimeout( function () { location.reload( true ); }, parseInt( 1000 + new_booking_title_time ) );  //FixIn: 8.1.2.14
570            }
571
572    } else {
573
574        setUnavailableSelectedDays( bk_type );           
575        document.getElementById('date_booking' + bk_type).value = '';           
576        jQuery('#calendar_booking' + bk_type + ', .block_hints').hide();
577
578        if ( location.href.indexOf('admin.php') == -1 ) {                       // Front End
579            
580            // Get calendar from the html and insert it before form div, which will hide after btn click
581            jQuery('#calendar_booking' + bk_type).insertBefore("#booking_form_div" + bk_type);
582            document.getElementById("booking_form_div" + bk_type).style.display = "none";
583
584            jQuery( '#hided_booking_form' + bk_type ).prevAll( 'select[name="active_booking_form"]' ).hide();       //FixIn: 7.1.2.13
585            jQuery( '#hided_booking_form' + bk_type ).prevAll( 'label[for="calendar_type"]' ).hide();
586
587            makeScroll('#ajax_respond_insert' + bk_type);
588
589            if ((document.getElementById('gateway_payment_forms' + bk_type) != null) &&
590                    (document.getElementById('gateway_payment_forms' + bk_type).innerHTML != ''))
591                is_pay_now = true;
592
593            if ((!is_pay_now) || (is_booking_without_payment == true)) {
594                if (type_of_thank_you_message == 'page') {      // Page
595                    timeoutID_of_thank_you_page = setTimeout(function ( ) {
596                        location.href = thank_you_page_URL;
597                    }, 1000);
598                } else {                                        // Message
599                    document.getElementById('submiting' + bk_type).innerHTML = '<div class=\"submiting_content wpdev-help-message alert alert-warning alert-success\" >' + new_booking_title + '</div>';
600
601                    //FixIn: 8.5.2.26
602                    if  ( ! jQuery('#submiting' + bk_type ).is('visible') ) {
603                        jQuery('#submiting' + bk_type ).closest( 'form.booking_form').before( jQuery('#submiting' + bk_type ) );
604                        jQuery('#submiting' + bk_type ).show();
605                        jQuery(".wpbc_submit_spinner").hide();
606                    }
607
608                    makeScroll( '#submiting' + bk_type );
609                    jQuery('.submiting_content').fadeOut( new_booking_title_time );
610                    setTimeout( function () { location.reload( true ); }, parseInt( 1000 + new_booking_title_time ) );  //FixIn: 8.1.2.14
611                }
612            }
613
614        } else {                                                                // Back End
615            setTimeout( function () { 
616                location.reload( true );
617            }, 1000);
618        }
619    }
620}
621
622
623/**
624 * Check ID of selected additional calendars
625 *
626 * @param int bk_type
627 * @returns array
628 */
629function wpbc_get_arr_of_selected_additional_calendars( bk_type ){                                                      //FixIn: 8.5.2.26
630
631    var selected_additionl_calendars = [];
632
633    // Checking according additional calendars
634    if ( document.getElementById( 'additional_calendars' + bk_type ) != null ){
635
636        var id_additional_str = document.getElementById( 'additional_calendars' + bk_type ).value;
637        var id_additional_arr = id_additional_str.split( ',' );
638
639        var is_all_additional_days_unselected = true;
640
641        for ( var ia = 0; ia < id_additional_arr.length; ia++ ){
642            if ( document.getElementById( 'date_booking' + id_additional_arr[ ia ] ).value != '' ){
643                selected_additionl_calendars.push( id_additional_arr[ ia ] );
644            }
645        }
646    }
647    return selected_additionl_calendars;
648}
649
650////////////////////////////////////////////////////////////////////////////
651// Submit Booking Data 
652////////////////////////////////////////////////////////////////////////////
653
654// Check fields at form and then send request
655function mybooking_submit( submit_form , bk_type, wpdev_active_locale){
656//console.log( wpbc_get_arr_of_selected_additional_calendars( bk_type ) );
657
658
659    var target_elm = jQuery( ".booking_form_div" ).trigger( "booking_form_submit_click", [bk_type, submit_form, wpdev_active_locale] );     //FixIn: 8.8.3.13
660    if  (
661            ( jQuery( target_elm ).find( 'input[name="booking_form_show_summary"]' ).length > 0 )
662         && ( 'pause_submit' === jQuery( target_elm ).find( 'input[name="booking_form_show_summary"]' ).val() )
663        )
664    {
665        return false;
666    }
667
668    //FixIn: 8.4.0.2
669    var is_error = wpbc_check_errors_in_booking_form( bk_type );
670    if ( is_error ) { return false; }
671
672    // Show message if no selected days in Calendar(s)
673    if (document.getElementById('date_booking' + bk_type).value == '')  {
674
675        var arr_of_selected_additional_calendars = wpbc_get_arr_of_selected_additional_calendars( bk_type );            //FixIn: 8.5.2.26
676
677        if ( arr_of_selected_additional_calendars.length == 0 ) {
678            showMessageUnderElement( '#date_booking' + bk_type, message_verif_selectdts, '');
679            makeScroll('#calendar_booking' + bk_type);            // Scroll to the calendar
680            return;
681        }
682    }
683
684    var count = submit_form.elements.length;
685    var formdata = '';
686    var inp_value;
687    var element;
688    var el_type;
689
690
691    // Serialize form here
692    for (i=0; i<count; i++)   {
693        element = submit_form.elements[i];
694        
695        if ( jQuery( element ).closest( '.booking_form_garbage' ).length ) {
696            continue;       // Skip elements from garbage                                           //FixIn: 7.1.2.14
697        }
698
699        if ( 
700               ( element.type !== 'button' ) 
701            && ( element.type !== 'hidden' ) 
702            && ( element.name !== ( 'date_booking' + bk_type ) )   
703            // && ( jQuery( element ).is( ':visible' ) )                                            //FixIn: 7.2.1.12.2 // Its prevent of saving hints,  and some other hidden element
704        ) {           // Skip buttons and hidden element - type                                     //FixIn: 7.2.1.12
705
706
707            // Get Element Value
708            if ( element.type == 'checkbox' ){
709
710                if (element.value == '') {
711                    inp_value = element.checked;
712                } else {
713                    if (element.checked) inp_value = element.value;
714                    else inp_value = '';
715                }
716
717            } else if ( element.type == 'radio' ) {
718
719                if (element.checked) {
720                    inp_value = element.value; 
721                } else {
722                        // Cehck  if this radio required,  and if its do not checked,  then show warning, otherwise if it not required or some other option checked skip this loop
723                        // We need to  check  it here, because radio have the several  otions with  same name and type and otherwsie we will save several options with  selcted and empty values.
724                    if (                                                        //FixIn: 7.0.1.62
725                           ( element.className.indexOf('wpdev-validates-as-required') !== -1 )
726                        && ( jQuery( element ).is( ':visible' ) )                                            //FixIn: 7.2.1.12.2 // Its prevent of saving hints,  and some other hidden element
727                        && ( ! jQuery(':radio[name="'+element.name+'"]', submit_form).is(":checked") ) ) {
728                        showErrorMessage( element , message_verif_requred_for_radio_box, false );   		//FixIn: 8.5.1.3
729                        return;   
730                    }
731                    continue;
732                }
733            } else {
734                inp_value = element.value;
735            }                      
736
737            // Get value in selectbox of multiple selection
738            if (element.type =='select-multiple') {
739                inp_value = jQuery('[name="'+element.name+'"]').val() ;
740                if (( inp_value == null ) || (inp_value.toString() == '' ))
741                    inp_value='';
742            }
743
744            // Make validation  only  for visible elements
745            if ( jQuery( element ).is( ':visible' ) ) {                                             //FixIn: 7.2.1.12.2
746                // Recheck for max num. available visitors selection
747                if ( element.name == ('visitors'+bk_type) ){
748					if ( typeof(is_max_visitors_selection_more_than_available) == 'function' ){
749
750						//FixIn: 8.2.1.28
751					    if (    ( wpbc_is_time_field_in_booking_form( bk_type, submit_form.elements ) )
752					         && ( ! wpdev_in_array( parent_booking_resources, bk_type ) )
753                           ) {
754
755					        // We are having timeslots and this is single booking resource,  so  skip checking for max number of visitors
756
757                        }  else {
758
759							if ( is_max_visitors_selection_more_than_available( bk_type, inp_value, element ) ){
760								return;
761							}
762						}
763					}
764				}
765                // Phone validation
766                /*if ( element.name == ('phone'+bk_type) ) {
767                    // we validate a phone number of 10 digits with no comma, no spaces, no punctuation and there will be no + sign in front the number - See more at: http://www.w3resource.com/javascript/form/phone-no-vali
767dation.php#sthash.U9FHwcdW.dpuf
768                    var reg =  /^\d{10}$/;
769                    var message_verif_phone = "Please enter correctly phone number";
770                    if ( inp_value != '' )
771                        if(reg.test(inp_value) == false) {showErrorMessage( element , message_verif_phone, false );return;}
772                }*/
773
774                // Validation Check --- Requred fields
775                if ( element.className.indexOf('wpdev-validates-as-required') !== -1 ){             
776                    if  ((element.type =='checkbox') && ( element.checked === false)) {
777                        if ( ! jQuery(':checkbox[name="'+element.name+'"]', submit_form).is(":checked") ) {
778                            showErrorMessage( element , message_verif_requred_for_check_box, false );   		//FixIn: 8.5.1.3
779                            return;                            
780                        }
781                    }
782                    if  (element.type =='radio') {
783                        if ( ! jQuery(':radio[name="'+element.name+'"]', submit_form).is(":checked") ) {
784                            showErrorMessage( element , message_verif_requred_for_radio_box, false );   		//FixIn: 8.5.1.3
785                            return;                            
786                        }
787                    }
788
789                    if (  (element.type != 'checkbox') && (element.type != 'radio') && ( '' === wpbc_trim( inp_value ) )  ){       //FixIn: 8.8.1.3   //FixIn:7.0.1.39       //FixIn: 8.7.11.12
790                        showErrorMessage( element , message_verif_requred, false );   		//FixIn: 8.5.1.3
791                        return;
792                    }
793                }
794
795                // Validation Check --- Email correct filling field
796                if ( element.className.indexOf('wpdev-validates-as-email') !== -1 ){   
797                    inp_value = inp_value.replace(/^\s+|\s+$/gm,'');                // Trim  white space //FixIn: 5.4.5
798                    var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/;
799                    if ( inp_value != '' )
800                        if(reg.test(inp_value) == false) {
801                            showErrorMessage( element , message_verif_emeil, false );   		//FixIn: 8.5.1.3
802                            return;
803                        }
804                }
805
806                // Validation Check --- Same Email Field
807                if ( ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) && ( element.className.indexOf('same_as_') !== -1 ) ) { 
808
809                    // Get  the name of Primary Email field from the "same_as_NAME" class                    
810                    var primary_email_name = element.className.match(/same_as_([^\s])+/gi); 
811                    if (primary_email_name != null) { // We found
812                        primary_email_name = primary_email_name[0].substr(8);
813
814                        // Recehck if such primary email field exist in the booking form
815                        if (jQuery('[name="' + primary_email_name + bk_type + '"]').length > 0) {
816
817                            // Recheck the values of the both emails, if they do  not equla show warning                    
818                            if ( jQuery('[name="' + primary_email_name + bk_type + '"]').val() !== inp_value ) {
819                                showErrorMessage( element , message_verif_same_emeil , false );   		//FixIn: 8.5.1.3
820                                return;
821                            }
822                        }
823                    }
824                    // Skip one loop for the email veryfication field
825                    continue;                                                                                           //FixIn: 8.1.2.15
826                }
827
828            }
829            
830            // Get Form Data
831            if ( element.name !== ('captcha_input' + bk_type) ) {
832                if (formdata !=='') formdata +=  '~';                                                // next field element
833
834                el_type = element.type;
835                if ( element.className.indexOf('wpdev-validates-as-email') !== -1 )  el_type='email';
836                if ( element.className.indexOf('wpdev-validates-as-coupon') !== -1 ) el_type='coupon';
837
838                inp_value = inp_value + '';
839                inp_value = inp_value.replace(new RegExp("\\^",'g'), '&#94;'); // replace registered characters
840                inp_value = inp_value.replace(new RegExp("~",'g'), '&#126;'); // replace registered characters
841
842                inp_value = inp_value.replace(/"/g, '&#34;'); // replace double quot
843                inp_value = inp_value.replace(/'/g, '&#39;'); // replace single quot
844
845                formdata += el_type + '^' + element.name + '^' + inp_value ;                    // element attr
846            }
847        }
848
849    }  // End Fields Loop
850
851    //FixIn:6.1.1.3
852    if( typeof( is_this_time_selections_not_available ) == 'function' ) {
853        
854        if ( document.getElementById('date_booking' + bk_type).value == '' )  {         // Primary calendar not selected.    
855
856            if ( document.getElementById('additional_calendars' + bk_type ) != null ) { // Checking additional calendars.
857
858                var id_additional_str = document.getElementById('additional_calendars' + bk_type).value; //Loop have to be here based on , sign
859                var id_additional_arr = id_additional_str.split(',');
860                var is_times_dates_ok = false;
861                for ( var ia=0;ia<id_additional_arr.length;ia++ ) {
862                    if (
863                            ( document.getElementById('date_booking' + id_additional_arr[ia] ).value != '' ) 
864                         && ( ! is_this_time_selections_not_available( id_additional_arr[ia], submit_form.elements ) )
865                       ){
866                        is_times_dates_ok = true;
867                    }
868                }
869                if ( ! is_times_dates_ok ) return;
870            }
871        } else {                                                                        //Primary calendar selected.
872            if ( is_this_time_selections_not_available( bk_type, submit_form.elements ) )
873                return;            
874        }
875    }
876
877    if ( bk_days_selection_mode == 'dynamic' ) {                                // Check if visitor finish  dates selection.
878                                                                                //FixIn:6.1.1.5
879        var selected_dates_cal_id = [];                                         // Get ID of calendars,  where selected dates.  
880        if ( document.getElementById('date_booking' + bk_type).value != '' ) {  
881            selected_dates_cal_id[selected_dates_cal_id.length] = bk_type;   
882        }
883        if ( document.getElementById('additional_calendars' + bk_type) != null ) {  // Checking according additional calendars.
884            var id_additional_str = document.getElementById('additional_calendars' + bk_type).value; //Loop have to be here based on , sign
885            var id_additional_arr = id_additional_str.split(',');
886            var is_all_additional_days_unselected = true;
887            for (var ia=0;ia<id_additional_arr.length;ia++) {
888                if (document.getElementById('date_booking' + id_additional_arr[ia] ).value != '' ) {
889                    selected_dates_cal_id[selected_dates_cal_id.length] = id_additional_arr[ia];
890                }
891            }
892        }     
893        for( var ci = 0; ci < selected_dates_cal_id.length; ci++) {
894            var abk_type = selected_dates_cal_id[selected_dates_cal_id.length]
895            if (document.getElementById('calendar_booking'+abk_type) != null ) {
896                var inst = jQuery.datepick._getInst(document.getElementById('calendar_booking'+abk_type));
897                if (bk_2clicks_mode_days_min != undefined) {
898                    if(typeof( check_conditions_for_range_days_selection_for_check_in ) == 'function') { 
899                        var first_date  = get_first_day_of_selection(document.getElementById('date_booking' + abk_type).value);                  
900                        var date_sections = first_date.split("."); 
901                        var selceted_first_day = new Date;       
902                        selceted_first_day.setFullYear( parseInt(date_sections[2]-0) ,parseInt(date_sections[1]-1), parseInt(date_sections[0]-0) );
903                        check_conditions_for_range_days_selection_for_check_in(selceted_first_day, abk_type); 
904                    } 
905                    if (inst.dates.length < bk_2clicks_mode_days_min ) {
906                        showMessageUnderElement( '#date_booking' + abk_type, message_verif_selectdts, '');                             
907                        makeScroll('#calendar_booking' + abk_type);            // Scroll to the calendar    
908                        return;
909                    }
910                }
911            }
912        }
913    }
914
915    // Cpatch  verify
916    var captcha = document.getElementById('wpdev_captcha_challenge_' + bk_type);
917
918    //Disable Submit button
919    jQuery('#booking_form_div' + bk_type + ' input[type="button"]').prop("disabled", true);
920    jQuery('#booking_form_div' + bk_type + ' button').prop("disabled", true);   //FixIn: 8.5.2.7
921    if (captcha != null)  form_submit_send( bk_type, formdata, captcha.value, document.getElementById('captcha_input' + bk_type).value ,wpdev_active_locale);
922    else                  form_submit_send( bk_type, formdata, '',            '' ,                                                      wpdev_active_locale);
923    return;
924}
925
926
927// Gathering params for sending Ajax request and then send it
928function form_submit_send( bk_type, formdata, captcha_chalange, user_captcha ,wpdev_active_locale){
929
930    document.getElementById('submiting' + bk_type).innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><img style="vertical-align:middle;box-shadow:none;width:14px;" src="'+wpdev_bk_plugin_url+'/assets/img/ajax-loader.gif"><//div>';
931
932    var my_booking_form = '';
933    var my_booking_hash = '';
934    if (document.getElementById('booking_form_type' + bk_type) != undefined)
935        my_booking_form =document.getElementById('booking_form_type' + bk_type).value;
936
937    if ( wpdev_bk_edit_id_hash != '' ) my_booking_hash = wpdev_bk_edit_id_hash;
938
939    var is_send_emeils = 1;
940    if ( jQuery('#is_send_email_for_pending').length ) {
941        is_send_emeils = jQuery( '#is_send_email_for_pending' ).is( ':checked' );       //FixIn: 8.7.9.5
942        if ( false === is_send_emeils ) { is_send_emeils = 0; }
943        else                            { is_send_emeils = 1; }
944    }
945
946    if ( document.getElementById('date_booking' + bk_type).value != '' )        //FixIn:6.1.1.3
947        send_ajax_submit(bk_type,formdata,captcha_chalange,user_captcha,is_send_emeils,my_booking_hash,my_booking_form,wpdev_active_locale   ); // Ajax sending request
948    else {
949        jQuery('#booking_form_div' + bk_type ).hide();
950        jQuery('#submiting' + bk_type ).hide();        
951    }
952    
953    var formdata_additional_arr;
954    var formdata_additional;
955    var my_form_field;
956    var id_additional;
957    var id_additional_str;
958    var id_additional_arr;
959    if (document.getElementById('additional_calendars' + bk_type) != null ) {
960
961        id_additional_str = document.getElementById('additional_calendars' + bk_type).value; //Loop have to be here based on , sign
962        id_additional_arr = id_additional_str.split(',');
963
964        //FixIn: 8.5.2.26
965        if ( ! jQuery( '#booking_form_div' + bk_type ).is( ':visible' ) ) {
966            jQuery( '#booking_form_div' + bk_type ).after(
967                '<div class="wpbc_submit_spinner" style="height:20px;width:100%;text-align:center;margin:15px auto;"><img style="vertical-align:middle;box-shadow:none;width:14px;" src="'+wpdev_bk_plugin_url+'/assets/img/ajax-loader.gif"></div>'
968            );
969        }
970
971
972
973        for (var ia=0;ia<id_additional_arr.length;ia++) {
974            formdata_additional_arr = formdata;
975            formdata_additional = '';
976            id_additional = id_additional_arr[ia];
977
978
979            formdata_additional_arr = formdata_additional_arr.split('~');
980            for (var j=0;j<formdata_additional_arr.length;j++) {
981                my_form_field = formdata_additional_arr[j].split('^');
982                if (formdata_additional !=='') formdata_additional +=  '~';
983
984                if (my_form_field[1].substr( (my_form_field[1].length -2),2)=='[]')
985                  my_form_field[1] = my_form_field[1].substr(0, (my_form_field[1].length - (''+bk_type).length ) - 2 ) + id_additional + '[]';
986                else
987                  my_form_field[1] = my_form_field[1].substr(0, (my_form_field[1].length - (''+bk_type).length ) ) + id_additional ;
988
989
990                formdata_additional += my_form_field[0] + '^' + my_form_field[1] + '^' + my_form_field[2];
991            }
992
993            if ( jQuery('#gateway_payment_forms' + bk_type).length > 0 ) {         // If Payment form  for main  booking resources is showing then append payment form  for additional  calendars.
994                jQuery('#gateway_payment_forms' + bk_type).after('<div id="gateway_payment_forms'+id_additional+'"></div>');
995                jQuery('#gateway_payment_forms' + bk_type).after('<div id="ajax_respond_insert'+id_additional+'" style="display:none;"></div>');
996            }
997            //FixIn: 8.5.2.17
998            send_ajax_submit( id_additional ,formdata_additional,captcha_chalange,user_captcha,is_send_emeils,my_booking_hash,my_booking_form ,wpdev_active_locale  );  // Submit
999
1000//            if (document.getElementById('date_booking' + id_additional).value != '' ) {
1001//                setUnavailableSelectedDays(id_additional);                                              // Set selected days unavailable in this calendar
1002//                jQuery('#calendar_booking'+id_additional).insertBefore("#booking_form_div"+bk_type);    // Insert calendar before form to do not hide it
1003//                if (document.getElementById('gateway_payment_forms'+id_additional) != null)
1004//                    jQuery('#gateway_payment_forms'+id_additional).insertBefore("#booking_form_div"+bk_type);    // Insert payment form to do not hide it
1005//                else {
1006//                    jQuery("#booking_form_div"+bk_type).append('<div id="gateway_payment_forms'+id_additional+'" ></div>');
1007//                    jQuery("#booking_form_div"+bk_type).append('<div id="ajax_respond_insert'+id_additional+'" ></div>');
1008//                }
1009//                send_ajax_submit( id_additional ,formdata_additional,captcha_chalange,user_captcha,is_send_emeils,my_booking_hash,my_booking_form ,wpdev_active_locale  );
1010//            }
1011        }
1012    }
1013}
1014
1015
1016//<![CDATA[
1017function send_ajax_submit(bk_type,formdata,captcha_chalange,user_captcha,is_send_emeils,my_booking_hash,my_booking_form  ,wpdev_active_locale ) {
1018        // Ajax POST here
1019
1020        var my_bk_res = bk_type;
1021        if ( document.getElementById('bk_type' + bk_type) != null ) my_bk_res = document.getElementById('bk_type' + bk_type).value;
1022
1023        jQuery.ajax({                                           // Start Ajax Sending
1024            // url: wpdev_bk_plugin_url+ '/' + wpdev_bk_plugin_filename,
1025            url: wpbc_ajaxurl, 
1026            type:'POST',
1027            success: function (data, textStatus){if( textStatus == 'success')   jQuery('#ajax_respond_insert' + bk_type).html( data ) ;},
1028            error:function (XMLHttpRequest, textStatus, errorThrown){window.status = 'Ajax sending Error status:'+ textStatus;alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);if (XMLHttpRequest.status == 500) {alert('Please check at this page according this error:' + ' https://wpbookingcalendar.com/faq/#ajax-sending-error');}},
1029            // beforeSend: someFunction,
1030            data:{
1031                // ajax_action : 'INSERT_INTO_TABLE',
1032                action : 'INSERT_INTO_TABLE',
1033                bktype: my_bk_res ,
1034                dates: document.getElementById('date_booking' + bk_type).value ,
1035                form: formdata,
1036                captcha_chalange:captcha_chalange,
1037                captcha_user_input: user_captcha,
1038                is_send_emeils : is_send_emeils,
1039                my_booking_hash:my_booking_hash,
1040                booking_form_type:my_booking_form,
1041                wpdev_active_locale:wpdev_active_locale,
1042                wpbc_nonce: document.getElementById('wpbc_nonce' + bk_type).value 
1043            }
1044        });
1045}
1046//]]>
1047
1048////////////////////////////////////////////////////////////////////////////
1049////////////////////////////////////////////////////////////////////////////
1050
1051// Show Error Message in Booking Form  at Front End
1052function showErrorMessage( element , errorMessage , isScrollStop ) {    //FixIn: 8.5.1.3
1053    //FixIn: 8.4.0.2
1054    // if(typeof( bk_form_step_click ) == 'function') {
1055    //     bk_form_step_click();                                                   // rollback  to 1st  step,  if system  will show warning and booking form  is using this customization: in the Exmaple #2 here: https://wpbookingcalendar.com/faq/customize-booking-form-for-having-several-steps-of-reservation/
1056    // }
1057
1058    //FixIn: 8.5.1.3
1059    if ( ! isScrollStop ){
1060        makeScroll( element );
1061    }
1062    //FixIn: 8.7.11.10
1063    if ( jQuery( "[name='" + element.name + "']" ).is( ':visible' ) ){
1064        jQuery("[name='"+ element.name +"']")
1065                .fadeOut( 350 ).fadeIn( 300 )
1066                .fadeOut( 350 ).fadeIn( 400 )
1067                .fadeOut( 350 ).fadeIn( 300 )
1068                .fadeOut( 350 ).fadeIn( 400 )
1069                .animate( {opacity: 1}, 4000 )
1070        ;  // mark red border
1071    }
1072    if (jQuery("[name='"+ element.name +"']").attr('type') == "radio") {
1073
1074        if (    ( ! jQuery( "[name='" + element.name + "']" ).parent().parent().parent().next().hasClass( 'alert-warning' ))
1075             || (
1076                      (   jQuery( "[name='" + element.name + "']" ).parent().parent().parent().next().hasClass( 'alert-warning' ))
1077                   && ( ! jQuery( "[name='" + element.name + "']" ).parent().parent().parent().next().is( ':visible' ) )
1078                )
1079        ){  //FixIn: 8.4.5.7
1080            jQuery( "[name='" + element.name + "']" ).parent().parent().parent()
1081                .after( '<span class="wpdev-help-message alert alert-warning">' + errorMessage + '</span>' ); // Show message
1082        }
1083
1084    } else if (jQuery("[name='"+ element.name +"']").attr('type') == "checkbox") {
1085
1086        if (    ( ! jQuery( "[name='" + element.name + "']" ).parent().next().hasClass( 'alert-warning' ))
1087             || (
1088                      (   jQuery( "[name='" + element.name + "']" ).parent().next().hasClass( 'alert-warning' ))
1089                   && ( ! jQuery( "[name='" + element.name + "']" ).parent().next().is( ':visible' ) )
1090                )
1091        ){  //FixIn: 8.4.5.7
1092            jQuery( "[name='" + element.name + "']" ).parent()
1093                .after( '<span class="wpdev-help-message alert alert-warning">' + errorMessage + '</span>' ); // Show message
1094        }
1095
1096    } else {
1097
1098        if (    ( ! jQuery( "[name='" + element.name + "']" ).next().hasClass( 'alert-warning' ))
1099             || (
1100                      (   jQuery( "[name='" + element.name + "']" ).next().hasClass( 'alert-warning' ))
1101                   && ( ! jQuery( "[name='" + element.name + "']" ).next().is( ':visible' ) )
1102                )
1103        ){  //FixIn: 8.4.5.7
1104            jQuery( "[name='" + element.name + "']" )
1105                .after( '<span class="wpdev-help-message alert alert-warning">' + errorMessage + '</span>' ); // Show message
1106        }
1107    }
1108    jQuery(".wpdev-help-message")
1109            .css( {'padding' : '5px 5px 4px', 'margin' : '2px 2px 2px 10px', 'vertical-align': 'top', 'line-height': '32px' } );
1110    
1111    if ( element.type == 'checkbox' )
1112        jQuery(".wpdev-help-message").css( { 'vertical-align': 'middle'} );
1113            
1114    jQuery(".widget_wpdev_booking .booking_form .wpdev-help-message")
1115            .css( {'vertical-align': 'sub' } ) ;
1116    jQuery(".wpdev-help-message")
1117            .animate( {opacity: 1}, 10000 )
1118            .fadeOut( 2000 );
1119
1120    if ( ! jQuery( "[name='" + element.name + "']" ).is( ':visible' ) ){
1121        makeScroll( jQuery(".wpdev-help-message") );
1122    }
1123    jQuery( element ).trigger( 'focus' );    //FixIn: 8.7.11.12
1124    return;
1125
1126}
1127
1128/**
1129 * Show message under specific element
1130 * 
1131 * @param {type} element - jQuery definition  of the element
1132 * @param {type} errorMessage - String message
1133 * @param {type} message_type "" | "alert-danger" | "alert-success" | "alert-info"
1134 */
1135function showMessageUnderElement( element , errorMessage , message_type) {
1136    //FixIn: 8.4.0.2
1137    // if(typeof( bk_form_step_click ) == 'function') {
1138    //     bk_form_step_click();                                                   // rollback  to 1st  step,  if system  will show warning and booking form  is using this customization: in the Exmaple #2 here: https://wpbookingcalendar.com/faq/customize-booking-form-for-having-several-steps-of-reservation/
1139    // }
1140    
1141     makeScroll( element );
1142    
1143     if ( jQuery( element ).attr('type') == "radio" ) {
1144
1145        if (    ( ! jQuery( element ).parent().parent().parent().next().hasClass( 'alert-warning' ))
1146             || (
1147                      (   jQuery( element ).parent().parent().parent().next().hasClass( 'alert-warning' ))
1148                   && ( ! jQuery( element ).parent().parent().parent().next().is( ':visible' ) )
1149                )
1150        ){  //FixIn: 8.4.5.7
1151            jQuery( element ).parent().parent().parent()
1152                .after( '<span class="wpdev-help-message wpdev-element-message alert alert-warning ' + message_type + '">' + errorMessage + '</span>' ); // Show message
1153        }
1154    } else if (jQuery( element ).attr('type') == "checkbox") {
1155
1156        if (    ( ! jQuery( element ).parent().next().hasClass( 'alert-warning' ))
1157             || (
1158                      (   jQuery( element ).parent().next().hasClass( 'alert-warning' ))
1159                   && ( ! jQuery( element ).parent().next().is( ':visible' ) )
1160                )
1161        ){  //FixIn: 8.4.5.7
1162            jQuery( element ).parent()
1163                .after( '<span class="wpdev-help-message wpdev-element-message alert alert-warning ' + message_type + '">' + errorMessage + '</span>' ); // Show message
1164        }
1165    } else {
1166        if (    ( ! jQuery( element ).next().hasClass( 'alert-warning' ))
1167                     || (
1168                              (   jQuery( element ).next().hasClass( 'alert-warning' ))
1169                           && ( ! jQuery( element ).next().is( ':visible' ) )
1170                        )
1171            ){  //FixIn: 8.4.5.7
1172            jQuery( element )
1173                .after( '<span class="wpdev-help-message wpdev-element-message alert alert-warning ' + message_type + '">' + errorMessage + '</span>' ); // Show message
1174        }
1175    }
1176    //    jQuery(".wpdev-help-message")
1177    //            .css( {'padding' : '5px 5px 4px', 'margin' : '10px 2px', 'vertical-align': 'middle' } );
1178    jQuery(".widget_wpdev_booking .booking_form .wpdev-help-message")
1179            .css( {'vertical-align': 'sub' } ) ;
1180    jQuery(".wpdev-help-message")
1181            .animate( {opacity: 1}, 10000 )
1182            .fadeOut( 2000 ); 
1183}
1184
1185// Hint labels inside of input boxes
1186jQuery(document).ready( function(){
1187
1188    jQuery('div.inside_hint').on( 'click', function(){                   //FixIn: 8.7.11.12
1189            jQuery(this).css('visibility', 'hidden').siblings('.has-inside-hint').trigger( 'focus' );   //FixIn: 8.7.11.12
1190    });
1191
1192    jQuery('input.has-inside-hint').on( 'blur', function(){                   //FixIn: 8.7.11.12
1193        if ( this.value == '' )
1194            jQuery(this).siblings('.inside_hint').css('visibility', '');
1195    }).on( 'focus', function(){                                                 //FixIn: 8.7.11.12
1196            jQuery(this).siblings('.inside_hint').css('visibility', 'hidden');
1197    });
1198
1199    jQuery('.booking_form_div input[type=button]').prop("disabled", false);
1200});
1201
1202
1203////////////////////////////////////////////////////////////////////////////
1204// Support Functions
1205////////////////////////////////////////////////////////////////////////////
1206
1207// Scroll to script
1208function makeScroll(object_name) {
1209     var targetOffset = jQuery( object_name ).offset().top;
1210     //targetOffset = targetOffset - 50;
1211     if (targetOffset<0) targetOffset = 0;
1212     if ( jQuery('#wpadminbar').length > 0 ) targetOffset = targetOffset - 50;
1213     else  targetOffset = targetOffset - 20;
1214     jQuery('html,body').animate({scrollTop: targetOffset}, 500);
1215}
1216
1217
1218//FixIn: 8.8.1.3
1219/**
1220 * Trim  strings and array joined with  (,)
1221 *
1222 * @param string_to_trim   string / array
1223 * @returns string
1224 */
1225function wpbc_trim( string_to_trim ){
1226
1227    if ( Array.isArray( string_to_trim ) ){
1228        string_to_trim = string_to_trim.join( ',' );
1229    }
1230
1231    if ( 'string' == typeof (string_to_trim) ){
1232        string_to_trim = string_to_trim.trim();
1233    }
1234
1235    return string_to_trim;
1236}
1237
1238
1239function wpdev_in_array (array_here, p_val) {
1240   for(var i = 0, l = array_here.length; i < l; i++) {
1241       if(array_here[i] == p_val) {
1242           return true;
1243       }
1244   }
1245   return false;
1246}
1247
1248
1249function days_between(date1, date2) {
1250
1251    // The number of milliseconds in one day
1252    var ONE_DAY = 1000 * 60 * 60 * 24;
1253
1254    // Convert both dates to milliseconds
1255    var date1_ms = date1.getTime();
1256    var date2_ms = date2.getTime();
1257
1258    // Calculate the difference in milliseconds
1259    var difference_ms =  date1_ms - date2_ms;
1260
1261    // Convert back to days and return
1262    return Math.round(difference_ms/ONE_DAY);
1263
1264}
1265
1266
1267function daysInMonth(month,year) {
1268    var m = [31,28,31,30,31,30,31,31,30,31,30,31];
1269    if (month != 2) return m[month - 1];
1270    if (year%4 != 0) return m[1];
1271    if (year%100 == 0 && year%400 != 0) return m[1];
1272    return m[1] + 1;
1273}
1274
1275
1276function wpbc_timeline_nav( timeline_obj, nav_step ){
1277    
1278    jQuery( ".wpbc_timeline_front_end" ).trigger( "timeline_nav" , [ timeline_obj, nav_step ] );        //FixIn:7.0.1.48
1279    
1280    jQuery( '#'+timeline_obj.html_client_id + ' .wpbc_tl_prev,#'+timeline_obj.html_client_id + ' .wpbc_tl_next').remove();
1281    
1282    jQuery('#'+timeline_obj.html_client_id + ' .wpbc_tl_title').html( '<span class="glyphicon glyphicon-refresh wpbc_spin"></span> &nbsp Loading...' );      // '<div style="height:20px;width:100%;text-align:center;margin:15px auto;">Loading ... <img style="vertical-align:middle;box-shadow:none;width:14px;" src="'+wpdev_bk_plugin_url+'/assets/img/ajax-loader.gif"><//div>'
1283
1284//Deprecated: FixIn: 9.0.1.1.1
1285// if ( 'function' === typeof( jQuery(".popover_click.popover_bottom" ).popover )  )       //FixIn: 7.0.1.2  - 2016-12-10
1286//     jQuery('.popover_click.popover_bottom').popover( 'hide' );                      //Hide all opned popovers
1287        
1288    jQuery.ajax({                                       
1289        url: wpbc_ajaxurl, 
1290        type:'POST',                                                            
1291        success: function ( data, textStatus ){                                 // Note,  here we direct show HTML to TimeLine frame
1292                    if( textStatus == 'success') {
1293                        jQuery('#' + timeline_obj.html_client_id + ' .wpbc_timeline_ajax_replace' ).html( data ); 
1294                        return true;
1295                    }
1296                },
1297        error:  function ( XMLHttpRequest, textStatus, errorThrown){ 
1298                    window.status = 'Ajax Error! Status: ' + textStatus;
1299                    alert( 'Ajax Error! Status: ' + XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText );
1300                },
1301        // beforeSend: someFunction,
1302        data:{
1303                action:             'WPBC_TIMELINE_NAV',
1304                timeline_obj:       timeline_obj,
1305                nav_step:           nav_step,
1306                wpdev_active_locale:wpbc_active_locale,
1307                wpbc_nonce:         document.getElementById('wpbc_nonce_'+ timeline_obj.html_client_id).value 
1308        }
1309    });     
1310}
1311
1312
1313
1314/**
1315	 * Unselect all days in calendar
1316 *
1317 * @param bk_type - ID of booking resource
1318 */
1319function wpbc_unselect_all_days( bk_type ){																				//FixIn: 8.0.1.2
1320
1321	var is_calendar_exist = jQuery( '#calendar_booking' + bk_type );
1322
1323	if ( is_calendar_exist.length > 0 ){
1324
1325		var inst = jQuery.datepick._getInst( document.getElementById( 'calendar_booking' + bk_type ) );					// Unselect all dates 	and set properties of Datepick
1326
1327		jQuery( '#date_booking' + bk_type ).val( '' );
1328		inst.stayOpen = false;
1329		inst.dates = [];
1330		jQuery.datepick._updateDatepick( inst );
1331	}
1332}
1333
1334
1335
1336//FixIn: 8.4.0.2
1337/**
1338 * Check errors in booking form  fields, and show warnings if some errors exist.
1339 * Check  errors,  like not selected dates or not filled requred form  fields, or not correct entering email or phone fields,  etc...
1340 *
1341 * @param bk_type  int (ID of booking resource)
1342 */
1343function wpbc_check_errors_in_booking_form( bk_type ) {
1344
1345    var is_error_in_field = false;  // By default all  is good - no error
1346
1347    var my_form = jQuery( '#booking_form' + bk_type );
1348
1349    if ( my_form.length ) {
1350
1351        // Pseudo-selector that get form elements <input , <textarea , <select, <button...
1352        my_form.find( ':input' ).each( function( index, el ) {
1353
1354            // Skip some elements
1355            var skip_elements = [ 'hidden', 'button' ];
1356
1357            if (  -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) )  ){
1358
1359				// Check Calendar Dates Selection
1360                if ( ( 'date_booking' + bk_type ) == jQuery( el ).attr( 'name' ) ) {
1361
1362                    // Show Warning only  if the calendar visible ( we are at step with  calendar)
1363                    if (
1364                            (  ( jQuery( '#calendar_booking' + bk_type ).is( ':visible' )  ) && ( '' == jQuery( el ).val() )  )
1365                         && ( wpbc_get_arr_of_selected_additional_calendars( bk_type ).length == 0 )                    //FixIn: 8.5.2.26
1366                    ){            //FixIn: 8.4.4.5
1367						showMessageUnderElement( '#date_booking' + bk_type, message_verif_selectdts, '' );
1368						makeScroll('#calendar_booking' + bk_type);            // Scroll to the calendar    		//FixIn: 8.5.1.3
1369						is_error_in_field = true;    // Error
1370                    }
1371                }
1372
1373                // Check only visible elements at this step
1374                if ( jQuery( el ).is( ':visible' )  ){
1375// console.log( '|id, type, val, visible|::', jQuery( el ).attr( 'name' ), '|' + jQuery( el ).attr( 'type' ) + '|', jQuery( el ).val(), jQuery( el ).is( ':visible' ) );
1376
1377					// Is Required
1378					if ( jQuery( el ).hasClass( 'wpdev-validates-as-required' ) ){
1379
1380						// Checkboxes
1381						if ( 'checkbox' == jQuery( el ).attr( 'type' ) ){
1382
1383                            if (
1384                                    ( ! jQuery( el ).is( ':checked' ))
1385                                 && ( ! jQuery( ':checkbox[name="' + el.name + '"]', my_form ).is( ":checked" ) )       //FixIn: 8.5.2.12
1386                            ){
1387								showErrorMessage( el, message_verif_requred_for_check_box, is_error_in_field );
1388								is_error_in_field = true;    // Error
1389							}
1390
1391							// Radio boxes
1392						} else if ( 'radio' == jQuery( el ).attr( 'type' ) ){
1393
1394							if ( !jQuery( ':radio[name="' + jQuery( el ).attr( 'name' ) + '"]', my_form ).is( ':checked' ) ){
1395								showErrorMessage( el, message_verif_requred_for_radio_box, is_error_in_field );
1396								is_error_in_field = true;    // Error
1397							}
1398
1399							// Other elements
1400						} else {
1401
1402							var inp_value = jQuery( el ).val();
1403
1404                            if ( '' === wpbc_trim( inp_value ) ){                                                       //FixIn: 8.8.1.3        //FixIn: 8.7.11.12
1405								showErrorMessage( el, message_verif_requred, is_error_in_field );
1406								is_error_in_field = true;    // Error
1407							}
1408						}
1409					}
1410
1411					// Validate Email
1412					if ( jQuery( el ).hasClass( 'wpdev-validates-as-email' ) ){
1413						var inp_value = jQuery( el ).val();
1414						inp_value = inp_value.replace( /^\s+|\s+$/gm, '' );                // Trim  white space //FixIn: 5.4.5
1415						var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/;
1416						if ( (inp_value != '') && (reg.test( inp_value ) == false) ){
1417							showErrorMessage( el, message_verif_emeil, is_error_in_field );
1418							is_error_in_field = true;    // Error
1419						}
1420					}
1421
1422					// Validate For digit entering - for example for - Phone
1423					// <p>Digit Field:<br />[text* dig_field class:validate_as_digit] </p>
1424					// <p>Phone:<br />[text* phone class:validate_digit_8] </p>
1425
1426					var classList = jQuery( el ).attr( 'class' );
1427
1428					if ( classList ){
1429
1430						classList = classList.split( /\s+/ );
1431
1432                        jQuery.each( classList, function ( cl_index, cl_item ){
1433
1434                            ////////////////////////////////////////////////////////////////////////////////////////////
1435
1436                            // Validate field value as "Date"   [CSS class - 'validate_as_digit']
1437                            if ( 'validate_as_date' === cl_item ) {
1438
1439                                // Valid values: 09-25-2018, 09/25/2018, 09-25-2018,  31-9-1918  ---   m/d/Y, m.d.Y, m-d-Y, d/m/Y, d.m.Y, d-m-Y
1440                                var regex = new RegExp( '^[0-3]?\\d{1}[\\/\\.\\-]+[0-3]?\\d{1}[\\/\\.\\-]+[0-2]+\\d{3}$' );       // Check for Date 09/25/2018
1441                                var message_verif_phone = 'This field must be valid date like this ' + '09/25/2018';
1442                                var inp_value = jQuery( el ).val();
1443
1444                                if (  ( inp_value != '' ) && ( regex.test( inp_value ) == false )  ){
1445                                    showErrorMessage( el, message_verif_phone, is_error_in_field );
1446                                    is_error_in_field = true;    // Error
1447                                }
1448                            }
1449
1450                            ////////////////////////////////////////////////////////////////////////////////////////////
1451
1452                            // Validate field value as "DIGIT"   [CSS class - 'validate_as_digit']
1453                            if ( 'validate_as_digit' === cl_item ) {
1454
1455                                var regex = new RegExp( '^[0-9]+\\.?[0-9]*$' );       // Check for digits
1456                                var message_verif_phone = 'This field must contain only digits';
1457                                var inp_value = jQuery( el ).val();
1458
1459                                if (  ( inp_value != '' ) && ( regex.test( inp_value ) == false )  ){
1460                                    showErrorMessage( el, message_verif_phone, is_error_in_field );
1461                                    is_error_in_field = true;    // Error
1462                                }
1463                            }
1464
1465                            ////////////////////////////////////////////////////////////////////////////////////////////
1466
1467                            // Validate field value as "Phone" number or any other valid number wth specific number of digits [CSS class - 'validate_digit_8' || 'validate_digit_10' ]
1468                            var is_validate_digit = cl_item.substring( 0, 15 );
1469
1470                            // Check  if class start  with 'validate_digit_'
1471                            if ( 'validate_digit_' === is_validate_digit ){
1472
1473                                // Get  number of digit in class: validate_digit_8 => 8 or validate_digit_10 => 10
1474                                var digits_to_check = parseInt( cl_item.substring( 15 ) );
1475
1476                                // Check  about any errors in
1477                                if ( !isNaN( digits_to_check ) ){
1478
1479                                    var regex = new RegExp( '^\\d{' + digits_to_check + '}$' );       // We was valid it as parseInt - only integer variable - digits_to_check
1480                                    var message_verif_phone = 'This field must contain ' + digits_to_check + ' digits';
1481                                    var inp_value = jQuery( el ).val();
1482
1483									if (  ( inp_value != '' ) && ( regex.test( inp_value ) == false )  ){
1484                                        showErrorMessage( el, message_verif_phone, is_error_in_field );
1485                                        is_error_in_field = true;    // Error
1486                                    }
1487                                }
1488                            }
1489
1490                            ////////////////////////////////////////////////////////////////////////////////////////////
1491
1492                        });
1493    				}
1494                }
1495			}
1496        } );
1497
1498	}
1499    return is_error_in_field;
1500}
1501
1502
1503//FixIn: 8.4.4.4
1504function bk_calendar_step_click( el ){
1505    var br_id = jQuery( el ).closest( 'form' ).find( 'input[name^="bk_type"]' ).val();
1506    var is_error = wpbc_check_errors_in_booking_form( br_id );
1507    if ( is_error ){
1508        return false;
1509    }
1510    if ( br_id != undefined ){
1511        jQuery( "#booking_form" + br_id + " .bk_calendar_step" ).css( {"display": "none"} );
1512        jQuery( "#booking_form" + br_id + " .bk_form_step" ).css( {"display": "block"} );
1513    } else {
1514        jQuery( ".bk_calendar_step" ).css( {"display": "none"} );
1515        jQuery( ".bk_form_step" ).css( {"display": "block"} );
1516    }
1517}
1518
1519function bk_form_step_click( el ){
1520    var br_id = jQuery( el ).closest( 'form' ).find( 'input[name^="bk_type"]' ).val();
1521    var is_error = false; // wpbc_check_errors_in_booking_form( br_id );          //FixIn: 8.4.5.6
1522    if ( is_error ){
1523        return false;
1524    }
1525    if ( br_id != undefined ){
1526        jQuery( "#booking_form" + br_id + " .bk_calendar_step" ).css( {"display": "block"} );
1527        jQuery( "#booking_form" + br_id + " .bk_form_step" ).css( {"display": "none"} );
1528        makeScroll( "#bklnk" + br_id );
1529    } else {
1530        jQuery( ".bk_calendar_step" ).css( {"display": "block"} );
1531        jQuery( ".bk_form_step" ).css( {"display": "none"} );
1532    }
1533}
1534
1535//FixIn: 8.6.1.15
1536/**
1537 * Go to next  specific step in Wizard style booking form, with
1538 * check all required elements specific step, otherwise show warning message!
1539 *
1540 * @param el
1541 * @param step_num
1542 * @returns {boolean}
1543 */
1544function wpbc_wizard_step( el, step_num, step_from ){
1545    var br_id = jQuery( el ).closest( 'form' ).find( 'input[name^="bk_type"]' ).val();
1546
1547    //FixIn: 8.8.1.5
1548    if ( ( undefined == step_from ) || ( step_num > step_from ) ){
1549        if ( 1 != step_num ){                                                                       //FixIn: 8.7.7.8
1550            var is_error = wpbc_check_errors_in_booking_form( br_id );
1551            if ( is_error ){
1552                return false;
1553            }
1554        }
1555    }
1556
1557    if ( wpbc_is_some_elements_visible( br_id, ['rangetime', 'durationtime', 'starttime', 'endtime'] ) ){
1558        if ( is_this_time_selections_not_available( br_id, document.getElementById( 'booking_form' + br_id ) ) ){
1559            return false;
1560        }
1561    }
1562    
1563    if ( br_id != undefined ){
1564        jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" ).css( {"display": "none"} );
1565        jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" + step_num ).css( {"display": "block"} );
1566    }
1567}
1568
1569
1570//FixIn: 8.6.1.15
1571/**
1572 * Check if at least  one element from  array  of  elements names in booking form  visible  or not.
1573 * Usage Example:   if ( wpbc_is_some_elements_visible( br_id, ['rangetime', 'durationtime', 'starttime', 'endtime'] ) ){ ... }
1574 *
1575 * @param bk_type
1576 * @param elements_names
1577 * @returns {boolean}
1578 */
1579function wpbc_is_some_elements_visible( bk_type, elements_names ){
1580
1581    var is_some_elements_visible = false;
1582
1583    var my_form = jQuery( '#booking_form' + bk_type );
1584
1585    if ( my_form.length ){
1586
1587        // Pseudo-selector that get form elements <input , <textarea , <select, <button...
1588        my_form.find( ':input' ).each( function ( index, el ){
1589
1590            // Skip some elements
1591            var skip_elements = ['hidden', 'button'];
1592
1593            if ( -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) ) ){
1594
1595                for ( var ei = 0; ei < ( elements_names.length - 1) ; ei++ ){
1596
1597                    // Check Calendar Dates Selection
1598                    if ( (elements_names[ ei ] + bk_type) == jQuery( el ).attr( 'name' ) ){
1599
1600                        if ( jQuery( el ).is( ':visible' ) ){
1601                            is_some_elements_visible = true;
1602                        }
1603                    }
1604                }
1605            }
1606        } );
1607    }
1608    return is_some_elements_visible;
1609}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.