PageSourceSearch

https://www.booktaxinewyork.com/modules/mod_taxibooking/assets/js/modtaxibooking.js

js booktaxinewyork.com collected 2026-10-06 19:28:41 UTC 53,929 bytes, 1,523 lines download raw bytes

1tbjQuery(document).ready(function(){
2    
3    var xhr;
4    
5    tbjQuery.fn.unsetPoiAddress = function() {
6        tbjQuery('input#address_from').val('');
7        tbjQuery('input#address_from_lat').val('');
8	tbjQuery('input#address_from_lng').val('');
9        tbjQuery('div#pickup_extra_wrapper').html('');
10        
11        tbjQuery('input#address_to').val('');
12        tbjQuery('input#address_to_lat').val('');
13	tbjQuery('input#address_to_lng').val('');
14        tbjQuery('div#dropoff_extra_wrapper').html('');
15        
16    }
17    tbjQuery.fn.unsetRoute = function() {
18        
19        var route_swapped = tbjQuery('#route_swapped').val();
20        if(route_swapped==1){ // routes are already swapped, so normalize them
21	    tbjQuery('#route_category_fld').attr('readonly', false);
22	    tbjQuery('#route_category_dropoff_fld').attr('readonly', false);
23            tbjQuery('#route_from_fld').attr('readonly', false);
24            tbjQuery('#route_to_fld').attr('readonly', false);
25            
26            tbjQuery('#route_swapped').val(0);
27        }
28	tbjQuery('#route_category_fld').val('');
29        tbjQuery('#route_from_fld').val('');
30        tbjQuery('#route_to_fld').val('');
31	tbjQuery('#route_category_dropoff').val(0);
32	tbjQuery('#route_category_dropoff_fld').val('');	
33	tbjQuery('#route_category').val(0);
34        tbjQuery('#route_from').val(0);
35	
36	if(tbjQuery('#show_poi_categories').val()==1){
37	    tbjQuery('div.routes_wrapper_from div.routes_from_inner').hide();
38	}
39	
40	tbjQuery('div.routes_wrapper_to').hide();
41	tbjQuery('div.routes_indicator').hide();	
42        tbjQuery('div#routefrom_extra_wrapper').html('');   
43        tbjQuery('div#routeto_extra_wrapper').html('');
44    }
45    tbjQuery.fn.unsetHourlyHire = function() {
46        tbjQuery('#hourly_hr').val(0);
47        tbjQuery('#hourly_min').val(0);
48    }
49    
50    tbjQuery( 'a.field_desc, a.addstop' ).tooltip({
51        track: true
52    });
53    
54    tbjQuery('div#directions_panel').hide(); // hide the direction panel at first load
55    
56    // show dropdown div of poi1
57    var mouseOverPoi1 = false;
58    tbjQuery('div.pickup_wrap .poi_options_trigger').mouseenter(function(){
59        mouseOverPoi1 = true; 
60    }).mouseleave(function(){ 
61        mouseOverPoi1 = false; 
62    })
63    tbjQuery("div.pickup_wrap .poi_options_trigger").click(function(){
64	if(tbjQuery(this).hasClass('Open') == true){
65	    tbjQuery(this).removeClass("Open");
66	}
67	else {
68	    tbjQuery(this).addClass("Open");
69	}
70	if (tbjQuery(this).next('.poi_dropdown_wrapper').is(":visible") == true){
71	    tbjQuery(this).next('.poi_dropdown_wrapper').slideUp(250);
72	}
73	else {
74	    tbjQuery(this).next('.poi_dropdown_wrapper').slideDown(250);
75	}        
76    })
77    tbjQuery("div.pickup_wrap div.poi_dropdown_wrapper div.poi_link").click(function(){
78        tbjQuery('#address_from').val(tbjQuery(this).children('span').html());
79        tbjQuery('#address_from_lat').val(tbjQuery(this).data('poilat'));
80	tbjQuery('#address_from_lng').val(tbjQuery(this).data('poilng'));
81        tbjQuery('div.pickup_wrap div.poi_dropdown_wrapper').hide();
82	tbjQuery('div.pickup_wrap .poi_options_trigger').removeClass('Open');
83        
84        // first unset route options
85        tbjQuery.fn.unsetRoute();
86        tbjQuery.fn.unsetHourlyHire();
87        tbjQuery.fn.getExtras('pickup');
88        
89        // set booking type
90        tbjQuery('#booking_type').val('address');
91    })
92    
93    // show dropdown div of poi2
94    var mouseOverPoi2 = false;
95    tbjQuery('div.dropoff_wrap div.nonstop_wrap .poi_options_trigger').mouseenter(function(){
96        mouseOverPoi2 = true; 
97    }).mouseleave(function(){ 
98        mouseOverPoi2 = false; 
99    })
100    tbjQuery("div.dropoff_wrap div.nonstop_wrap .poi_options_trigger").click(function(){
101	if(tbjQuery(this).hasClass('Open') == true){
102	    tbjQuery(this).removeClass("Open");
103	}
104	else {
105	    tbjQuery(this).addClass("Open");
106	}
107	if (tbjQuery(this).next('.poi_dropdown_wrapper').is(":visible") == true){
108	    tbjQuery(this).next('.poi_dropdown_wrapper').slideUp(250);
109	}
110	else {
111	    tbjQuery(this).next('.poi_dropdown_wrapper').slideDown(250);
112	}        
113    })
114    tbjQuery("div.dropoff_wrap div.nonstop_wrap div.poi_dropdown_wrapper div.poi_link").click(function(){
115        tbjQuery('#address_to').val(tbjQuery(this).children('span').html());
116        tbjQuery('#address_to_lat').val(tbjQuery(this).data('poilat'));
117	tbjQuery('#address_to_lng').val(tbjQuery(this).data('poilng'));
118        tbjQuery("div.dropoff_wrap div.poi_dropdown_wrapper").hide();
119        tbjQuery('div.dropoff_wrap div.nonstop_wrap .poi_options_trigger').removeClass('Open');
120	
121        // first unset route options
122        tbjQuery.fn.unsetRoute();
123        tbjQuery.fn.unsetHourlyHire();
124        tbjQuery.fn.getExtras('dropoff');
125        
126        // set booking type
127        tbjQuery('#booking_type').val('address');
128    })
129    
130    // waypoint
131    tbjQuery("div.dropoff_wrap div.stops_wrap .poi_options_trigger").click(function(){
132	if(tbjQuery(this).hasClass('Open') == true){
133	    tbjQuery(this).removeClass("Open");
134	}
135	else {
136	    tbjQuery(this).addClass("Open");
137	}
138	if (tbjQuery(this).next('.poi_dropdown_wrapper').is(":visible") == true){
139	    tbjQuery(this).next('.poi_dropdown_wrapper').slideUp(250);
140	}
141	else {
142	    tbjQuery(this).next('.poi_dropdown_wrapper').slideDown(250);
143	}        
144    })
145    tbjQuery("div.dropoff_wrap div.stops_wrap div.poi_dropdown_wrapper div.poi_link").click(function(){
146	tbjQuery(this).closest('div.stops_wrap').find('.waypoints').val(tbjQuery(this).children('span').html());
147	tbjQuery(this).closest('div.stops_wrap').find('#waypoint_lat').val(tbjQuery(this).data('poilat'));
148	tbjQuery(this).closest('div.stops_wrap').find('#waypoint_lng').val(tbjQuery(this).data('poilng'));
149	tbjQuery(this).closest('div.stops_wrap').find("div.poi_dropdown_wrapper").hide();
150	tbjQuery(this).closest('div.stops_wrap').find('.poi_options_trigger').removeClass('Open');
151    })
152    tbjQuery('div.dropoff_wrap').on('click', '.remove_stops', function() { // code
153	tbjQuery(this).closest('div.stops_wrap').remove();
154    });
155    
156    // show dropdown div of route category if show_poi_category is enabled
157    if(tbjQuery('#show_poi_categories').val()==1)
158    {
159	// collect pickup route for this selected category
160	tbjQuery.fn.collectRouteFrom = function() {
161	    if(tbjQuery('#route_category').val() > 0)
162	    {
163		tbjQuery.ajax({
164		    type: "POST",
165		    url: 'index.php?option=com_taxibooking&task=getRouteList',
166		    data: tbjQuery('#price_form').serialize(),
167		    dataType: 'json',
168		    async: false,
169		    beforeSend: function(){
170			tbjQuery('div.routes_wrapper_from div#routefrom_loader').html(tbjQuery('#route_loader').html());
171			tbjQuery('div.routes_wrapper_to').hide();
172			tbjQuery('div#routefrom_extra_wrapper').html('');   
173			tbjQuery('div#routeto_extra_wrapper').html('');
174			
175			tbjQuery('#route_category_dropoff_fld').val('');
176			tbjQuery('#route_category_dropoff').val(0);
177		    },
178		    complete: function(){
179			
180		    },
181		    success: function(response){
182			
183			//tbjQuery('#route_to_wrap').html(response.msg);
184			tbjQuery('div.routes_wrapper_from div#routefrom_loader').html('');
185			tbjQuery('div.routes_wrapper_from').show();
186			tbjQuery('div.routes_wrapper_from div.routes_from_inner').show();
187			tbjQuery('div.routefrom_dropdown_wrapper').html(response.route_options_html);
188			
189			tbjQuery("#route_from_fld").autocomplete({
190			    source: response.route_poi_data,		
191			    minLength: 2,
192			    open: function( event, ui ) {
193				tbjQuery('div.routes_wrapper div.routefrom_dropdown_wrapper').hide();
194			    },
195			    select: function(event, ui) {
196				tbjQuery('#route_from').val(ui.item.id);
197				tbjQuery('#route_from_fld').val(ui.item.value);
198				
199				tbjQuery.fn.getExtras('route_pickup');
200				
201				// set booking type
202				tbjQuery('#booking_type').val('offers');
203			    }
204			})
205			
206			var mouseOverRouteFrom = false;
207			tbjQuery('div.routes_wrapper .routefrom_options_trigger').mouseenter(function(){
208			    mouseOverRouteFrom = true; 
209			}).mouseleave(function(){ 
210			    mouseOverRouteFrom = false; 
211			})
212			
213			tbjQuery("html").click(function(){
214			    if (!mouseOverRouteFrom) {
215				tbjQuery('div.routes_wrapper div.routefrom_dropdown_wrapper').hide();
216			    }
217			});
218		    }
219		})
220	    }
221	    else {
222		tbjQuery('div#routefrom_extra_wrapper').html('');   
223		tbjQuery('div#routeto_extra_wrapper').html('');
224		
225		tbjQuery('div.routes_wrapper_to').hide();
226	    }
227	}
228	
229	var mouseOverRouteCategory = false;
230	tbjQuery('div.routecategory_wrapper_from .routecategory_options_trigger').mouseenter(function(){
231	    mouseOverRouteCategory = true; 
232	}).mouseleave(function(){ 
233	    mouseOverRouteCategory = false; 
234	})
235	
236	tbjQuery("html").click(function(){
237	    if (!mouseOverRouteCategory) {
238		tbjQuery('div.routecategory_wrapper_from div.routecategory_dropdown_wrapper').hide();
239	    }
240	});
241	
242	tbjQuery("div.routecategory_wrapper_from .routecategory_options_trigger").click(function(){
243	    if(tbjQuery(this).hasClass('Open') == true){
244		tbjQuery(this).removeClass("Open");
245	    }
246	    else {
247		tbjQuery(this).addClass("Open");
248	    }
249	    if (tbjQuery(this).prev('.routecategory_dropdown_wrapper').is(":visible") == true){
250		tbjQuery(this).prev('.routecategory_dropdown_wrapper').slideUp(250);
251	    }
252	    else {
253		tbjQuery(this).prev('.routecategory_dropdown_wrapper').slideDown(250);
254	    }        
255	})
256	tbjQuery("div.routecategory_wrapper_from div.routecategory_dropdown_wrapper div.poi_link").click(function(){
257	    
258	    // unset routes
259	    tbjQuery('#route_category_dropoff').val(0);
260	    tbjQuery('#route_category_dropoff_fld').val('');
261	    tbjQuery('#route_from').val(0);
262	    tbjQuery('#route_from_fld').val('');
263	    tbjQuery('#route_to').val(0);
264	    tbjQuery('#route_to_fld').val('');
265	    
266	    tbjQuery('div#routefrom_extra_wrapper').html('');
267	    tbjQuery('div#routeto_extra_wrapper').html('');
268	    
269	    tbjQuery('#route_category').val(tbjQuery(this).attr('id'));
270	    tbjQuery('#route_category_fld').val(tbjQuery(this).children('span').html());
271	    tbjQuery('div.routecategory_wrapper_from div.routecategory_dropdown_wrapper').hide();
272	    tbjQuery('div.routecategory_wrapper_from .routecategory_options_trigger').removeClass('Open');
273	    
274	    // unset all the poi/address selection below
275	    tbjQuery.fn.unsetPoiAddress();
276	    tbjQuery.fn.unsetHourlyHire();
277	    
278	    tbjQuery.fn.collectRouteFrom();
279	    
280	    // set booking type
281	    tbjQuery('#booking_type').val('offers');
282	})
283    }
284    
285    tbjQuery("div.routes_wrapper .routefrom_options_trigger").live('click', function(){
286	if(tbjQuery(this).hasClass('Open') == true){
287	    tbjQuery(this).removeClass("Open");
288	}
289	else {
290	    tbjQuery(this).addClass("Open");
291	}
292	if (tbjQuery(this).prev('.routefrom_dropdown_wrapper').is(":visible") == true){
293	    tbjQuery(this).prev('.routefrom_dropdown_wrapper').slideUp(250);
294	}
295	else {
296	    tbjQuery(this).prev('.routefrom_dropdown_wrapper').slideDown(250);
297	}        
298    })
299    tbjQuery("div.routes_wrapper div.routefrom_dropdown_wrapper div.poi_link").live('click', function(){
300	tbjQuery('#route_from').val(tbjQuery(this).attr('id'));
301	tbjQuery('#route_from_fld').val(tbjQuery(this).children('span').html());
302	tbjQuery('div.routes_wrapper div.routefrom_dropdown_wrapper').hide();
303	tbjQuery('div.routes_wrapper .routefrom_options_trigger').removeClass('Open');
304	
305	// unset all the poi/address selection below
306	tbjQuery.fn.unsetPoiAddress();
307	tbjQuery.fn.unsetHourlyHire();
308	tbjQuery.fn.getExtras('route_pickup');
309	
310	// if show_route_category enabled, collect dropoff route category
311	if(tbjQuery('#show_poi_categories').val()==1) {
312	    tbjQuery.fn.collectDropoffRouteCategory();
313	}
314	else { // if show_route_category disabled, collect dropoff routes list
315	    tbjQuery.fn.collectRouteTo();
316	}
317	
318	// set booking type
319	tbjQuery('#booking_type').val('offers');
320    })
321    
322    // show dropdown div of route from initially if show_poi_category is disabled
323    if(tbjQuery('#show_poi_categories').val()==0)
324    {
325	var mouseOverRouteFrom = false;
326	tbjQuery('div.routes_wrapper .routefrom_options_trigger').mouseenter(function(){
327	    mouseOverRouteFrom = true; 
328	}).mouseleave(function(){ 
329	    mouseOverRouteFrom = false; 
330	})
331    }
332    
333    tbjQuery.fn.collectDropoffRouteCategory = function() {
334        if(tbjQuery('#route_from').val() > 0) {
335            tbjQuery.ajax({
336                type: "POST",
337                url: 'index.php?option=com_taxibooking&task=getRouteCategory',
338                data: tbjQuery('#price_form').serialize(),
339                dataType: 'json',
340                async: false,
341                beforeSend: function(){
342                    tbjQuery('div.routes_wrapper_to').hide();
343                    
344                    // unset all the poi/address selection below
345                    tbjQuery.fn.unsetPoiAddress();
346                    tbjQuery.fn.unsetHourlyHire();
347                },
348                complete: function(){
349                    
350                },
351                success: function(response){
352                    
353                    tbjQuery('div.routes_indicator').show();
354		    tbjQuery('div.routes_wrapper_to').show();
355                    tbjQuery('div.routecategory_dropoff_dropdown_wrapper').html(response.route_categories_html);
356                    
357                    tbjQuery("#route_category_dropoff_fld").autocomplete({
358                        source: response.route_categories_data,		
359                        minLength: 2,
360                        open: function( event, ui ) {
361                            tbjQuery('div.routes_wrapper div.routeto_dropdown_wrapper').hide();
362                        },
363                        select: function(event, ui) {
364                            tbjQuery('#route_category_dropoff').val(ui.item.id);
365                            tbjQuery('#route_category_dropoff_fld').val(ui.item.value);
366                            
367                            // unset all the poi/address selection below
368                            tbjQuery.fn.unsetPoiAddress();
369                            tbjQuery.fn.unsetHourlyHire();
370                            tbjQuery.fn.collectRouteTo();
371                            
372                            // set booking type
373                            tbjQuery('#booking_type').val('offers');
374                        }
375                    })
376                    
377                    // show dropdown div of route from
378                    var mouseOverRouteTo = false;
379                    tbjQuery('div.routes_wrapper .routeto_options_trigger').mouseenter(function(){
380                        mouseOverRouteTo = true; 
381                    }).mouseleave(function(){ 
382                        mouseOverRouteTo = false; 
383                    })
384                    
385                    tbjQuery("html").click(function(){
386                        if (!mouseOverRouteTo) {
387                            tbjQuery('div.routes_wrapper div.routeto_dropdown_wrapper').hide();
388                        }
389                    });
390		    
391		    var mouseOverRouteCategoryDropoff = false;
392		    tbjQuery('div.routecategory_dropoff_options_trigger').mouseenter(function(){
393			mouseOverRouteCategoryDropoff = true; 
394		    }).mouseleave(function(){ 
395			mouseOverRouteCategoryDropoff = false; 
396		    })
397		    
398		    tbjQuery("html").click(function(){
399			if (!mouseOverRouteCategoryDropoff) {
400			    tbjQuery('div.routecategory_dropoff_dropdown_wrapper').hide();
401			}
402		    });
403                }
404            })
405        }
406        else {
407            tbjQuery('div.routes_wrapper_to').hide();
408        }
409    }
410    
411    tbjQuery("div.routecategory_dropoff_options_trigger").live('click', function(){
412	if(tbjQuery(this).hasClass('Open') == true){
413	    tbjQuery(this).removeClass("Open");
414	}
415	else {
416	    tbjQuery(this).addClass("Open");
417	}
418	if (tbjQuery(this).prev('div.routecategory_dropoff_dropdown_wrapper').is(":visible") == true){
419	    tbjQuery(this).prev('div.routecategory_dropoff_dropdown_wrapper').slideUp(250);
420	}
421	else {
422	    tbjQuery(this).prev('div.routecategory_dropoff_dropdown_wrapper').slideDown(250);
423	}        
424    })
425    tbjQuery("div.routecategory_dropoff_dropdown_wrapper div.poi_link").live('click', function(){
426	
427	// unset routes
428	tbjQuery('#route_to').val(0);
429	tbjQuery('#route_to_fld').val('');
430	
431	tbjQuery('div#routeto_extra_wrapper').html('');
432	
433	tbjQuery('#route_category_dropoff').val(tbjQuery(this).attr('id'));
434	tbjQuery('#route_category_dropoff_fld').val(tbjQuery(this).children('span').html());
435	tbjQuery('div.routecategory_dropoff_dropdown_wrapper').hide();
436	tbjQuery('div.routecategory_dropoff_options_trigger').removeClass('Open');
437	
438	// unset all the poi/address selection below
439	tbjQuery.fn.unsetPoiAddress();
440	tbjQuery.fn.unsetHourlyHire();
441	
442	tbjQuery.fn.collectRouteTo();
443	
444	// set booking type
445	tbjQuery('#booking_type').val('offers');
446    })
447    
448    tbjQuery.fn.collectRouteTo = function() {
449        if(tbjQuery('#route_from').val() > 0) {
450            tbjQuery.ajax({
451                type: "POST",
452                url: 'index.php?option=com_taxibooking&task=getRouteList',
453                data: tbjQuery('#price_form').serialize(),
454                dataType: 'json',
455                async: false,
456                beforeSend: function(){
457                    
458		    tbjQuery('div.routes_wrapper_to div#routefrom_loader').html(tbjQuery('#route_loader').html());
459		    
460                    // unset route to
461                    tbjQuery('#route_to').val(0);
462                    tbjQuery('#route_to_fld').val('');
463                    
464                    tbjQuery('div#routeto_extra_wrapper').html('');
465                    // unset all the poi/address selection below
466                    tbjQuery.fn.unsetPoiAddress();
467                    tbjQuery.fn.unsetHourlyHire();
468                },
469                complete: function(){
470                    
471                },
472                success: function(response){
473                    tbjQuery('div.routes_wrapper_to div#routefrom_loader').html('');
474		    
475                    tbjQuery('div.routes_indicator').show();
476		    tbjQuery('div.routes_wrapper_to').show();
477		    tbjQuery('div.routes_wrapper_to div.routes_to_inner').show();
478                    tbjQuery('div.routeto_dropdown_wrapper').html(response.route_options_html);
479                    
480                    tbjQuery("#route_to_fld").autocomplete({
481                        source: response.route_poi_data,		
482                        minLength: 2,
483                        open: function( event, ui ) {
484                            tbjQuery('div.routes_wrapper div.routeto_dropdown_wrapper').hide();
485                        },
486                        select: function(event, ui) {
487                            tbjQuery('#route_to').val(ui.item.id);
488                            tbjQuery('#route_to_fld').val(ui.item.value);
489                            
490                            // unset all the poi/address selection below
491                            tbjQuery.fn.unsetPoiAddress();
492                            tbjQuery.fn.unsetHourlyHire();
493                            tbjQuery.fn.getExtras('route_dropoff');
494                            
495                            // set booking type
496                            tbjQuery('#booking_type').val('offers');
497                        }
498                    })
499                    
500                    
501                    // show dropdown div of route from
502                    var mouseOverRouteTo = false;
503                    tbjQuery('div.routes_wrapper .routeto_options_trigger').mouseenter(function(){
504                        mouseOverRouteTo = true; 
505                    }).mouseleave(function(){ 
506                        mouseOverRouteTo = false; 
507                    })
508                    
509                    tbjQuery("html").click(function(){
510                        if (!mouseOverRouteTo) {
511                            tbjQuery('div.routes_wrapper div.routeto_dropdown_wrapper').hide();
512                        }
513                    });
514                }
515            })
516        }
517        else {
518            tbjQuery('div.routes_wrapper_to').hide();
519            //tbjQuery('#route_to_wrap').html('');
520            tbjQuery('div#routefrom_extra_wrapper').html('');   
521            tbjQuery('div#routeto_extra_wrapper').html('');
522        }
523    }
524    
525    tbjQuery("div.routes_wrapper .routeto_options_trigger").live('click', function(){
526	if(tbjQuery(this).hasClass('Open') == true){
527	    tbjQuery(this).removeClass("Open");
528	}
529	else {
530	    tbjQuery(this).addClass("Open");
531	}
532	if (tbjQuery(this).prev('.routeto_dropdown_wrapper').is(":visible") == true){
533	    tbjQuery(this).prev('.routeto_dropdown_wrapper').slideUp(250);
534	}
535	else {
536	    tbjQuery(this).prev('.routeto_dropdown_wrapper').slideDown(250);
537	}        
538    })
539    tbjQuery("div.routes_wrapper div.routeto_dropdown_wrapper div.poi_link").live('click', function(){
540        tbjQuery('#route_to').val(tbjQuery(this).attr('id'));
541        tbjQuery('#route_to_fld').val(tbjQuery(this).children('span').html());
542        tbjQuery('div.routes_wrapper div.routeto_dropdown_wrapper').hide();
543	tbjQuery('div.routes_wrapper .routeto_options_trigger').removeClass('Open');
544        
545        // unset all the poi/address selection below
546        tbjQuery.fn.unsetPoiAddress();
547        tbjQuery.fn.unsetHourlyHire();
548        tbjQuery.fn.getExtras('route_dropoff');
549        
550        // set booking type
551        tbjQuery('#booking_type').val('offers');
552    })
553    
554    /*tbjQuery('#route_to').live('change', function(){
555        tbjQuery.fn.getExtras('route_dropoff');
556    })*/
557
558    // swap route with extras
559    tbjQuery.fn.swapRoute = function() {
560        
561        var pickup_route_selected = tbjQuery('#route_from').val();
562        var dropoff_route_selected = tbjQuery('#route_to').val();
563        
564        if(pickup_route_selected==0 || dropoff_route_selected==0){
565            alert('Please choose both routes!');
566            return false;
567        }
568        var pickup_route_html = tbjQuery('#route_from_fld').val();
569        var dropoff_route_html = tbjQuery('#route_to_fld').val();
570        
571        tbjQuery('#route_from_fld').val(dropoff_route_html);
572        tbjQuery('#route_to_fld').val(pickup_route_html);
573        
574        tbjQuery('#route_from').val(dropoff_route_selected);
575        tbjQuery('#route_to').val(pickup_route_selected);
576        
577        return true;
578    }
579    
580    tbjQuery('a.swap_routes').click(function(){
581        
582        var route_swapped = tbjQuery('#route_swapped').val();
583        if(route_swapped==1){ // routes are already swapped, so normalize them
584            
585	    tbjQuery('#route_category_fld').attr('readonly', false);
586	    tbjQuery('#route_category_dropoff_fld').attr('readonly', false);
587	    tbjQuery('#route_from_fld').attr('readonly', false);
588            tbjQuery('#route_to_fld').attr('readonly', false);
589            
590            if(tbjQuery.fn.swapRoute()){
591                tbjQuery('#route_swapped').val(0);
592                tbjQuery("div.routecategory_options_trigger, div.routecategory_dropoff_options_trigger, div.routefrom_options_trigger, div.routeto_options_trigger").show();
593                tbjQuery.fn.getSwappedRouteExtras();
594		tbjQuery.fn.getReturnExtras();
595            }
596        }
597        else {
598            if(tbjQuery.fn.swapRoute()){
599                tbjQuery('#route_swapped').val(1);
600		tbjQuery('#route_category_fld').attr('readonly', true);
601		tbjQuery('#route_category_dropoff_fld').attr('readonly', true);
602                tbjQuery('#route_from_fld').attr('readonly', true);
603                tbjQuery('#route_to_fld').attr('readonly', true);
604                
605                tbjQuery("div.routecategory_options_trigger, div.routecategory_dropoff_options_trigger, div.routefrom_options_trigger, div.routeto_options_trigger").hide();
606                tbjQuery.fn.getSwappedRouteExtras();
607		tbjQuery.fn.getReturnExtras();
608            }
609        }
610    });
611    
612        
613    tbjQuery('#hourly_hr').selectbox({
614	    onOpen: function (inst) {
615		    //console.log("open", inst);
616	    },
617	    onClose: function (inst) {
618		    //console.log("close", inst);
619	    },
620	    onChange: function (val, inst) {
621		tbjQuery('#hourly_hr').selectbox('close');
622		tbjQuery('#booking_type').val('hourly');
623		tbjQuery.fn.unsetPoiAddress();
624		tbjQuery.fn.unsetRoute();
625		tbjQuery.fn.getExtras('hourly_hire');
626	    }
627    });
628    
629    tbjQuery(".see_price").click(function() {
630	var booking_type = tbjQuery('#booking_type').val();
631	
632        // first validate the required field
633        var err = 0;
634	
635	// address field validation if user choose address radio
636	if(booking_type=='address')
637	{
638	    if(tbjQuery('[name="from_dest"]:checked').val()==1)
639	    {
640		var address_from_lat = tbjQuery('#address_from_lat').val();
641		var address_from_lng = tbjQuery('#address_from_lng').val();
642		
643		if(address_from_lat=="" || address_from_lng==""){
644		    err = err+1;
645		    tbjQuery("#address_from").addClass('incorrect');
646		}
647		else {
648		    tbjQuery("#address_from").removeClass('incorrect');
649		}
650	    }
651	    if(tbjQuery('[name="to_dest"]:checked').val()==1)
652	    {
653		var address_to_lat = tbjQuery('#address_to_lat').val();
654		var address_to_lng = tbjQuery('#address_to_lng').val();
655		
656		if(address_to_lat=="" || address_to_lng==""){
657		    err = err+1;
658		    tbjQuery("#address_to").addClass('incorrect');
659		}
660		else {
661		    tbjQuery("#address_to").removeClass('incorrect');
662		}
663	    }
664	}
665	
666	// other required field validation
667	if(tbjQuery('#passengers').val()=="0"){
668	    err = err+1;
669	    tbjQuery('#passengers').next("div.sbHolder").addClass('required incorrect');
670	}
671	else {
672	    tbjQuery('#passengers').next("div.sbHolder").removeClass('required incorrect');
673	}
674	
675	if(tbjQuery('#hourly_hr').hasClass('required')){
676	    if(tbjQuery('#hourly_hr').val()=="0"){
677		err = err+1;
678		tbjQuery('#hourly_hr').next("div.sbHolder").addClass('required incorrect');
679	    }
680	    else {
681		tbjQuery('#hourly_hr').next("div.sbHolder").removeClass('required incorrect');
682	    }
683	}
684	
685        tbjQuery('.required').each(function(){
686            if(tbjQuery(this).is(":visible") == true && (tbjQuery(this).val()=="" || tbjQuery(this).val()=="0" || tbjQuery(this).val()=="Date")){
687                err = err+1;
688                tbjQuery(this).addClass('incorrect');
689            }
690	    else {
691                tbjQuery(this).removeClass('incorrect');
692	    }
693        })
694	
695        if(err>0){
696	    tbjQuery('html, body').animate({ scrollTop: tbjQuery('#verticle_booking_wrap').offset().top }, 'fast');
697        }
698	else {
699	    document.price_form.submit();
700	}
701    });
702        
703    
704    // hide all the dropdown if clicked outside of the arrow
705    tbjQuery("html").click(function(){
706        if (!mouseOverRouteFrom) {
707            tbjQuery('div.routes_wrapper div.routefrom_dropdown_wrapper').hide();
708        }
709        if (!mouseOverPoi1) {
710            tbjQuery('div.pickup_selectwrapper div.poi_dropdown_wrapper').hide();
711        }
712        if (!mouseOverPoi2) {
713            tbjQuery("div.dropoff_selectwrapper div.poi_dropdown_wrapper").hide();
714        }
715    });
716    
717    // collect extra list
718    tbjQuery.fn.getExtras = function(type) {
719        
720        // if there is a previous ajax search, then we abort it and then set xhr to null
721        if( xhr != null ) {
722            xhr.abort();
723            xhr = null;
724        }
725        var passingData = tbjQuery('#price_form').serialize()+'&type='+type;
726        
727        xhr = tbjQuery.ajax({
728                type: "POST",
729                url: 'index.php?option=com_taxibooking&controller=onepage&task=getExtraList',
730                data: passingData,
731                dataType: 'json',
732                async: false,
733                beforeSend: function(){
734                    // load the ajax loading image
735                    if(type=='pickup' || type=='address_pickup'){
736			tbjQuery('div#pickup_extra_wrapper').html(tbjQuery('#route_loader').html());   
737		    }
738		    else if(type=='dropoff' || type=='address_dropoff'){
739			tbjQuery('div#dropoff_extra_wrapper').html(tbjQuery('#route_loader').html());
740		    }
741		    else if(type=='route_pickup'){
742			tbjQuery('div#routefrom_extra_wrapper').html(tbjQuery('#route_loader').html());   
743		    }
744		    else if(type=='route_dropoff'){
745			tbjQuery('div#routeto_extra_wrapper').html(tbjQuery('#route_loader').html());
746		    }
747		    else if(type=='hourly_hire'){
748			tbjQuery('div#hourly_extra_wrapper').html(tbjQuery('#route_loader').html());
749		    }
750                },
751                complete: function(){
752                },
753                success: function(response){
754                    // clear out the ajax loading image
755                    tbjQuery('#route_loader').hide();
756                    
757                    if(response.error==0)
758                    {
759                        if(type=='pickup' || type=='address_pickup'){
760                            tbjQuery('div#pickup_extra_wrapper').html(response.msg);   
761                        }
762                        else if(type=='dropoff' || type=='address_dropoff'){
763                            tbjQuery('div#dropoff_extra_wrapper').html(response.msg);
764                        }
765                        else if(type=='route_pickup'){
766                            tbjQuery('div#routefrom_extra_wrapper').html(response.msg);   
767                        }
768                        else if(type=='route_dropoff'){
769                            tbjQuery('div#routeto_extra_wrapper').html(response.msg);
770                        }
771			else if(type=='hourly_hire'){
772                            tbjQuery('div#hourly_extra_wrapper').html(response.msg);
773                        }
774                        
775                        // show car description in tooltips
776                        tbjQuery( 'a.field_desc' ).tooltip({
777                            track: true
778                        });
779			
780			tbjQuery(".seat_options").selectbox();
781                    }
782                }
783        });
784    }
785    
786    // This function collects extras fir swapped routes
787    tbjQuery.fn.getSwappedRouteExtras = function(type) {
788        
789        // if there is a previous ajax search, then we abort it and then set xhr to null
790        if( xhr != null ) {
791            xhr.abort();
792            xhr = null;
793        }
794        var passingData = tbjQuery('#price_form').serialize();
795        
796        xhr = tbjQuery.ajax({
797                type: "POST",
798                url: 'index.php?option=com_taxibooking&task=getSwappedExtraList',
799                data: passingData,
800                dataType: 'json',
801                async: false,
802                beforeSend: function(){
803                    // load the ajax loading image
804                    tbjQuery('#route_loader').show();
805                    
806                    tbjQuery('div#routefrom_extra_wrapper').html('');
807                    tbjQuery('div#routeto_extra_wrapper').html('');
808                },
809                complete: function(){
810                },
811                success: function(response){
812                    // clear out the ajax loading image
813                    tbjQuery('#route_loader').hide();
814                    
815                    if(response.error==0)
816                    {
817                        tbjQuery('div#routefrom_extra_wrapper').html(response.pickupextra);   
818                        tbjQuery('div#routeto_extra_wrapper').html(response.dropoffextra);
819                        
820                        // show car description in tooltips
821                        tbjQuery( 'a.field_desc' ).tooltip({
822                            track: true
823                        });
824			
825			tbjQuery(".seat_options").selectbox();
826                    }
827                }
828        });
829    }
830    
831    tbjQuery.fn.getReturnExtras = function() {
832	
833	if(tbjQuery('#returnjurney').is(':checked') && tbjQuery('#show_return_extras').val()==1){
834	    tbjQuery.ajax({
835                type: "POST",
836		    url: 'index.php?option=com_taxibooking&controller=onepage&task=getReturnExtraList',
837		    data: tbjQuery('#price_form').serialize(),
838		    dataType: 'json',
839		    async: false,
840		    beforeSend: function(){
841			// load the ajax loading image
842			tbjQuery('div#return_extra_wrapper').show().html(tbjQuery('#route_loader').html());
843		    },
844		    complete: function(){
845		    },
846		    success: function(response){
847			// clear out the ajax loading image
848			tbjQuery('#route_loader').hide();
849			
850			if(response.error==0)
851			{
852			    tbjQuery('div#return_extra_wrapper').show().html(response.msg);   
853			    
854			    // show car description in tooltips
855			    tbjQuery( 'a.field_desc' ).tooltip({
856				track: true
857			    });
858			    
859			    tbjQuery(".seat_options").selectbox();
860			}
861		    }
862	    });
863	}
864	else {
865	    return false;
866	}
867    }
868    
869    // order date picker for jquery datepicker
870    if(tbjQuery('#datepicker_type').val()=='jquery')
871    {
872	var locale = tbjQuery('#locale').val();
873	tbjQuery.datepicker.setDefaults( tbjQuery.datepicker.regional[ locale ] );
874	tbjQuery( "#orderdatereturn" ).datepicker({
875	    dateFormat: tbjQuery('#date_format').val(),
876	    minDate: new Date(),
877	    onSelect: function(dateText, inst){
878		if(!tbjQuery.fn.compareDate()) {
879		    if(tbjQuery("#selPtHr1").val() >= tbjQuery("#selPtHr2").val()) {
880			tbjQuery("#selPtHr2").val('');
881		    }
882		}
883	    }
884	})
885	if(tbjQuery( "#orderdate" ).val()!=""&&tbjQuery( "#orderdate" ).val()!="Date") {
886	    var dateText = tbjQuery( "#orderdate" ).val();
887	    if(tbjQuery('#date_format').val()=='dd-mm-yy'){
888		var order_date_day = dateText.substring(0, 2);
889		var order_date_month = dateText.substring(3, 5);
890	    }
891	    else {
892		var order_date_month = dateText.substring(0, 2);
893		var order_date_day  = dateText.substring(3, 5);
894	    }
895	    
896	    var order_date_year = dateText.substring(6, 10);
897	    tbjQuery( "#orderdatereturn" ).datepicker( "option", "minDate", new Date(order_date_year, parseInt(order_date_month)-1, order_date_day) );
898	}
899	tbjQuery( "#orderdate" ).datepicker({
900	    dateFormat: tbjQuery('#date_format').val(),
901	    minDate: new Date(),
902	    onSelect: function(dateText, inst){
903		if(tbjQuery('#date_format').val()=='dd-mm-yy'){
904		    var order_date_day = dateText.substring(0, 2);
905		    var order_date_month = dateText.substring(3, 5);
906		}
907		else {
908		    var order_date_month = dateText.substring(0, 2);
909		    var order_date_day  = dateText.substring(3, 5);
910		}
911		
912		var order_date_year = dateText.substring(6, 10);
913		tbjQuery( "#orderdatereturn" ).datepicker( "option", "minDate", new Date(order_date_year, parseInt(order_date_month)-1, order_date_day) ).val('Return Date');
914	    }
915	})
916    }
917    
918    // Inline date functions
919    tbjQuery.fn.attachPluginPickupMonth = function(){
920	tbjQuery("#pickup_month").selectbox({
921	    classHolder: "sbHolder dateinline",
922	    onChange: function (val, inst) {
923		    var return_year = parseInt(tbjQuery('#return_year').val());
924		    var order_date_year = parseInt(tbjQuery('#pickup_year').val());
925		    
926		    tbjQuery.fn.setPickupDate();
927		    
928		    if(return_year > order_date_year){
929			tbjQuery.fn.resetReturnMonth();
930			tbjQuery.fn.resetReturnDay();
931		    }
932		    else {
933			tbjQuery.fn.setReturnMonth();
934			tbjQuery.fn.setReturnDay();
935		    }
936	    }
937	}).selectbox('attach');
938    }
939    tbjQuery.fn.attachPluginPickupDay = function(){
940	tbjQuery("#pickup_day").selectbox({
941	    classHolder: "sbHolder dateinline",
942	    onChange: function (val, inst) {
943		    var order_date_month = parseInt(tbjQuery('#pickup_month').val());
944		    var return_month = parseInt(tbjQuery('#return_month').val());
945		    
946		    tbjQuery.fn.setPickupDate();
947		    if(return_month > order_date_month){
948			tbjQuery.fn.resetReturnDay();
949		    }
950		    else {
951			tbjQuery.fn.setReturnDay();
952		    }
953	    }
954	}).selectbox('attach');
955    }
956    tbjQuery.fn.attachPluginReturnYear = function(){
957	tbjQuery("#return_year").selectbox({
958	    classHolder: "sbHolder dateinline",
959	    onChange: function (val, inst) {
960		    var return_year = parseInt(tbjQuery("#return_year").val());
961		    var order_date_year = parseInt(tbjQuery('#pickup_year').val());
962		    
963		    if(return_year > order_date_year){
964			tbjQuery.fn.resetReturnMonth();
965			tbjQuery.fn.resetReturnDay();
966		    }
967		    else {
968			tbjQuery.fn.setReturnMonth();
969			tbjQuery.fn.setReturnDay();
970		    }
971	    }
972	}).selectbox('attach');
973    }
974    tbjQuery.fn.attachPluginReturnMonth = function(){
975	tbjQuery("#return_month").selectbox({
976	    classHolder: "sbHolder dateinline",
977	    onChange: function (val, inst) {
978		    var return_month = parseInt(tbjQuery("#return_month").val());
979		    var order_date_month = parseInt(tbjQuery('#pickup_month').val());
980		    
981		    if(return_month > order_date_month){
982			tbjQuery.fn.resetReturnDay();
983		    }
984		    else {
985			tbjQuery.fn.setReturnDay();
986		    }
987	    }
988	}).selectbox('attach');
989    }
990    
991    tbjQuery.fn.setReturnYear = function() {
992        var pickup_year = tbjQuery('#pickup_year').val();
993	
994	tbjQuery('#return_year').selectbox('detach');
995        tbjQuery("#return_year option").each(function()
996        {
997            if(tbjQuery(this).val()<parseInt(pickup_year)){
998                tbjQuery(this).attr('disabled', true);
999            }
1000            else {
1001                tbjQuery(this).attr('disabled', false);
1002            }
1003        })
1004        tbjQuery('#return_year').val(pickup_year);
1005	tbjQuery.fn.attachPluginReturnYear();
1006    }
1007    
1008    tbjQuery.fn.setReturnMonth = function() {
1009        var pickup_month = tbjQuery('#pickup_month').val();
1010	
1011	tbjQuery('#return_month').selectbox('detach');
1012        tbjQuery("#return_month option").each(function()
1013        {
1014            if(tbjQuery(this).val()<parseInt(pickup_month)){
1015                tbjQuery(this).attr('disabled', true);
1016            }
1017            else {
1018                tbjQuery(this).attr('disabled', false);
1019            }
1020        })
1021        tbjQuery('#return_month').val(pickup_month);
1022	tbjQuery.fn.attachPluginReturnMonth();
1023    }
1024    
1025    tbjQuery.fn.resetReturnMonth = function() {
1026	tbjQuery('#return_month').selectbox('detach');
1027        tbjQuery("#return_month option").each(function()
1028        {
1029            tbjQuery(this).attr('disabled', false);
1030        })
1031        tbjQuery('#return_month').val(1);
1032	tbjQuery.fn.attachPluginReturnMonth();
1033    }
1034    
1035    tbjQuery.fn.setReturnDay = function() {
1036        var pickup_day = tbjQuery('#pickup_day').val();
1037	
1038	tbjQuery('#return_day').selectbox('detach');
1039        tbjQuery("#return_day option").each(function()
1040        {
1041            if(tbjQuery(this).val()<parseInt(pickup_day)){
1042                tbjQuery(this).attr('disabled', true);
1043            }
1044            else {
1045                tbjQuery(this).attr('disabled', false);
1046            }
1047        })
1048        tbjQuery('#return_day').val(pickup_day);
1049	tbjQuery('#return_day').selectbox({
1050	    classHolder: "sbHolder dateinline"
1051	}).selectbox('attach');
1052    }
1053    tbjQuery.fn.resetReturnDay = function() {
1054	tbjQuery('#return_day').selectbox('detach');
1055        tbjQuery("#return_day option").each(function()
1056        {
1057            tbjQuery(this).attr('disabled', false);
1058        })
1059        tbjQuery('#return_day').val(1);
1060	tbjQuery('#return_day').selectbox({
1061	    classHolder: "sbHolder dateinline"
1062	}).selectbox('attach');
1063    }
1064    
1065    tbjQuery.fn.setPickupDate = function() {
1066	var pickup_year = tbjQuery('#pickup_year').val();
1067        var pickup_month = tbjQuery('#pickup_month').val();
1068	var pickup_day = tbjQuery('#pickup_day').val();
1069	var currentDate = new Date();
1070        var day = currentDate.getDate();
1071        var month = currentDate.getMonth();
1072	var year = currentDate.getFullYear();
1073        
1074	// first detach the selectbox plugin
1075	tbjQuery('#pickup_month').selectbox('detach');
1076	tbjQuery('#pickup_day').selectbox('detach');
1077	
1078	if(pickup_year > year){
1079		
1080	    tbjQuery("#pickup_month option").each(function()
1081	    {
1082		tbjQuery(this).attr('disabled', false);
1083	    })
1084	    tbjQuery("#pickup_day option").each(function()
1085	    {
1086		tbjQuery(this).attr('disabled', false);
1087	    })
1088	}
1089	else {
1090	    tbjQuery("#pickup_month option").each(function()
1091	    {
1092		if(tbjQuery(this).val()<(parseInt(month)+1)){
1093		    tbjQuery(this).attr('disabled', true);
1094		}
1095		else {
1096		    tbjQuery(this).attr('disabled', false);
1097		}
1098	    })
1099	    
1100	    if(pickup_month > (parseInt(month)+1)){
1101		tbjQuery("#pickup_day option").each(function()
1102		{
1103		    tbjQuery(this).attr('disabled', false);
1104		})
1105	    }
1106	    else {
1107		tbjQuery("#pickup_day option").each(function()
1108		{
1109		    if(tbjQuery(this).val()<day){
1110			tbjQuery(this).attr('disabled', true);
1111		    }
1112		    else {
1113			tbjQuery(this).attr('disabled', false);
1114		    }
1115		})
1116	    }
1117	}
1118	
1119	// attach the selectbox plugin again
1120	tbjQuery.fn.attachPluginPickupMonth();
1121	tbjQuery.fn.attachPluginPickupDay();
1122    }
1123    
1124    tbjQuery.fn.setReturnDate = function() {
1125	var pickup_day = parseInt(tbjQuery('#pickup_day').val());
1126	var pickup_month = parseInt(tbjQuery('#pickup_month').val());
1127	var pickup_year = parseInt(tbjQuery('#pickup_year').val());
1128	
1129	var return_day = parseInt(tbjQuery('#return_day').val());
1130	var return_month = parseInt(tbjQuery('#return_month').val());
1131	var return_year = parseInt(tbjQuery('#return_year').val());
1132	
1133	tbjQuery('#return_year').selectbox('detach');
1134	tbjQuery('#return_month').selectbox('detach');
1135	tbjQuery('#return_day').selectbox('detach');
1136	
1137	tbjQuery("#return_year option").each(function()
1138	{
1139	    if(tbjQuery(this).val()<pickup_year){
1140		tbjQuery(this).attr('disabled', true);
1141	    }
1142	    else {
1143		tbjQuery(this).attr('disabled', false);
1144	    }
1145	})
1146	if(return_year > pickup_year){
1147	    
1148	    tbjQuery("#return_month option").each(function()
1149	    {
1150		tbjQuery(this).attr('disabled', false);
1151	    })
1152	    tbjQuery("#return_day option").each(function()
1153	    {
1154		tbjQuery(this).attr('disabled', false);
1155	    })
1156	}
1157	else {
1158	    tbjQuery("#return_month option").each(function()
1159	    {
1160		if(tbjQuery(this).val()<pickup_month){
1161		    tbjQuery(this).attr('disabled', true);
1162		}
1163		else {
1164		    tbjQuery(this).attr('disabled', false);
1165		}
1166	    })
1167	    if(return_month > pickup_month){
1168		tbjQuery("#return_day option").each(function()
1169		{
1170		    tbjQuery(this).attr('disabled', false);
1171		})
1172	    }
1173	    else {
1174		tbjQuery("#return_day option").each(function()
1175		{
1176		    if(tbjQuery(this).val()<pickup_day){
1177			tbjQuery(this).attr('disabled', true);
1178		    }
1179		    else {
1180			tbjQuery(this).attr('disabled', false);
1181		    }
1182		})
1183	    }
1184	}
1185	
1186	tbjQuery.fn.attachPluginReturnYear();
1187	tbjQuery.fn.attachPluginReturnMonth();
1188	
1189	tbjQuery('#return_day').selectbox({
1190		classHolder: "sbHolder dateinline"
1191	}).selectbox('attach');
1192    }
1193    
1194    tbjQuery.fn.hidePastDays = function(){
1195        var currentDate = new Date();
1196        var day = currentDate.getDate();
1197        var month = currentDate.getMonth();
1198        
1199	tbjQuery('#pickup_month').selectbox('detach');
1200	tbjQuery('#pickup_day').selectbox('detach');
1201	
1202        tbjQuery("#pickup_day option").each(function()
1203        {
1204            if(tbjQuery(this).val()<parseInt(day)){
1205                tbjQuery(this).attr('disabled', true);
1206            }
1207            else {
1208                tbjQuery(this).attr('disabled', false);
1209            }
1210        })
1211        tbjQuery("#pickup_month option").each(function()
1212        {
1213            if(tbjQuery(this).val()<(parseInt(month)+1)){
1214                tbjQuery(this).attr('disabled', true);
1215            }
1216            else {
1217                tbjQuery(this).attr('disabled', false);
1218            }
1219        })
1220	
1221	// attach the selectbox plugin again
1222	tbjQuery.fn.attachPluginPickupMonth();
1223	tbjQuery.fn.attachPluginPickupDay();
1224	
1225        if(tbjQuery('#returnjurney').is(':checked'))
1226        {
1227            var pickup_day = parseInt(tbjQuery('#pickup_day').val());
1228            var pickup_month = parseInt(tbjQuery('#pickup_month').val());
1229	    var pickup_year = parseInt(tbjQuery('#pickup_year').val());
1230	    
1231	    var return_day = parseInt(tbjQuery('#return_day').val());
1232            var return_month = parseInt(tbjQuery('#return_month').val());
1233	    var return_year = parseInt(tbjQuery('#return_year').val());
1234            
1235	    tbjQuery('#return_year').selectbox('detach');
1236	    tbjQuery('#return_month').selectbox('detach');
1237	    tbjQuery('#return_day').selectbox('detach');
1238	    
1239	    tbjQuery("#return_year option").each(function()
1240	    {
1241		if(tbjQuery(this).val()<pickup_year){
1242		    tbjQuery(this).attr('disabled', true);
1243		}
1244		else {
1245		    tbjQuery(this).attr('disabled', false);
1246		}
1247	    })
1248	    if(return_year > pickup_year){
1249		
1250		tbjQuery("#return_month option").each(function()
1251		{
1252		    tbjQuery(this).attr('disabled', false);
1253		})
1254		tbjQuery("#return_day option").each(function()
1255		{
1256		    tbjQuery(this).attr('disabled', false);
1257		})
1258	    }
1259	    else {
1260		tbjQuery("#return_month option").each(function()
1261		{
1262		    if(tbjQuery(this).val()<pickup_month){
1263			tbjQuery(this).attr('disabled', true);
1264		    }
1265		    else {
1266			tbjQuery(this).attr('disabled', false);
1267		    }
1268		})
1269		if(return_month > pickup_month){
1270		    tbjQuery("#return_day option").each(function()
1271		    {
1272			tbjQuery(this).attr('disabled', false);
1273		    })
1274		}
1275		else {
1276		    tbjQuery("#return_day option").each(function()
1277		    {
1278			if(tbjQuery(this).val()<pickup_day){
1279			    tbjQuery(this).attr('disabled', true);
1280			}
1281			else {
1282			    tbjQuery(this).attr('disabled', false);
1283			}
1284		    })
1285		}
1286	    }
1287	    
1288	    tbjQuery.fn.attachPluginReturnYear();
1289	    tbjQuery.fn.attachPluginReturnMonth();
1290	    
1291	    tbjQuery('#return_day').selectbox({
1292		    classHolder: "sbHolder dateinline"
1293	    }).selectbox('attach');
1294        }
1295    }
1296    
1297    if(tbjQuery('#datepicker_type').val()=='inline')
1298    {
1299	// pickup section
1300	tbjQuery("#pickup_year").selectbox({
1301	    classHolder: "sbHolder dateinline",
1302	    onChange: function (val, inst) {
1303		    tbjQuery.fn.setPickupDate();
1304		    tbjQuery.fn.setReturnYear();
1305		    
1306		    var pickup_year = parseInt(tbjQuery('#pickup_year').val());
1307		    var currentDate = new Date();
1308		    var day = currentDate.getDate();
1309		    var month = currentDate.getMonth();
1310		    var year = currentDate.getFullYear();
1311	
1312		    tbjQuery('#pickup_month').selectbox('detach');
1313		    tbjQuery('#pickup_day').selectbox('detach');
1314	
1315		    if(pickup_year > year){
1316			tbjQuery('#pickup_day').val(1);
1317			tbjQuery('#pickup_month').val(1);
1318		    }
1319		    else {
1320			tbjQuery('#pickup_day').val(day);
1321			tbjQuery('#pickup_month').val(month+1);
1322		    }
1323		    
1324		    tbjQuery.fn.attachPluginPickupMonth();
1325		    tbjQuery.fn.attachPluginPickupDay();
1326	    }
1327	});
1328	
1329	tbjQuery("#pickup_month").selectbox({
1330	    classHolder: "sbHolder dateinline",
1331	    onChange: function (val, inst) {
1332		    var return_year = parseInt(tbjQuery('#return_year').val());
1333		    var order_date_year = parseInt(tbjQuery('#pickup_year').val());
1334		    
1335		    tbjQuery.fn.setPickupDate();
1336		    
1337		    if(return_year > order_date_year){
1338			tbjQuery.fn.resetReturnMonth();
1339			tbjQuery.fn.resetReturnDay();
1340		    }
1341		    else {
1342			tbjQuery.fn.setReturnMonth();
1343			tbjQuery.fn.setReturnDay();
1344		    }
1345	    }
1346	});
1347	
1348	tbjQuery("#pickup_day").selectbox({
1349	    classHolder: "sbHolder dateinline",
1350	    onChange: function (val, inst) {
1351		    var order_date_month = parseInt(tbjQuery('#pickup_month').val());
1352		    var return_month = parseInt(tbjQuery('#return_month').val());
1353		    
1354		    tbjQuery.fn.setPickupDate();
1355		    if(return_month > order_date_month){
1356			tbjQuery.fn.resetReturnDay();
1357		    }
1358		    else {
1359			tbjQuery.fn.setReturnDay();
1360		    }
1361	    }
1362	});
1363	
1364	// return section
1365	tbjQuery("#return_year").selectbox({
1366	    classHolder: "sbHolder dateinline",
1367	    onChange: function (val, inst) {
1368		    var return_year = parseInt(tbjQuery("#return_year").val());
1369		    var order_date_year = parseInt(tbjQuery('#pickup_year').val());
1370		    
1371		    tbjQuery.fn.setReturnDate();
1372	    }
1373	});
1374	tbjQuery("#return_month").selectbox({
1375	    classHolder: "sbHolder dateinline",
1376	    onChange: function (val, inst) {
1377		    tbjQuery.fn.setReturnDate();
1378	    }
1379	});
1380	
1381	// hide all past dates
1382	tbjQuery.fn.hidePastDays();
1383    }
1384    
1385    tbjQuery("#return_wait_hr").selectbox({
1386	classHolder: "sbHolder medium",
1387	onChange: function (val, inst) {
1388	    if(val=='-1'){
1389		tbjQuery('div#return_datepicker_wrapper').show();
1390	    }
1391	    else{
1392		tbjQuery('div#return_datepicker_wrapper').hide();
1393		tbjQuery('#orderdatereturn').val('Return Date');
1394	    
1395		tbjQuery('#selPtHr2').selectbox('detach').val('').selectbox('attach');
1396		tbjQuery('#selPtMn2').selectbox('detach').val('').selectbox('attach');
1397	    }
1398	}
1399    });
1400    
1401    tbjQuery('#returnjurney').change(function(){
1402        if(tbjQuery(this).is(':checked'))
1403        {
1404	    if(tbjQuery('#datepicker_type').val()=='jquery')
1405	    {
1406		var orderdate = tbjQuery('#orderdate').val();
1407		if(orderdate=='' || orderdate=="Date")
1408		{
1409		    alert('Please select Departing Date first.');
1410		    tbjQuery(this).attr('checked', false);
1411		}
1412		else
1413		{
1414		    tbjQuery('div#return_date_wrapper').show();
1415		    
1416		    if(tbjQuery('#date_format').val()=='dd-mm-yy'){
1417			var order_date_day = orderdate.substring(0, 2);
1418			var order_date_month = orderdate.substring(3, 5);
1419		    }
1420		    else {
1421			var order_date_month = orderdate.substring(0, 2);
1422			var order_date_day = orderdate.substring(3, 5);
1423		    }
1424		    
1425		    var order_date_year = orderdate.substring(6, 10);
1426		    tbjQuery( "#orderdatereturn" ).datepicker( "option", "minDate", new Date(order_date_year, parseInt(order_date_month)-1, order_date_day) ).val('Return Date');
1427		}
1428	    }
1429	    else if(tbjQuery('#datepicker_type').val()=='inline')
1430	    {
1431		tbjQuery('div#return_date_wrapper').show();
1432		
1433		tbjQuery.fn.setReturnYear();
1434                tbjQuery.fn.setReturnMonth();
1435                tbjQuery.fn.setReturnDay();
1436	    }
1437	    
1438	    // collect return pickup and dropoff extras
1439	    if(tbjQuery('#show_return_extras').val()==1 && (tbjQuery('#booking_type').val()=='address' || tbjQuery('#booking_type').val()=='offers'))
1440	    {
1441		tbjQuery.fn.getReturnExtras();
1442	    }
1443        }
1444        else
1445        {
1446            tbjQuery('div#return_date_wrapper').hide();
1447            tbjQuery('#orderdatereturn').val('Return Date');
1448            tbjQuery('#selPtHr2').selectbox('detach').val('').selectbox('attach');
1449	    tbjQuery('#selPtMn2').selectbox('detach').val('').selectbox('attach');
1450            
1451	    // clear out the return extras
1452	    tbjQuery('div#return_extra_wrapper').html('').hide();
1453        }
1454    })
1455    
1456    // This function collects extras fir swapped routes
1457    tbjQuery.fn.compareDate = function() {
1458        
1459	if(tbjQuery('#datepicker_type').val()=='jquery')
1460	{
1461	    var order_date = tbjQuery('#orderdate').val();
1462	    var order_return_date = tbjQuery('#orderdatereturn').val();
1463	    
1464	    if(tbjQuery('#date_format').val()=='dd-mm-yy'){
1465		var order_date_day = order_date.substring(0, 2);
1466		var order_date_month = order_date.substring(3, 5);
1467	    }
1468	    else {
1469		var order_date_month = order_date.substring(0, 2);
1470		var order_date_day = order_date.substring(3, 5);
1471	    }
1472	    var order_date_year = order_date.substring(6, 10);
1473	    
1474	    if(tbjQuery('#date_format').val()=='dd-mm-yy'){
1475		var order_return_date_day = order_return_date.substring(0, 2);
1476		var order_return_date_month = order_return_date.substring(3, 5);
1477	    }
1478	    else {
1479		var order_return_date_month = order_return_date.substring(0, 2);
1480		var order_return_date_day = order_return_date.substring(3, 5);
1481	    }
1482	    
1483	    var order_return_date_year = order_return_date.substring(6, 10);
1484	}
1485	else if(tbjQuery('#datepicker_type').val()=='inline')
1486	{
1487	    var order_date_day = tbjQuery('#pickup_day').val();
1488	    var order_date_month = tbjQuery('#pickup_month').val();
1489	    var order_date_year = tbjQuery('#pickup_year').val();
1490	    
1491	    var order_return_date_day = tbjQuery('#return_day').val();
1492	    var order_return_date_month = tbjQuery('#return_month').val();
1493	    var order_return_date_year = tbjQuery('#return_year').val();
1494	}
1495	
1496        if(order_return_date_year>order_date_year) {
1497            return true;
1498        }
1499        else {
1500            if(order_return_date_month>order_date_month) {
1501                return true;
1502            }
1503            else {
1504                if(order_return_date_day>order_date_day) {
1505                    return true;
1506                }
1507                else {
1508                    return false;
1509                }
1510            }
1511        }
1512    }
1513    
1514    tbjQuery("#selPtHr2").selectbox({
1515	onChange: function (val, inst) {
1516	    if(!tbjQuery.fn.compareDate()) {
1517		if(tbjQuery("#selPtHr1").val() >= tbjQuery("#selPtHr2").val()) {
1518		    tbjQuery("#selPtHr2").val('');
1519		}
1520	    }
1521	}
1522    });
1523})

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.