PageSourceSearch

https://www.islandpackers.com/wp-content/themes/islandpackers/asse…?ver=d66fb444d20a8e7f7406e9d6e5debdac

js islandpackers.com collected 2026-09-24 21:10:09 UTC 86,798 bytes, 2,024 lines download raw bytes

1var monthsLZ = [];
2var monthsSZ = [];
3monthsLZ[1] = 'January';
4monthsLZ[2] = 'February';
5monthsLZ[3] = 'March';
6monthsLZ[4] = 'April';
7monthsLZ[5] = 'May';
8monthsLZ[6] = 'June';
9monthsLZ[7] = 'July';
10monthsLZ[8] = 'August';
11monthsLZ[9] = 'September';
12monthsLZ[10] = 'October';
13monthsLZ[11] = 'November';
14monthsLZ[12] = 'December';
15monthsSZ[1] = 'Jan';
16monthsSZ[2] = 'Feb';
17monthsSZ[3] = 'Mar';
18monthsSZ[4] = 'Apr';
19monthsSZ[5] = 'May';
20monthsSZ[6] = 'Jun';
21monthsSZ[7] = 'Jul';
22monthsSZ[8] = 'Aug';
23monthsSZ[9] = 'Sep';
24monthsSZ[10] = 'Oct';
25monthsSZ[11] = 'Nov';
26monthsSZ[12] = 'Dec';
27
28var customStyles = {
29    palette: {
30        background: {
31            default: "#ffffff"
32        }
33    }
34};
35
36var checkoutCustomStyle = {
37    palette: {
38		primary: {
39			main: "#212E63",
40			contrastText: "#ffffff"
41		},
42		secondary: {
43			main: "#212E63",
44		},
45		background: {
46			default: "#ffffff"
47		},
48		calendar: {
49			calendarDay: {
50				background: "#00b1d5 !important",
51				color: "#ffffff !important",
52				border: "1px solid #ffffff",
53				borderRadius: "4px"
54			}
55		}
56	}
57};
58
59var searchCustomStyle = {
60    palette: {
61		primary: {
62			main: "#5C94AC",
63			contrastText: "#ffffff"
64		},
65		secondary: {
66			main: "#5C94AC",
67		},
68		background: {
69			default: "#ffffff"
70		}
71	}
72};
73
74var signWaiverInlineStyle = {
75	".header": {
76		"height": "200px",
77		"textAlign": "center",
78		"& img": {
79			"height": "100%"
80		}
81	}
82};
83
84var tourInlineStyles = {
85	/*".calendar-custom-wrapper td.CalendarDay__default": {
86		"backgroundColor": "#BCC7E1 !important",
87	},
88	".calendar-custom-wrapper td.CalendarDay__selected": {
89		"backgroundColor": "#212E63 !important",
90	},
91	".calendar-custom-wrapper td.CalendarDay__default.CalendarDay__blocked_calendar": {
92		"backgroundColor": "transparent !important",
93	}*/
94};
95
96
97var allTranslations = ['ar','da','de','el','es','fr','he','hi','it','ja','ko','ms','nl','pt','ru','sw','tr','vi','zh'];
98
99function getCartItems() {
100    var anchorMetaStr = decodeURIComponent(getCookie('_anchorcidmeta'));
101    return isJson(anchorMetaStr) ? JSON.parse(anchorMetaStr) : { };
102}
103
104function getCartCount() {
105    var anchorMeta = getCartItems();
106    return anchorMeta.totalItems !== undefined ? anchorMeta.totalItems : 0;
107}
108
109function plusSlides(slideId, n) {
110    //window['slide_' + slideId] += n;
111    hbShowSlides(slideId, window['slide_' + slideId] += n);
112}
113
114function currentSlide(slideId, n) {
115    //window['slide_' + slideId] = n;
116    hbShowSlides(slideId, window['slide_' + slideId] = n);
117}
118
119function hbShowSlides(id, n) {
120    var slides = jQuery('.hbSlides[data-id='+id+']');
121    var dots = jQuery('.hb-dot[data-id='+id+']');
122    if (n > slides.length) {window['slide_' + id] = 1}
123    if (n < 1) {window['slide_' + id] = slides.length}
124    slides.attr('style', 'display: none;').removeClass('show');
125    for (var i = 0; i < dots.length; i++) {
126        dots[i].className = dots[i].className.replace(" active", "");
127    }
128    jQuery(slides[window['slide_' + id]-1]).attr('style', 'display: block;').addClass('show');
129    jQuery(dots).removeClass('active');
130    jQuery(dots[window['slide_' + id]-1]).addClass('active');;
131}
132
133function prepareHBSlideImages(id, slideIndex) {
134    window['slide_' + id] = slideIndex;
135    hbShowSlides(id, slideIndex);
136}
137
138function getPageTranslation() {
139    var thisPath = window.location.pathname.split('/');
140    var thisPath = jQuery.map( thisPath, function(v){
141        return v === "" ? null : v;
142    });
143    if(thisPath.length === 0) {
144        return 'en';
145    } else {
146        if(allTranslations.includes(thisPath[0])) {
147            //console.log('found',thisPath[0]);
148            return thisPath[0];
149        } else {
150            return 'en';
151        }
152    }
153}
154
155function updateHeaderHeight(el, head) {
156    console.log('el', el.height());
157    console.log('head', head.height());
158    if(true || el.height() < head.height()) {
159        el.attr('style','height:'+head.height()+'px;');
160    }
161}
162
163function populateDefaultTour(obj) {
164    var selTour = '';
165    //selTour = '/tour-options/alcatraz-day-tour/';
166    //selTour = '/tour-options/alcatraz-night-tour/';
167    //selTour = '/tour-options/alcatraz-behind-the-scenes-tour/';
168    //selTour = '/tour-options/alcatraz-angel-island-combo-tour/';
169    if(selTour.length > 0) obj.val(selTour);
170}
171
172function buildPaginationList(tot, cur, cName) {
173    var paginationHTML = '';
174    paginationHTML += '<ul>';
175    for(var pIdx=0; pIdx < tot; pIdx++) {
176        var thisIdx = pIdx + 1;
177        paginationHTML += '<li class="page-'+thisIdx+'">';
178        paginationHTML += '<a href="" class="'+cName+' '+(thisIdx === cur ? 'selected' : '')+'" role-num="'+thisIdx+'">'+thisIdx+'</a>';
179        paginationHTML += '</li>';
180    }
181    paginationHTML += '</ul>';
182    return paginationHTML;
183}
184
185function assignIframeClassW(iframeID) {
186    var iframeW = jQuery('iframe#'+iframeID).width();
187    //console.log('iframeW',iframeW);
188    var selClass = '';
189    if(iframeW < 500) {
190        selClassNum = 'sm';
191    } else if (iframeW >= 500) {
192        selClassNum = 'md';
193    }
194    jQuery('iframe#'+iframeID).attr('data-size',selClassNum);
195}
196
197function setCookie(cname, cvalue, exdays) {
198    var d = new Date();
199    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
200    var expires = "expires="+d.toUTCString();
201    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
202}
203
204function getCookie(cname) {
205    var name = cname + "=";
206    var ca = document.cookie.split(';');
207    for(var i = 0; i < ca.length; i++) {
208        var c = ca[i];
209        while (c.charAt(0) == ' ') {
210            c = c.substring(1);
211        }
212        if (c.indexOf(name) == 0) {
213            return c.substring(name.length, c.length);
214        }
215    }
216    return "";
217}
218
219function checkCookie() {
220    var user = getCookie("username");
221    if (user != "") {
222        alert("Welcome again " + user);
223    } else {
224        user = prompt("Please enter your name:", "");
225        if (user != "" && user != null) {
226            setCookie("username", user, 365);
227        }
228    }
229}
230
231function getElementProp_listing(obj) {
232    var elProp = [];
233    if (obj.length) {
234        var pos = obj.position();
235        elProp['posX'] = pos.left;
236        elProp['posY'] = pos.top;
237        elProp['w'] = obj.width();
238        elProp['h'] = obj.height();
239    }
240
241    return elProp;
242}
243
244function updateExpNav_listing(mainObj, ulWrap, ulObj, prevObj, nextObj) {
245    var expList = getElementProp_listing(ulWrap);
246    var listLen = ulObj.width();
247    var screenXsize = mainObj.width();
248    //ulWrap.attr('style', 'left:'+expList['posX']+'px; width:'+listLen+'px;');
249    if (listLen <= screenXsize - expList['posX']) {
250        nextObj.addClass('hide');
251    } else if (expList['w'] > screenXsize) {
252        nextObj.removeClass('hide');
253    }
254
255    if (expList['posX'] < 0) {
256        prevObj.removeClass('hide');
257    } else {
258        prevObj.addClass('hide');
259    }
260}
261
262function isJson(str) {
263    try {
264        JSON.parse(str);
265    } catch (e) {
266        return false;
267    }
268    return true;
269}
270
271function nextBtn_listing(mainObj, ulWrap, ulObj, prevObj, nextObj) {
272    var screenXsize = mainObj.width();
273    var listLen = ulObj.width();
274    var expList = getElementProp_listing(ulWrap);
275    var nextLeft = -(expList.posX - screenXsize);
276    console.log('screenXsize',screenXsize);
277    console.log('listLen',listLen);
278    console.log('expList',expList);
279    console.log('nextLeft',nextLeft);
280    nextLeft = nextLeft + screenXsize > listLen ? listLen - screenXsize : nextLeft;
281    console.log('nextLeft',nextLeft);
282    ulWrap.animate({
283        left: -nextLeft
284    }, 800, function () {
285        console.log('done animation');
286        updateExpNav_listing(mainObj, ulWrap, ulObj, prevObj, nextObj);
287    });
288}
289
290function prevBtn_listing(mainObj, ulWrap, ulObj, prevObj, nextObj) {
291    var screenXsize = mainObj.width();
292    var listLen = ulObj.width();
293    var expList = getElementProp_listing(ulWrap);
294    var nextRight = expList.posX + screenXsize > 0 ? 0 : expList.posX + screenXsize;
295    nextRight = nextRight > 0 ? 0 : nextRight;
296    ulWrap.animate({
297        left: nextRight
298    }, 800, function () {
299        updateExpNav_listing(mainObj, ulWrap, ulObj, prevObj, nextObj);
300    });
301}
302
303function calculateToShowFiller(mainObj, liDataObj, liFillerObj) {
304    var item_per_row = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2;
305    var allDataCount = liDataObj.length;
306    var allHiddenDataCount = 0; //liDataObj.attr('class','hide').length;
307
308    jQuery(liDataObj).each(function (liItem) {
309        allHiddenDataCount += jQuery(this).hasClass('hide') ? 1 : 0;
310    });
311    var allShowDataCount = allDataCount - allHiddenDataCount;
312    var fillerMax = liFillerObj.length;
313    var modVal = allShowDataCount % item_per_row;
314    var needFillerCount = allShowDataCount == 0 ? item_per_row : modVal ? item_per_row - modVal : modVal; //console.log('allDataCount',allDataCount);
315    //console.log('allHiddenDataCount',allHiddenDataCount);
316    //console.log('allShowDataCount',allShowDataCount);
317    //console.log('fillerMax',fillerMax);
318    //console.log('item_per_row',item_per_row);
319
320    var fillerIdx = [];
321
322    for (var idx = 0; idx < needFillerCount; idx++) {
323        fillerIdx = getAvailableIndex(fillerIdx, fillerMax);
324    } //console.log('fillerIdx',fillerIdx);
325
326
327    for (var fidx = 0; fidx < fillerIdx.length; fidx++) {
328        jQuery(liFillerObj).each(function (tx) {
329            //console.log('tx',tx,'fidx',fillerIdx[fidx]);
330            if (tx + 1 == fillerIdx[fidx]) {
331                //console.log('tx',tx);
332                jQuery(this).removeClass('hide');
333            }
334        });
335    }
336
337    ;
338}
339
340function getTodayDate() {
341    var today = new Date();
342    var dd = String(today.getDate()).padStart(2, '0');
343    var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
344    var yyyy = today.getFullYear();
345
346    return mm + '/' + dd + '/' + yyyy;
347}
348
349function getTodayDateOrUrlParam(urlParam) {
350    var selUrlParam = decodeURIComponent(getUrlParam(urlParam,''));
351    var today = new Date();
352    var dd = String(today.getDate()).padStart(2, '0');
353    var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
354    var yyyy = today.getFullYear();
355
356    return selUrlParam.length ? selUrlParam : mm + '/' + dd + '/' + yyyy;
357}
358
359function getAvailableIndex(existing, max) {
360    var found = false;
361    var maxIter = 10;
362    var curIter = 0;
363    var nextNum = 0;
364
365    while (!found && curIter < maxIter) {
366        nextNum = Math.floor(Math.random() * 1000000 % max) + 1;
367
368        if (existing.indexOf(nextNum) < 0) {
369            existing.push(nextNum);
370            found = true;
371            curIter = maxIter;
372        }
373
374        curIter++;
375    }
376
377    if (!found) {
378        for (idx = 0; idx < max; idx++) {
379            if (existing.indexOf(idx) < 0) {
380                existing.push(idx);
381                idx = max;
382            }
383        }
384    }
385
386    return existing;
387}
388
389function removeActiveFilterByClass(filterClass) {
390    jQuery('.' + filterClass).removeClass('active');
391}
392
393function hideAllListItemsByElement() {
394    for (i = 0; i < arguments.length; i++) {
395        jQuery(arguments[i]).addClass('hide');
396    }
397}
398
399function showAllListItemsByClass(liObj, cName) {
400    jQuery(liObj).each(function () {
401        if (cName == '' || jQuery(this).hasClass(cName)) {
402            jQuery(this).removeClass('hide');
403        }
404    });
405}
406
407function populateTour(tour,lang) {
408    var tourObj = {};
409    var thisLang = lang === undefined ? 'en' : lang;
410    //console.log('thisLangthisLang',thisLang);
411    if(tour.unavailable.length) {
412        tourObj = tour.unavailable[0];
413        var localizedEnLang = tourObj.localizedInfo['en'];
414        var localizedLang = tourObj.localizedInfo[thisLang] || localizedEnLang;
415        //console.log('localizedLanglocalizedLang',localizedLang);
416        tourObj.title = localizedLang.title || localizedEnLang.title || 'No Title';
417        tourObj.overview = localizedLang.description || localizedEnLang.description || "";
418        tourObj.whatUget = localizedLang.whatYouGet || localizedEnLang.whatYouGet || "";
419        tourObj.schedule = localizedLang.schedule || localizedEnLang.schedule || "";
420        tourObj.whereToMeet = localizedLang.whereToMeet || localizedEnLang.whereToMeet || "";
421        tourObj.dressCode = localizedLang.dressCode || localizedEnLang.dressCode || "";
422
423        tourObj.has_whereToMeet = tourObj.whereToMeet.length > 0;
424        tourObj.has_whatUget = tourObj.whatUget.length > 0;
425        tourObj.has_schedule = tourObj.schedule.length > 0;
426        tourObj.has_dressCode = tourObj.dressCode.length > 0;
427
428		tourObj.video = (tourObj.media.videos.length ? tourObj.media.videos[0].url : '');
429        tourObj.has_video = (tourObj.media.videos.length ? true : false);
430        tourObj.address = (tourObj.settings['address.formatted'] || '');
431        tourObj.additional_assets = [];
432        tourObj.additional_assets_no_map = [];
433        tourObj.lat = tourObj.settings['address.latitude'];
434        tourObj.lon = tourObj.settings['address.longitude'];
435        tourObj.has_main_image = false;
436
437        tourObj.review = (tourObj.settings.review || "");
438        //tourObj.overview = (tourObj.overview.length ? '<h2>Overview</h2>' + tourObj.overview : "");
439        //tourObj.whatUget = (tourObj.whatUget.length ? '<h2>Includes</h2>' + tourObj.whatUget : "");
440        //tourObj.schedule = (tourObj.schedule.length ? '<h2>Schedule</h2>' + tourObj.schedule : "");
441        //tourObj.whereToMeet = (tourObj.whereToMeet.length ? '<h2>Where to Meet</h2>' + tourObj.whereToMeet : "");
442        //tourObj.dressCode = (tourObj.dressCode.length ? '<h2>Dress Code</h2>' + tourObj.dressCode : "");
443        tourObj.has_review = (tourObj.review.length ? true : false);
444
445        var mainImageIndex = 0;
446        tourObj.has_prime_image = !tourObj.has_video;
447        tourObj.has_main_image = false;
448        if(tourObj.media.images.length && tourObj.has_prime_image) {
449            tourObj.prime_image_url = tourObj.media.images[0].url;
450            mainImageIndex++;
451        }
452
453        if(tourObj.media.images.length > mainImageIndex) {
454            tourObj.main_image_url = tourObj.media.images[mainImageIndex].url;
455            tourObj.main_image_index = mainImageIndex + 1;
456            tourObj.has_main_image = true;
457        }
458			
459		tourObj.liCategories = convertCategories(tourObj.categories || '');
460		
461
462if (tourObj.liCategories.length) {
463    let _cats = tourObj.liCategories, 
464        _catsArr = _cats.split(" ");
465
466    tourObj.childCruisePrice = _catsArr.filter(e => e.indexOf("child-s-cruise-price") > -1);
467    tourObj.windowSeats = _catsArr.filter(e => e.indexOf("window-seats") > -1);
468
469    tourObj.childCruisePrice = tourObj.childCruisePrice.length ? tourObj.childCruisePrice[0].split("---")[1] : "$0.00";
470    tourObj.windowSeats = tourObj.windowSeats.length ? tourObj.windowSeats[0].split("---")[1] : "$0.00";
471}
472
473        //console.log('mainImageIndex',mainImageIndex);
474        var shiftIndex = tour.is_experiences ? 0 : 1;
475        tourObj.max_image_assets = tourObj.media.images.length;
476        for(var idx=mainImageIndex;idx < tourObj.media.images.length; idx+=2) {
477            var add_images = { top: '', top_image_assets: '', bottom: '', bottom_image_assets: '', has_bottom: false};
478            if(idx < tourObj.media.images.length) {
479                add_images.top = tourObj.media.images[idx].url;
480                add_images.top_image_assets = idx + 1;
481            }
482            if(idx + 1 < tourObj.media.images.length) {
483                add_images.bottom = tourObj.media.images[idx+1].url;
484                add_images.bottom_image_assets = idx + 2;
485                add_images.has_bottom = true;
486            }
487            tourObj.additional_assets.push(add_images)
488        }
489    }
490    return tourObj;
491}
492
493var formatter = new Intl.NumberFormat('en-US', {
494    style: 'currency',
495    currency: 'USD',
496});
497
498function getItineraryDayPort(itinObj, dayNum) {
499    var portObj = { port_id: 0, 'port_name': '', 'port_link': '', 'port_image': '', 'port_content': '', 'has_excursion': false, 'excursions': { 'has_included': false, 'has_premium': false, 'included': [], 'premium': [] } };
500    var thisPort = itinObj.length > (dayNum-1) ? itinObj[dayNum-1].port : itinObj[itinObj.length-1].port;
501    var thisExcursion = itinObj.length > (dayNum-1) ? itinObj[dayNum-1].excursions : itinObj[itinObj.length-1].excursions;
502    //console.log('itinObj',itinObj);
503    //console.log('thisPort',thisPort);
504    portObj.port_id = thisPort.id;
505    portObj.port_name = (thisPort.localizedInfo.en !== undefined && thisPort.localizedInfo.en.portName) || '';
506    portObj.port_link = '';
507    portObj.port_image = thisPort.media.images[0];
508    portObj.port_content = (thisPort.localizedInfo.en !== undefined && thisPort.localizedInfo.en.portDescription) || '';
509    portObj.has_excursion = thisExcursion.length > 0;
510    portObj.excursions = thisExcursion;
511    return portObj;
512}
513
514function getDateProps(thisDate) {
515    var thisDateProp = { 'ldate': '', 'lsdate': '', 'sdate0': '', 'sdate': '', 'cdate': '', 'mdate': '', 'yydate': '', 'mmdate': '', 'dddate': '', 'phpdate': '', 'ymddate':'', 'gmtdate': '' }
516    var thisDateObj = thisDate.split('-');
517    var thisDateMM = thisDateObj[1];
518    var thisDateM = parseInt(thisDateMM);
519    var thisDateDD = thisDateObj[2];
520    var thisDateD = parseInt(thisDateDD);
521    var thisDateYYYY = thisDateObj[0];
522    var thisDateYY = thisDateYYYY.substr(-2,2);
523    thisDateProp.ldate = monthsLZ[thisDateM] + ' ' + thisDateD + ', ' + thisDateYYYY;
524    thisDateProp.lsdate = monthsSZ[thisDateM] + ' ' + thisDateD + ', ' + thisDateYYYY;
525    thisDateProp.sdate0 = thisDateMM + '/' + thisDateDD + '/' + thisDateYYYY;
526    thisDateProp.sdate = thisDateM + '/' + thisDateD + '/' + thisDateYYYY;
527    thisDateProp.cdate = thisDateM + '/' + thisDateD + '/' + thisDateYYYY;
528    thisDateProp.udate = thisDateM + '-' + thisDateD + '-' + thisDateYYYY;
529    thisDateProp.mdate = thisDateYYYY + '-' + thisDateMM;
530    thisDateProp.yydate = thisDateYYYY;
531    thisDateProp.mmdate = thisDateMM;
532    thisDateProp.dddate = thisDateDD;
533    thisDateProp.phpdate = thisDateYYYY;
534    thisDateProp.ymddate = thisDateYYYY+thisDateMM+thisDateDD;
535    thisDateProp.gmtdate = thisDate;
536    return thisDateProp;
537}
538
539function populateSdkTours(tours, selMonth) {
540    var listObj = { listing: [] };
541    //console.log('selMonth',selMonth);
542    for(var tIdx=0; tIdx < tours.length; tIdx++) {
543        var thisTour = populateSdkTour(tours[tIdx]);
544        //console.log('thisTourthisTour',thisTour);
545        var thisVesselData = thisTour.cruise_data.vessel_data;
546        for(var vIdx=0; vIdx < thisVesselData.length; vIdx++) {
547            var thisListing = { item_image: '', item_name: '', sub_title: '', description: '', depart_date: { ldate: ''}, has_sale_price: false, from_original_price_str: '', permalink: '', sailingId: 0 };
548            thisListing.item_image = thisTour.prime_image_url;
549            thisListing.item_name = thisTour.title;
550            thisListing.sub_title = thisTour.sub_title;
551            thisListing.description = thisTour.localizedInfo.en.shortDescription;
552            thisListing.permalink = thisTour.permalink;
553            thisListing.item_link = thisTour.permalink;
554            var thisVessel = thisVesselData[vIdx];
555            thisListing.itineraryName = thisVesselData[vIdx].itineraryName;
556            thisListing.sailingId = thisVesselData[vIdx].sailingID;
557            thisListing.depart_date = thisVesselData[vIdx].vessel_date;
558            thisListing.arrive_date = thisVesselData[vIdx].vessel_end_date;
559            thisListing.vessel_name = thisVesselData[vIdx].vesselName;
560            thisListing.numDays = thisVesselData[vIdx].numDays;
561            thisListing.cruise_date = thisListing.depart_date.ymddate;
562            thisListing.has_sale_price = thisVesselData[vIdx].has_startingAtSalePrice;
563            thisListing.from_original_price_str = thisVesselData[vIdx].startingFromPrice_str;
564            thisListing.from_sale_price_str = thisVesselData[vIdx].startingAtSalePrice_str;
565            thisListing.save_per_couple_str = thisVesselData[vIdx].starting_save_per_couple_str;
566            if(selMonth === '' || selMonth === thisListing.depart_date.mdate) {
567                listObj.listing.push(thisListing);
568            }
569        }
570    }
571    return listObj;
572}
573
574function populateSdkTour(tour) {
575    var tourObj = {};
576    //console.log('tourtour',tour);
577    tourObj = tour;
578    tourObj.title = (tourObj.localizedInfo.en.title || 'No Title');
579    tourObj.sub_title = (tourObj.localizedInfo.en.subTitle || '');
580    tourObj.video = (tourObj.media.videos.length ? tourObj.media.videos[0].url : '');
581    tourObj.has_video = (tourObj.media.videos.length ? true : false);
582    tourObj.address = (tourObj.settings['address.formatted'] || '');
583    tourObj.additional_assets = [];
584    tourObj.lat = tourObj.settings['address.latitude'];
585    tourObj.lon = tourObj.settings['address.longitude'];
586    tourObj.has_main_image = false;
587
588    tourObj.overview = (tourObj.localizedInfo.en.description || "");
589    tourObj.whatUget = (tourObj.localizedInfo.en.whatYouGet || "");
590    tourObj.schedule = (tourObj.localizedInfo.en.schedule || "");
591    tourObj.whereToMeet = (tourObj.localizedInfo.en.whereToMeet || "");
592    tourObj.dressCode = (tourObj.localizedInfo.en.dressCode || "");
593    tourObj.review = (tourObj.settings.review || "{}");
594    tourObj.overview = (tourObj.overview.length ? '<h2>Cruise Highlights</h2>' + tourObj.overview : "");
595    tourObj.whatUget = (tourObj.whatUget.length ? '<h2>Itinerary</h2>' + tourObj.whatUget : "");
596    tourObj.schedule = (tourObj.schedule.length ? '<h2>Schedule</h2>' + tourObj.schedule : "");
597    tourObj.whereToMeet = (tourObj.whereToMeet.length ? '<h2>Where to Meet</h2>' + tourObj.whereToMeet : "");
598    tourObj.dressCode = (tourObj.dressCode.length ? '<h2>Dress Code</h2>' + tourObj.dressCode : "");
599    tourObj.has_review = (tourObj.review.length ? true : false);
600    tourObj.listing =  JSON.parse(isJson(tourObj.review) ? tourObj.review :  '{}');
601    tourObj.total_listing = tourObj.listing.length;
602    for(var lidx=0; lidx < tourObj.listing.length; lidx++) {
603        var thisYStr = tourObj.listing[lidx].cruise_date.slice(0,4);
604        var thisMStr = tourObj.listing[lidx].cruise_date.slice(4,6).replace(/^0+/, '');
605        var thisDStr = tourObj.listing[lidx].cruise_date.slice(6,8).replace(/^0+/, '');
606        tourObj.listing[lidx].cruise_date_numeric = thisMStr+'/'+thisDStr+'/'+thisYStr;
607        tourObj.listing[lidx].cruise_date_str_long = monthsLZ[thisMStr]+' '+thisDStr+', '+thisYStr;
608        tourObj.listing[lidx].cruise_date_str_short = monthsSZ[thisMStr]+' '+thisDStr+', '+thisYStr;
609    }
610
611    var mainImageIndex = 0;
612    tourObj.has_prime_image = !tourObj.has_video;
613    tourObj.has_main_image = false;
614    if(tourObj.media.images.length && tourObj.has_prime_image) {
615        tourObj.prime_image_url = tourObj.media.images[0].url;
616        mainImageIndex++;
617    }
618
619    tourObj.max_image_assets = tourObj.media.images.length;
620    for(var idx=mainImageIndex;idx < tourObj.media.images.length; idx+=2) {
621        var add_images = { top: '', top_image_assets: '', bottom: '', bottom_image_assets: '', has_bottom: false};
622        if(idx < tourObj.media.images.length) {
623            add_images.top = tourObj.media.images[idx].url;
624            add_images.top_image_assets = idx + 1;
625        }
626        if(idx + 1 < tourObj.media.images.length) {
627            add_images.bottom = tourObj.media.images[idx+1].url;
628            add_images.bottom_image_assets = idx + 2;
629            add_images.has_bottom = true;
630        }
631        tourObj.additional_assets.push(add_images)
632    }
633    tourObj.has_menu = tourObj.menuId && tourObj.menuId.length ? true : false;
634    tourObj.has_itineraries = (tourObj.itineraries || []).length ? true : false;
635    tourObj.itinerariesData = [];
636    tourObj.portData = [];
637    tourObj.vesselData = [];
638    tourObj.cruise_data = { cruise_year: [], cruise_date: [], vessel_data: [] };
639    if(tourObj.has_itineraries) {
640        for(var itinIdx=0; itinIdx < tourObj.itineraries.length; itinIdx++) {
641            var thisItinProp = {};
642            var thisItin = tourObj.itineraries[itinIdx];
643            thisItinProp.itinID = thisItin.id;
644            thisItinProp.mapFrame = thisItin.settings.itineraryMapEmbedLink;
645            thisItinProp.has_map = (thisItinProp.mapFrame || '').length ? true : false;
646            thisItinProp.z_index = itinIdx === 0 ? 100 : 1;
647            thisItinProp.numDays = thisItin.settings.itineraryNumberOfDays;
648            thisItinProp.vesselID = thisItin.settings.vesselId;
649            thisItinProp.vessel = thisItin.vessel;
650            thisItinProp.sailing = thisItin.sailings;
651            thisItinProp.itineraryName = thisItin.localizedInfo.en.itineraryName;
652            thisItinProp.numDays = thisItin.settings.itineraryNumberOfDays;
653            thisItinProp.itineraryInternalName = thisItin.localizedInfo.en.itineraryInternalName;
654            thisItinProp.itineraryDayItem = [];
655            for(var iDayIdx=0; iDayIdx < thisItin.itineraryDayItem.length; iDayIdx++) {
656                var thisItinDay = thisItin.itineraryDayItem[iDayIdx];
657                var thisItinObj = {
658                    itineraryDayNumber: thisItinDay.settings.itineraryDayNumber,
659                    itineraryPortId: thisItinDay.settings.itineraryPortId,
660                    itineraryIncludedPortExcursions: thisItinDay.settings.itineraryIncludedPortExcursions,
661                    itineraryPremiumPortExcursions: thisItinDay.settings.itineraryPremiumPortExcursions,
662                    active: iDayIdx === 0 ? 'active' : '',
663                    show:  iDayIdx === 0 ? 'show' : '',
664                    media: thisItinDay.media,
665                    port: thisItinDay.port,
666                    excursions: thisItinDay.excursions,
667                    port_id: thisItinDay.port.id,
668                    port_name: (thisItinDay.port.localizedInfo.en !== undefined && thisItinDay.port.localizedInfo.en.portName) || '',
669                    port_int_name: (thisItinDay.port.localizedInfo.en !== undefined && thisItinDay.port.localizedInfo.en.portInternalName) || '',
670                    port_desc: (thisItinDay.port.localizedInfo.en !== undefined && thisItinDay.port.localizedInfo.en.portDescription) || '',
671                    port_image: thisItinDay.port.media.images.length ? thisItinDay.port.media.images[0].url : '',
672                    inc_excursions: [],
673                    prm_excursions: [],
674                    has_excursion: false,
675                    has_inc_exc: false,
676                    has_prm_exc: false,
677                }
678                for(var iExcIdx=0; iExcIdx < thisItinObj.excursions.length; iExcIdx++) {
679                    var thisExcursion = thisItinObj.excursions[iExcIdx];
680                    var thisExcObj = {
681                        exc_id: thisExcursion.id,
682                        exc_price_str: thisExcursion.settings.excursionDisplayPrice,
683                        exc_type: thisExcursion.settings.excursionType,
684                        exc_port_id: thisExcursion.settings.portId,
685                        exc_port_name: thisExcursion.settings.portName,
686                        exc_link: thisExcursion.settings.excursionLink,
687                        exc_name: thisExcursion.localizedInfo.en.excursionName,
688                        exc_desc: thisExcursion.localizedInfo.en.excursionDescription,
689                        exc_int_name: thisExcursion.localizedInfo.en.excursionInternalTitle,
690                        exc_image: thisExcursion.media.images.length > 0 ? thisExcursion.media.images[0].url : '',
691                        exc_has_img: thisExcursion.media.images.length > 0,
692                        exc_media: thisExcursion.media,
693                        exc_show: false,
694                    };
695                    if(thisExcObj.exc_type === 'Included') {
696                        thisExcObj.exc_idx = thisItinObj.inc_excursions.length + 1;
697                        thisExcObj.exc_show = thisItinObj.inc_excursions.length === 0;
698                        thisItinObj.inc_excursions.push(thisExcObj);
699                    } else if(thisExcObj.exc_type === 'Premium') {
700                        thisExcObj.exc_show = thisItinObj.prm_excursions.length === 0;
701                        thisExcObj.exc_idx = thisItinObj.prm_excursions.length + 1;
702                        thisItinObj.prm_excursions.push(thisExcObj);
703                    }
704                }
705                thisItinObj.has_inc_exc = thisItinObj.inc_excursions.length > 0;
706                thisItinObj.has_prm_exc = thisItinObj.prm_excursions.length > 0;
707                thisItinObj.has_excursion = thisItinObj.has_inc_exc || thisItinObj.has_prm_exc;
708                thisItinProp.itineraryDayItem.push(thisItinObj);
709            }
710            for(var iSailIdx=0; iSailIdx < thisItin.sailings.length; iSailIdx++) {
711                var thisSailingProp = {};
712                var thisSailing = thisItin.sailings[iSailIdx];
713                thisSailingProp.itineraryName = thisItinProp.itineraryName;
714                thisSailingProp.numDays = thisItinProp.numDays;
715                thisSailingProp.id = thisSailing.id;
716                thisSailingProp.voyageCode = thisSailing.settings.voyageCode;
717                thisSailingProp.sailingID = thisSailing.id;
718                thisSailingProp.vesselID = thisSailing.settings.vesselId;
719                thisSailingProp.vessel_start_date = getDateProps(thisSailing.settings.startDate);
720                thisSailingProp.vessel_date = thisSailingProp.vessel_start_date;
721                thisSailingProp.vessel_end_date = getDateProps(thisSailing.settings.endDate);
722                //thisSailingProp.startingFromPrice = thisSailing.settings.startingFromPrice;
723                //thisSailingProp.startingAtSalePrice = thisSailing.settings.startingAtSalePrice;
724
725                //thisSailingProp.startingFromPrice_str = thisSailing.settings.startingFromPrice || '';
726                thisSailingProp.startingFromPrice_str = thisSailing.settings.startingFromPrice === '' ? formatter.format(0) : formatter.format(thisSailing.settings.startingFromPrice.replace(/\$|\,/g,'').trim());
727                thisSailingProp.startingAtSalePrice_str = thisSailing.settings.startingAtSalePrice || '';
728                thisSailingProp.startingFromPrice = thisSailingProp.startingFromPrice_str.replace(/\$|\,/g,'').trim();
729                thisSailingProp.startingAtSalePrice = thisSailingProp.startingAtSalePrice_str.replace(/\$|\,/g,'').trim();
730                thisSailingProp.has_startingAtSalePrice = thisSailingProp.startingAtSalePrice.length > 0;
731                thisSailingProp.starting_save_per_couple_str = '';
732                thisSailingProp.starting_save_per_couple = 0;
733                if(thisSailingProp.has_startingAtSalePrice) {
734                    thisSailingProp.starting_save_per_couple = thisSailingProp.startingFromPrice - thisSailingProp.startingAtSalePrice;
735                    thisSailingProp.starting_save_per_couple_str = formatter.format(thisSailingProp.starting_save_per_couple);
736                }
737
738                thisSailingProp.vessel_start_port = getItineraryDayPort(thisItinProp.itineraryDayItem, 1);
739                thisSailingProp.vessel_end_port = getItineraryDayPort(thisItinProp.itineraryDayItem, thisItinProp.numDays);
740                thisSailingProp.vesselName = thisSailing.vessel.translations.en.name;
741                thisSailingProp.shortDescription = thisSailing.vessel.translations.en.shortDescription;
742                thisSailingProp.vesselMedia = thisSailing.vessel.media;
743                if(!tourObj.cruise_data.cruise_year.includes(thisSailingProp.vessel_start_date.yydate)) {
744                    tourObj.cruise_data.cruise_year.push(thisSailingProp.vessel_start_date.yydate);
745                }
746                if(!tourObj.cruise_data.cruise_date.includes(thisSailingProp.vessel_start_date.mdate)) {
747                    tourObj.cruise_data.cruise_date.push(thisSailingProp.vessel_start_date.mdate);
748                }
749                thisSailingProp.cabins = [];
750                thisSailingProp.vessel_from_original_price = "";
751                thisSailingProp.vessel_from_sale_price = "";
752                thisSailingProp.vessel_save_per_couple = "";
753                thisSailingProp.vessel_from_original_price_str = "";
754                thisSailingProp.vessel_from_sale_price_str = "";
755                thisSailingProp.vessel_save_per_couple_str = "";
756                thisSailingProp.has_vessel_from_sale_price = false;
757                for(var iCabinIdx=0; iCabinIdx < thisSailing.vessel.cabins.length; iCabinIdx++) {
758                    var thisCabin = thisSailing.vessel.cabins[iCabinIdx];
759                    var thisCabinProp = {};
760                    if(thisSailing.cabinStandardPrice[thisCabin.id] !== undefined) {
761                        thisCabinProp.id = thisCabin.id;
762                        thisCabinProp.cabin_idx = thisSailingProp.cabins.length + 1;
763                        thisCabinProp.cabin_active = thisCabinProp.cabin_idx === 1 ? true : false;
764                        thisCabinProp.cabin_id = thisCabin.id;
765                        thisCabinProp.cabin_name = thisCabin.translations.en.name;
766                        thisCabinProp.cabin_desc = thisCabin.translations.en.description;
767                        thisCabinProp.media = thisCabin.media;
768                        thisCabinProp.cabin_image = thisCabinProp.media.images.length > 0 ? thisCabinProp.media.images[0].url : '';
769                        thisCabinProp.standardPrice = thisSailing.cabinStandardPrice[thisCabin.id];
770                        thisCabinProp.salePrice = thisSailing.cabinSalePrice[thisCabin.id] || '';
771                        thisCabinProp.cabin_price_str = thisCabinProp.standardPrice.trim();
772                        thisCabinProp.cabin_price_sale_str = thisCabinProp.salePrice.trim();
773                        var thisCabinStandardPrice = thisCabinProp.cabin_price_str.replace(/\$|\,/g,'').trim();
774                        thisCabinStandardPrice = thisCabinStandardPrice.length > 0 ? parseFloat(thisCabinStandardPrice).toFixed(2) : thisCabinStandardPrice;
775                        var thisCabinSalePrice = thisCabinProp.cabin_price_sale_str.replace(/\$|\,/g,'').trim();
776                        thisCabinSalePrice = thisCabinSalePrice.length > 0 ? parseFloat(thisCabinSalePrice).toFixed(2) : thisCabinSalePrice;
777                        if( (thisCabinStandardPrice.length > 0 && thisSailingProp.vessel_from_original_price.length === 0) || (thisCabinStandardPrice.length > 0 && thisSailingProp.vessel_from_original_price.length > 0 && thisSailingProp.vessel_from_original_price > thisCabinStandardPrice)) {
778                            thisSailingProp.vessel_from_original_price = thisCabinStandardPrice;
779                            thisSailingProp.vessel_from_sale_price = thisCabinSalePrice;
780                            thisSailingProp.vessel_from_original_price_str = thisCabinProp.standardPrice.trim();
781                            thisSailingProp.vessel_from_sale_price_str = thisCabinProp.salePrice.trim();
782                            thisSailingProp.has_vessel_from_sale_price = thisSailingProp.vessel_from_sale_price.length > 0 ? true : false;
783                            if(thisSailingProp.has_vessel_from_sale_price) {
784                                thisSailingProp.vessel_save_per_couple = (thisSailingProp.vessel_from_original_price - thisSailingProp.vessel_from_sale_price) * 2;
785                                thisSailingProp.vessel_save_per_couple_str = formatter.format(thisSailingProp.vessel_save_per_couple);
786                            }
787                        }
788                        thisSailingProp.cabins.push(thisCabinProp);
789                    }
790                }
791                for(var cIdx=0; cIdx < thisSailingProp.cabins.length; cIdx++) {
792                    thisSailingProp.cabins[cIdx].prev_cabin_idx = cIdx === 0 ? thisSailingProp.cabins.length : cIdx;
793                    thisSailingProp.cabins[cIdx].next_cabin_idx = thisSailingProp.cabins.length - (cIdx + 1) > 0 ? cIdx + 2 : 1;
794                }
795                tourObj.cruise_data.vessel_data.push(thisSailingProp);
796            }
797            tourObj.itinerariesData.push(thisItinProp);
798        }
799    }
800    tourObj.cruise_data.vessel_data.sort(function (a, b) {
801        var numberToSortA = a.vessel_start_date.ymddate === null ? 0 : parseInt(a.vessel_start_date.ymddate);
802        var numberToSortB = b.vessel_start_date.ymddate === null ? 0 : parseFloat(b.vessel_start_date.ymddate);
803        return numberToSortA - numberToSortB;
804    });
805    //console.log('sortedTours',sortedTours);
806    tourObj.cruise_data.cruise_year = tourObj.cruise_data.cruise_year.sort();
807    tourObj.cruise_data.cruise_date = tourObj.cruise_data.cruise_date.sort();
808    return tourObj;
809}
810
811function populateTours() {
812    var tours = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
813    var maxCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
814    var availability = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
815    var max_show_onload = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
816    var steps_show_more = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
817    var localMyObj = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
818    var excludeList = localMyObj.exclude_list || '';
819    var lang = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'en';
820    var toursObj = {
821        listing: []
822    };
823    //console.log('populateTours',localMyObj);
824    var numberPattern = /[\d|.]+/g;
825    var tourList = availability ? tours.available : tours.unavailable;
826    var maxTourCount = maxCount === 0 ? tourList.length : tourList.length <= maxCount ? tourList.length : maxCount;
827    max_show_onload = max_show_onload === 0 ? maxTourCount : max_show_onload;
828    var excludeArr = excludeList.split(',');
829
830    for (i = 0; i < maxTourCount; i++) {
831        var localTour = tourList[i];
832
833        if (excludeArr.indexOf(localTour.tourId) < 0) {
834            localTour.liCategories = convertCategories(localTour.categories || '');
835            localTour.localizedInfo.en.shortDesc = (localTour.localizedInfo.en.shortDescription || '').replace(/\n/g, '<br />');
836            localTour.settings.displayPriceOnly = (localTour.settings.displayPrice || '').match(numberPattern);
837            localTour.settings.displayPriceSign = (localTour.settings.displayPrice || '').replace(localTour.settings.displayPriceOnly, '');
838            localTour.noMedia = localTour.media.images.length ? false : true;
839            localTour.slider_max = localTour.media.images.length;
840			localTour.categoryArr = localTour.categories.split(',') || [];
841
842            for (j = 0; j < localTour.media.images.length; j++) {
843                localTour.media.images[j].slide_num = j + 1;
844                localTour.media.images[j].active = j == 0 ? 'active' : '';
845            }
846
847            localTour.no_image = localTour.noMedia;
848            localTour.has_image = !localTour.no_image;
849            localTour.has_event_data = true; //localTour.use_filler = !localTour.has_event_data;
850			
851			localTour.has_most_popular = localTour.categoryArr.includes('category most popular');
852			localTour.has_all_ages = localTour.categoryArr.includes('category all ages');
853			localTour.has_4_hours = localTour.categoryArr.includes('category 4 hours');
854			localTour.has_5_hours = localTour.categoryArr.includes('category 5 hours');
855			localTour.has_6_hours = localTour.categoryArr.includes('category 6 hours');
856			localTour.has_hour_tags = localTour.has_4_hours || localTour.has_5_hours || localTour.has_6_hours;
857			localTour.has_bottom_tags = localTour.has_all_ages || localTour.has_hour_tags;
858			
859			localTour.currencySign = localTour.propertySettings.defaultCurrency === 'USD' ? '$' : '$';
860			localTour.displayPrice = (localTour.settings.displayPrice || '').indexOf(localTour.currencySign) >= 0 ? localTour.settings.displayPrice : localTour.currencySign + localTour.settings.displayPrice;
861
862            if (!localTour.no_image) {
863                localTour.item_image = localTour.media.images[0].url;
864            }
865
866            localTour.item_link = localTour.permalink;
867
868            var localizedEnLang = localTour.localizedInfo['en'];
869            var localizedLang = localTour.localizedInfo[lang] || localizedEnLang;
870
871            localTour.item_name = localizedLang.title || localizedEnLang.title || 'No Title';
872            localTour.description = localizedLang.description || localizedEnLang.description || '';
873            localTour.overview = (localizedLang.description || localizedEnLang.description || '').replace(/<(?:.|\n)*?>/gm, '');
874            localTour.clean_desc = (localizedLang.description || localizedEnLang.description || '').replace(/<(?:.|\n)*?>/gm, '');
875            localTour.clean_schedule = (localizedLang.schedule || localizedEnLang.schedule || '').replace(/<(?:.|\n)*?>/gm, '');
876            localTour.slider_id = localTour.tourId;
877            localTour.show_after_click_btn = max_show_onload <= i;
878            localTour.tourReview = localTour.settings.review || '';
879            localTour.has_tourReview = localTour.tourReview.length ? true : false;
880            toursObj.listing.push(localTour);
881        }
882    }
883	if(localMyObj.settings.add_manual_tiles) {
884		console.log('populateTours-add-manual',{localMyObj,toursObj});
885		var manualTilesIndex = [];
886		var manualTiles = [];
887		for(var j=0; j < (localMyObj.settings.manual_tiles || []).length; j++) {
888			var localTileNo = localMyObj.settings.manual_tiles[j].tile_order;
889			toursObj.listing.splice( (localTileNo-1), 0, localMyObj.settings.manual_tiles[j] );
890		}
891	}
892	//console.log('populateTours', tourList);
893
894    return toursObj;
895}
896
897function convertCategories(categories) {
898    var cat = [];
899    categories.split(',').map(function (category) {
900        cat.push(category.trim().replace(/ |\'/g, '-'));
901    });
902    return cat.join(' ');
903}
904
905function build_nav_script_js(listingID, listingName) {
906    window[listingID + '_mainObj'] = jQuery( listingName );
907    window[listingID + '_ulScrollObj'] = jQuery( listingName + ' .glisting-container' );
908    window[listingID + '_ulWrapObj'] = jQuery( listingName + ' .glisting-content' );
909    window[listingID + '_ulObj'] = jQuery( listingName + ' .glisting-content ul.glisting' );
910    window[listingID + '_next'] = jQuery( listingName + ' .nav-arrow a.next' );
911    window[listingID + '_prev'] = jQuery( listingName + ' .nav-arrow a.prev' );
912    window[listingID + '_next'].on('click', function(e) {
913        console.log('clicked next');
914        e.preventDefault();
915        console.log('_mainObj',window[listingID + '_mainObj']);
916        console.log('_ulScrollObj',window[listingID + '_ulScrollObj']);
917        console.log('_ulWrapObj',window[listingID + '_ulWrapObj']);
918        console.log('_ulObj',window[listingID + '_ulObj']);
919        console.log('_next',window[listingID + '_next']);
920        console.log('_prev',window[listingID + '_prev']);
921        nextBtn_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
922    });
923    window[listingID + '_prev'].on('click', function(e) {
924        console.log('clicked prev');
925        e.preventDefault();
926        prevBtn_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
927    });
928    window[listingID + '_ulScrollObj'].on('scroll', function(e) {
929        console.log('scrolled');
930        updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
931    });
932    updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
933}
934
935function build_nav_assets_script_js(listingID, listingName) {
936    window[listingID + '_mainObj'] = jQuery( listingName );
937    window[listingID + '_ulScrollObj'] = jQuery( listingName + ' .event-assets' );
938    window[listingID + '_ulWrapObj'] = jQuery( listingName + ' .assets-wrapper' );
939    window[listingID + '_ulObj'] = jQuery( listingName + ' .assets-wrapper ul.assets-list' );
940    window[listingID + '_next'] = jQuery( listingName + ' .nav-arrow a.next' );
941    window[listingID + '_prev'] = jQuery( listingName + ' .nav-arrow a.prev' );
942    window[listingID + '_next'].on('click', function(e) {
943        console.log('clicked next');
944        e.preventDefault();
945        nextBtn_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
946    });
947    window[listingID + '_prev'].on('click', function(e) {
948        console.log('clicked prev');
949        e.preventDefault();
950        prevBtn_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
951    });
952    window[listingID + '_ulScrollObj'].on('scroll', function(e) {
953        console.log('scrolled');
954        updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
955    });
956    updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
957}
958
959function addTourListFilterAction(name, show_nav, listingID) {
960    var alink = jQuery('.hbg-display-tour-listing.' + name + ' ul.filter-list li a.detach-filter').on('click', function(e) {
961        e.preventDefault();
962        jQuery('.hbg-display-tour-listing.' + name + ' ul.filter-list li a.detach-filter').removeClass('active');
963        jQuery(this).addClass('active');
964        var filterName = jQuery(this).attr('data-class');
965        jQuery('.hbg-display-tour-listing.' + name + ' .glisting-content.nav ul.glisting li.glisting-item').addClass('hide');
966        jQuery('.hbg-display-tour-listing.' + name + ' .glisting-container .loading-event').fadeIn( 'slow', function() {
967            jQuery('.hbg-display-tour-listing.' + name + ' .glisting-content.nav').attr('style', '');
968            jQuery('.hbg-display-tour-listing.' + name + ' .glisting-container .loading-event').fadeOut( 'slow', function() {
969                if(filterName !== '') {
970                    jQuery('.hbg-display-tour-listing.' + name + ' .glisting-content.nav ul.glisting li.glisting-item.' + filterName).removeClass('hide');
971                } else {
972                    jQuery('.hbg-display-tour-listing.' + name + ' .glisting-content.nav ul.glisting li.glisting-item').removeClass('hide');
973                }
974                if(show_nav) {
975                    updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
976                }
977            });
978        });
979    });
980}
981
982function prepareImgWrapWithSlider() {
983    var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
984
985    if (id.length > 0) {
986        jQuery('#' + id + '.img-wrap.with-slider a.prev').on('click', function (e) {
987            e.preventDefault();
988            var wrapperID = jQuery(this).attr('wrapper-id');
989            var curSlide = parseInt(jQuery('#' + wrapperID).attr('slider-cur'));
990            var curNextSlide = parseInt(jQuery('#' + wrapperID).attr('slider-next'));
991            var maxSlide = parseInt(jQuery('#' + wrapperID).attr('slider-max'));
992
993            if (curSlide === curNextSlide) {
994                var nextSlide = curSlide - 1;
995
996                if (nextSlide <= 0) {
997                    nextSlide = maxSlide;
998                }
999
1000                jQuery('#' + wrapperID).attr('slider-next', nextSlide);
1001                sliderActionRight(wrapperID, curSlide, nextSlide, maxSlide);
1002            }
1003        });
1004        jQuery('#' + id + '.img-wrap.with-slider a.next').on('click', function (e) {
1005            e.preventDefault();
1006            var wrapperID = jQuery(this).attr('wrapper-id');
1007            var curSlide = parseInt(jQuery('#' + wrapperID).attr('slider-cur'));
1008            var curNextSlide = parseInt(jQuery('#' + wrapperID).attr('slider-next'));
1009            var maxSlide = parseInt(jQuery('#' + wrapperID).attr('slider-max'));
1010
1011            if (curSlide === curNextSlide) {
1012                var nextSlide = curSlide + 1;
1013
1014                if (nextSlide > maxSlide) {
1015                    nextSlide = 1;
1016                }
1017
1018                jQuery('#' + wrapperID).attr('slider-next', nextSlide);
1019                sliderActionLeft(wrapperID, curSlide, nextSlide, maxSlide);
1020            }
1021        });
1022        jQuery('#' + id + '.img-wrap.with-slider a.radio').on('click', function (e) {
1023            e.preventDefault();
1024            var wrapperID = jQuery(this).attr('wrapper-id');
1025            var curSlide = parseInt(jQuery('#' + wrapperID).attr('slider-cur'));
1026            var curNextSlide = parseInt(jQuery('#' + wrapperID).attr('slider-next'));
1027            var maxSlide = parseInt(jQuery('#' + wrapperID).attr('slider-max'));
1028            var nextSlide = jQuery(this).attr('slide-id');
1029
1030            if (curSlide === curNextSlide && curSlide != nextSlide) {
1031                if (curSlide < nextSlide) {
1032                    jQuery('#' + wrapperID).attr('slider-next', nextSlide);
1033                    sliderActionLeft(wrapperID, curSlide, nextSlide, maxSlide);
1034                } else {
1035                    jQuery('#' + wrapperID).attr('slider-next', nextSlide);
1036                    sliderActionRight(wrapperID, curSlide, nextSlide, maxSlide);
1037                }
1038            }
1039        });
1040    }
1041}
1042
1043function topFunction() {
1044    document.body.scrollTop = 0; // For Safari
1045
1046    document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
1047}
1048
1049function gravityFormRearrange(bObj) {
1050    gBody = jQuery(bObj).find('div.gform_body'); //console.log('calling gravityFormRearrange',bObj);
1051
1052    if (gBody) {
1053        jQuery(gBody).find('ul.gform_fields li.gfield').each(function () {
1054            var labelTag = jQuery(this).find('label');
1055            var divTag = jQuery(this).find('div.ginput_container');
1056
1057            if (divTag.hasClass('ginput_container_text') || divTag.hasClass('ginput_container_phone') || divTag.hasClass('ginput_container_email') || divTag.hasClass('ginput_container_textarea')) {
1058                divTag.addClass('mui-textfield mui-textfield--float-label');
1059                divTag.append(labelTag);
1060            } else if (divTag.hasClass('ginput_container_select')) {
1061                divTag.addClass('mui-select');
1062                divTag.append(labelTag);
1063            } else if (divTag.hasClass('ginput_container_date')) {
1064                //divTag.addClass('mui-textfield');
1065                //divTag.append(labelTag);
1066            }
1067
1068        });
1069    }
1070}
1071
1072function populateFleets() {
1073    var fleets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1074    var excludeList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1075    var maxCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1076    var max_show_onload = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1077    //console.log('populateFleets');
1078    var fleetsObj = {
1079        listing: []
1080    };
1081    var maxFleetCount = maxCount === 0 ? fleets.length : fleets.length <= maxCount ? fleets.length : maxCount;
1082    exArr = excludeList.split(',');
1083    max_show_onload = max_show_onload === 0 ? maxFleetCount : max_show_onload;
1084
1085    for (idx = 0; idx < maxFleetCount; idx++) {
1086        var localFleet = fleets[idx];
1087
1088        if (exArr.indexOf(localFleet.id) == -1) {
1089            /*
1090            localFleet.fleet_images = (localFleet.media || []);
1091            localFleet.noMedia = (localFleet.media.images.length ? false : true);
1092            localFleet.no_image = localFleet.noMedia;
1093            localFleet.has_image = !localFleet.no_image;
1094            localFleet.slider_max = localFleet.media.images.length;
1095            for(j=0;j<localFleet.media.images.length;j++) {
1096                localFleet.media.images[j].slide_num = j + 1;
1097                localFleet.media.images[j].active = (j == 0 ? 'active' : '');
1098            }
1099            localFleet.slider_id = localFleet.id;
1100            localFleet.item_link = (localFleet.vesselDetails.permalink || '');
1101            localFleet.item_name = (localFleet.translations.en.name || 'No Title');
1102            localFleet.description = (localFleet.translations.en.description || '');
1103            localFleet.shortDescription = (localFleet.translations.en.shortDescription || '');
1104            localFleet.fleet_overview = localFleet.shortDescription.replace(/<(?:.|\n)*?>/gm, '');
1105            localFleet.has_fleet_data = true;
1106            if(!localFleet.no_image) {
1107                localFleet.item_image = localFleet.media.images[0].url;
1108            }
1109            delete localFleet.media;
1110            localFleet.buffetMealsCapacity = (localFleet.vesselDetails.buffetMealsCapacity || 0);
1111            localFleet.cocktailsCapacity = (localFleet.vesselDetails.cocktailsCapacity || 0);
1112            localFleet.seatedMealsCapacity = (localFleet.vesselDetails.seatedMealsCapacity || 0);
1113            localFleet.fleet_capacity = 'CAPACITY: UP TO ' + Math.max(localFleet.buffetMealsCapacity, localFleet.cocktailsCapacity, localFleet.seatedMealsCapacity) + ' GUESTS';
1114            */
1115            localFleet.show_after_click_btn = max_show_onload < fleetsObj.listing.length + 1;
1116            fleetsObj.listing.push(populateFleet(localFleet));
1117        }
1118    } //console.log('fleetsObj.listing',fleetsObj.listing);
1119
1120
1121    return fleetsObj;
1122}
1123
1124function populateFleet() {
1125    var fleet = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1126    //console.log('fleetfleetfleetfleetfleetfleetfleetfleet', fleet);
1127    var fleetObj = fleet;
1128
1129    if (!jQuery.isEmptyObject(fleet)) {
1130        fleetObj.fleet_has_image = fleetObj.media.images.length > 0;
1131        fleetObj.has_image = fleetObj.fleet_has_image;
1132        fleetObj.fleet_has_video = fleetObj.media.videos.length > 0;
1133        fleetObj.fleet_has_virtual = fleetObj.media.virtualTour.length > 0;
1134
1135        for (i = 0; i < fleetObj.media.images.length; i++) {
1136            fleetObj.media.images[i].item_num = i + 1;
1137            fleetObj.media.images[i].active = i == 0 ? 'active' : '';
1138            fleetObj.media.images[i].item_image = fleetObj.media.images[i].url;
1139        }
1140
1141        for (k = 0; k < fleetObj.media.videos.length; k++) {
1142            fleetObj.media.videos[k].item_num = k + 1;
1143            fleetObj.media.videos[k].active = k == 0 ? 'active' : '';
1144            fleetObj.media.videos[k].video_url = jQuery(fleetObj.media.videos[k].url).attr('src');
1145        }
1146
1147        fleetObj.item_name = fleetObj.translations.en.name || 'No Title';
1148        fleetObj.fleet_main_images = fleetObj.media.images;
1149        fleetObj.fleet_main_image = fleetObj.media.images.length > 0 ? fleetObj.media.images.slice(0, 1) : {};
1150        fleetObj.fleet_additional_images = fleetObj.media.images.slice(1, fleetObj.media.images.length);
1151        fleetObj.main_id = 'main-' + fleetObj.id;
1152        fleetObj.main_max_image = fleetObj.media.images.length;
1153        fleetObj.has_deck = fleetObj.decks.length > 0 ? true : false;
1154        fleetObj.item_link = fleetObj.details.permalink || '';
1155        fleetObj.buffetMealsCapacity = fleetObj.details.buffetMealsCapacity || 0;
1156        fleetObj.cocktailsCapacity = fleetObj.details.cocktailsCapacity || 0;
1157        fleetObj.seatedMealsCapacity = fleetObj.details.seatedMealsCapacity || 0;
1158        fleetObj.has_buffetMealsCapacity = fleetObj.details.buffetMealsCapacity != null || false;
1159        fleetObj.has_cocktailsCapacity = fleetObj.details.cocktailsCapacity != null || false;
1160        fleetObj.has_seatedMealsCapacity = fleetObj.details.seatedMealsCapacity != null || false;
1161        fleetObj.fleet_capacity = 'CAPACITY: UP TO ' + Math.max(fleetObj.buffetMealsCapacity, fleetObj.cocktailsCapacity, fleetObj.seatedMealsCapacity) + ' GUESTS';
1162        fleetObj.slider_id = fleetObj.id;
1163        fleetObj.shortDescription = fleetObj.translations.en.shortDescription || '';
1164        fleetObj.description = fleetObj.translations.en.description || '';
1165        fleetObj.reviews = fleetObj.translations.en.reviews || '';
1166        fleetObj.fleet_overview = fleetObj.shortDescription.replace(/<(?:.|\n)*?>/gm, '');
1167        fleetObj.fleet_clean_desc = fleetObj.description.replace(/<(?:.|\n)*?>/gm, '');
1168        fleetObj.fleet_has_shortDescription = fleetObj.shortDescription.length ? true : false;
1169        fleetObj.fleet_has_description = fleetObj.description.length ? true : false;
1170        fleetObj.fleet_has_reviews = fleetObj.reviews.length ? true : false;
1171        fleetObj.has_fleet_data = true;
1172
1173        for (j = 0; j < fleetObj.decks.length; j++) {
1174            fleetObj.decks[j].active = j == 0 ? 'active' : '';
1175            fleetObj.decks[j].show = j == 0 ? 'in' : '';
1176            fleetObj.decks[j].odd_row = j % 2 ? false : true;
1177            fleetObj.decks[j].even_row = !fleetObj.decks[j].odd_row;
1178            fleetObj.decks[j].deck_has_media = fleetObj.decks[j].media.images.length > 0;
1179
1180            for (k = 0; k < fleetObj.decks[j].media.images.length; k++) {
1181                fleetObj.decks[j].media.images[k].item_num = k + 1;
1182                fleetObj.decks[j].media.images[k].active = k == 0 ? 'active' : '';
1183                fleetObj.decks[j].media.images[k].item_image = fleetObj.decks[j].media.images[k].url;
1184            }
1185
1186            fleetObj.decks[j].deck_has_video = fleetObj.decks[j].media.videos.length > 0;
1187
1188            for (l = 0; l < fleetObj.decks[j].media.videos.length; l++) {
1189                fleetObj.decks[j].media.videos[l].item_num = l + 1;
1190                fleetObj.decks[j].media.videos[l].active = l == 0 ? 'active' : '';
1191                fleetObj.decks[j].media.videos[l].video_url = jQuery(fleetObj.media.videos[l].url).attr('src');
1192            }
1193
1194            fleetObj.decks[j].deck_has_virtual = fleetObj.decks[j].media.virtualTour.length > 0;
1195            fleetObj.decks[j].deck_media = fleetObj.decks[j].media;
1196            fleetObj.decks[j].deck_has_buffetMealsCapacity = fleetObj.decks[j].details.buffetMealsCapacity != null || false;
1197            fleetObj.decks[j].deck_has_cocktailsCapacity = fleetObj.decks[j].details.cocktailsCapacity != null || false;
1198            fleetObj.decks[j].deck_has_seatedMealsCapacity = fleetObj.decks[j].details.seatedMealsCapacity != null || false;
1199            delete fleetObj.decks[j].media;
1200        }
1201
1202        fleetObj.fleet_media = fleetObj.media;
1203        delete fleetObj.media;
1204    } //console.log('fleetObj',fleetObj);
1205
1206
1207    return fleetObj;
1208}
1209
1210function sliderActionLeft(id, cur, final, max) {
1211    var slideLen = jQuery('#' + id).width();
1212    var next = cur + 1;
1213
1214    if (next > max) {
1215        next = 1;
1216    }
1217
1218    jQuery('#' + id + ' .slide-wrapper.slide-' + next).addClass('next');
1219    jQuery('#' + id + ' .slide-wrapper.slide-' + cur).animate({
1220        "left": '-=' + slideLen,
1221        "easing": "linear"
1222    }, 700, function () {
1223        jQuery('#' + id).attr('slider-cur', next);
1224        jQuery('#' + id + ' .slide-wrapper.slide-' + cur).removeClass('active').attr('style', '');
1225        jQuery('#' + id + ' .slide-wrapper.slide-' + next).addClass('active').removeClass('next');
1226        updateRadioSlider(id, next);
1227
1228        if (next < final) {
1229            sliderActionLeft(id, next, final, max);
1230        }
1231    });
1232}
1233
1234function sliderActionRight(id, cur, final, max) {
1235    var slideLen = jQuery('#' + id).width();
1236    var next = cur - 1;
1237
1238    if (next <= 0) {
1239        next = max;
1240    }
1241
1242    jQuery('#' + id + ' .slide-wrapper.slide-' + next).addClass('active').attr('style', 'left: -' + slideLen + 'px');
1243    jQuery('#' + id + ' .slide-wrapper.slide-' + cur).removeClass('active').addClass('next');
1244    jQuery('#' + id + ' .slide-wrapper.slide-' + next).animate({
1245        "left": '+=' + slideLen,
1246        "easing": "linear"
1247    }, 700, function () {
1248        jQuery('#' + id).attr('slider-cur', next);
1249        jQuery('#' + id + ' .slide-wrapper.slide-' + cur).removeClass('next');
1250        updateRadioSlider(id, next);
1251
1252        if (next > final) {
1253            sliderActionRight(id, next, final, max);
1254        }
1255    });
1256}
1257
1258function updateRadioSlider(id, active) {
1259    jQuery('#' + id + ' .nav-radio a.radio').removeClass('active');
1260    jQuery('#' + id + ' .nav-radio a.radio.radio-' + active).addClass('active');
1261    jQuery('#' + id + ' .thumb-wrapper a.radio').removeClass('active');
1262    jQuery('#' + id + ' .thumb-wrapper a.radio.radio-' + active).addClass('active');
1263}
1264
1265function returnAllPortName() {
1266    var portNames = [];
1267    portNames['hbmdr'] = 'Marina del Rey';
1268    portNames['hbsf'] = 'San Francisco';
1269    portNames['hbber'] = 'Berkeley';
1270    portNames['hblb'] = 'Long Beach';
1271    portNames['hbsd'] = 'San Diego';
1272    portNames['hbnpb'] = 'Newport Beach';
1273    portNames['hbsac'] = 'Sacramento';
1274    portNames['hbny'] = 'New York';
1275    return portNames;
1276}
1277
1278function rearrangePortList() {
1279    var portList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1280    var arrangedPortList = [];
1281    var socal = ['hbmdr', 'hblb', 'hbnpb'];
1282    var norcal = ['hbsf', 'hbber', 'hbsac'];
1283
1284    if (socal.includes(portList[0].id)) {
1285        var mainSocalPort = 'hbmdr';
1286
1287        if (portList[0].id != mainSocalPort && portList[1].id == mainSocalPort) {
1288            var tmpPort = portList[0];
1289            portList[0] = portList[1];
1290            portList[1] = tmpPort;
1291        } else if (portList[0].id != mainSocalPort && portList[2].id == mainSocalPort) {
1292            var tmpPort = portList[0];
1293            portList[0] = portList[2];
1294            portList[2] = tmpPort;
1295        }
1296    }
1297
1298    if (norcal.includes(portList[0].id)) {
1299        var mainNorcalPort = 'hbsf';
1300
1301        if (portList[0].id != mainNorcalPort && portList[1].id == mainNorcalPort) {
1302            var tmpPort = portList[0];
1303            portList[0] = portList[1];
1304            portList[1] = tmpPort;
1305        } else if (portList[0].id != mainNorcalPort && portList[2].id == mainNorcalPort) {
1306            var tmpPort = portList[0];
1307            portList[0] = portList[2];
1308            portList[2] = tmpPort;
1309        }
1310    }
1311
1312    return portList;
1313}
1314
1315function assignListingByTagList() {
1316    var listing = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1317    var tagList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1318    var newListing = [];
1319
1320    for (tagIdx = 0; tagIdx < tagList.length; tagIdx++) {
1321        curLTagName = tagList[tagIdx].ltag_name;
1322        newListing[tagIdx] = {
1323            listing: [],
1324            tag_id: tagList[tagIdx].tag_id,
1325            tag_name: tagList[tagIdx].tag_name,
1326            tag_code: tagList[tagIdx].tag_code,
1327            ltag_name: tagList[tagIdx].ltag_name
1328        };
1329
1330        for (listIdx = 0; listIdx < listing.length; listIdx++) {
1331            var thisCatArr = (listing[listIdx].categories || '').split(",");
1332            if(thisCatArr.includes(curLTagName)) {
1333                newListing[tagIdx].listing.push(listing[listIdx]);
1334            }
1335        }
1336
1337        newListing[tagIdx].port_has_data = newListing[tagIdx].listing.length > 0;
1338    }
1339
1340    return newListing;
1341}
1342
1343function generateTagList() {
1344    var tagList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1345    var tagProp = [];
1346    //var portNames = returnAllPortName();
1347    var tagNames = [];
1348    var thisPortName = '';
1349
1350    for (idx = 0; idx < tagList.length; idx++) {
1351        tagProp[idx] = {
1352            tag_name: tagList[idx].tag_name,
1353            tag_code: tagList[idx].tag_code,
1354            ltag_name: tagList[idx].tag_name.toLowerCase(),
1355            tag_id: tagList[idx].tag_id
1356        };
1357    }
1358    //console.log('tagProptagProptagProptagProp',tagProp);
1359
1360    return tagProp;
1361}
1362
1363function dateSelectionButton(id, dropId) {
1364    jQuery('button#'+id).on('click', function() {
1365        location.href = jQuery('#'+dropId).val();
1366    });
1367}
1368
1369function enableDepartureMonths(data) {
1370    //months-wrapper
1371    //console.log('data enableDepartureMonths', data);
1372    for(var mIdx=0; mIdx < data.length; mIdx++) {
1373        jQuery('a.select-departure-month[data-role='+data[mIdx]+']').removeClass('disabled');
1374    }
1375}
1376
1377function selectedDepartureMonth(selMonth) {
1378    //console.log('selMonth',selMonth);
1379    if(selMonth != null && selMonth.length && !jQuery('a.select-departure-month[data-role='+selMonth+']').hasClass('disabled')) {
1380        jQuery('a.select-departure-month[data-role='+selMonth+']').addClass('selected');
1381    }
1382}
1383
1384function enableTriggerSelectDepartureMonth() {
1385    jQuery('a.select-departure-month').on('click', function(e) {
1386        e.preventDefault();
1387        if(!jQuery(this).hasClass('disabled')) {
1388            var thisClicked = jQuery(this).attr('data-role');
1389            var thisHide = jQuery(this).hasClass('selected') ? true : false;
1390            if(thisHide) {
1391                jQuery('div[data-myear='+thisClicked+']').addClass('hide');
1392                jQuery(this).removeClass('selected');
1393            } else {
1394                jQuery('div[data-myear='+thisClicked+']').removeClass('hide');
1395                jQuery(this).addClass('selected');
1396            }
1397        }
1398    });
1399}
1400
1401function triggerNavLinkShortcut() {
1402    jQuery('a.nav-link-shortcut').on('click', function(e) {
1403        e.preventDefault();
1404        //if (this.hash !== "" && jQuery(this.hash).length) {
1405        console.log(this.hash);
1406        //jQuery(this.hash).tab('show');
1407        jQuery('#myTab a[href="'+this.hash+'"]').tab('show')
1408    });
1409}
1410
1411function getUrlVars() {
1412    var vars = {};
1413    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
1414        vars[key] = value;
1415    });
1416    return vars;
1417}
1418
1419function getUrlParam(parameter, defaultvalue){
1420    var urlparameter = defaultvalue;
1421    if(window.location.href.indexOf(parameter) > -1){
1422        urlparameter = getUrlVars()[parameter];
1423    }
1424    return urlparameter;
1425}
1426
1427function mergeDownListing(filterArr) {
1428    var newFilterArr = [];
1429    var keysArr = Object.keys(filterArr);
1430    for(var keyIdx=0; keyIdx < keysArr.length; keyIdx++) {
1431        newFilterArr = newFilterArr.concat(filterArr[keysArr[keyIdx]]);
1432    }
1433    //console.log('newFilterArr',newFilterArr);
1434    return newFilterArr;
1435}
1436
1437function filterByPromotion(filterArr, usePromoID, promoID) {
1438    var promoArr = [];
1439    for(var idx=0; idx < filterArr.length; idx++) {
1440        if( (filterArr[idx]['has_promotion'] && !usePromoID) || (usePromoID && filterArr[idx]['has_promotion'] && filterArr[idx]['promotions'].includes(promoID)) ) {
1441            promoArr.push(filterArr[idx]);
1442        }
1443    }
1444    //console.log('promoID', promoID);
1445    //console.log('promoArr', promoArr);
1446    return promoArr;
1447}
1448
1449function filterListingByBookingID(allArr, filterArr, hasDateParam) {
1450    //console.log('allArr',allArr);
1451    //console.log('filterArr',filterArr);
1452    var allByBookingID = [];
1453    for(var allIdx=0; allIdx < allArr.length; allIdx++) {
1454        allByBookingID[allArr[allIdx].bookingTypeId] = allArr[allIdx];
1455    }
1456    //console.log('allByBookingID',allByBookingID);
1457    var newArr = [];
1458    var filterArr2 = [];
1459    for(var filterIdx=0; filterIdx < filterArr.length; filterIdx++) {
1460        filterArr[filterIdx] = jQuery.extend( filterArr[filterIdx], allByBookingID[filterArr[filterIdx].booking_type_id] );
1461        filterArr[filterIdx]['depart_date_sort'] = filterArr[filterIdx]['depart_date'].phpdate;
1462    }
1463    filterArr = filterArr.sort(function (a, b) {
1464        var numberToSortA = a.depart_date_sort === null ? 0 : parseInt(a.depart_date_sort);
1465        var numberToSortB = b.depart_date_sort === null ? 0 : parseInt(b.depart_date_sort);
1466        return numberToSortA - numberToSortB;
1467    });
1468    return filterArr;
1469}
1470
1471function populateMonthsAndSelected(selObj, selMonth) {
1472    //console.log('selObj',selObj);
1473    //console.log('selMonth',selMonth);
1474    var now = new Date();
1475    var thisMonth = now.getMonth() + 1;
1476    var thisYear = now.getFullYear();
1477    var dateVal = '';
1478    var dateStr = '';
1479    for(var monthIdx=0; monthIdx < 24; monthIdx++) {
1480        if(thisMonth == 13) {
1481            thisMonth = 1;
1482            thisYear += 1;
1483        }
1484        dateStr = monthsLZ[thisMonth] + ' ' + thisYear;
1485        dateVal = thisYear + '-' + (thisMonth < 10 ? '0' + thisMonth : thisMonth);
1486        selObj.append(new Option(dateStr, dateVal, selMonth===dateVal, selMonth===dateVal));
1487        thisMonth += 1;
1488    }
1489}
1490
1491function addOnClickAnchor(id) {
1492	//console.log('addOnClickAnchor', id);
1493    jQuery( '#' + id + ' a.anchor-to-deck' ).on('click', function(e) {
1494        e.preventDefault();
1495        if (this.hash !== "") {
1496            //console.log('jQuery(this.hash)',jQuery(this.hash));
1497            jQuery('html, body').animate({
1498                scrollTop: jQuery(this.hash).offset().top - document.getElementById('masthead').offsetHeight - 50
1499            }, 800, function(e){
1500            });
1501        }
1502    });
1503}
1504
1505function generateTopInAppBannerHTML_local(bannerObj) {
1506	var topBannerHTML = '';
1507	if (bannerObj.length) {
1508		topBannerHTML += '<div class="container">';
1509		topBannerHTML += '<div class="banner-text-wrapper">';
1510		for(var i=0; i < bannerObj.length; i++) {
1511			var thisInAppObj = bannerObj[i];
1512			topBannerHTML += '<div class="each-inApp-notification">' + thisInAppObj.notificationBody + '</div>';
1513		}
1514		topBannerHTML += '</div>';
1515		topBannerHTML += '</div>';
1516		jQuery('div.top-banner-wrapper').removeClass('hide');
1517	}
1518	jQuery('div.top-banner-wrapper').html(topBannerHTML);
1519	jQuery('.followWrap').attr('style','height: '+jQuery('header').height()+'px;');
1520}
1521
1522/* BEGIN PHOTO GALLERY LIGHTBOX */
1523//photoGallery
1524function openGalleryModal() {
1525	document.getElementById("photoGallery").style.display = "block";
1526}
1527
1528// Close the Modal
1529function closeGalleryModal() {
1530	document.getElementById("photoGallery").style.display = "none";
1531}
1532
1533var slideIndex = 1;
1534if(document.getElementsByClassName("photoGallerySlides").length) {
1535	showGallerySlides(slideIndex);	
1536}
1537
1538// Next/previous controls
1539function plusGallerySlides(n) {
1540	showGallerySlides(slideIndex += n);
1541}
1542
1543// Thumbnail image controls
1544function currentGallerySlide(n) {
1545	showGallerySlides(slideIndex = n);
1546}
1547
1548function showGallerySlides(n) {
1549	var i;
1550	var slides = document.getElementsByClassName("photoGallerySlides");
1551	var localIndex = slideIndex;
1552	//var dots = document.getElementsByClassName("demo");
1553	var captionText = document.getElementById("galleryCaption");
1554	if (n > slides.length) {localIndex = 1}
1555	if (n < 1) {localIndex = slides.length}
1556	for (i = 0; i < slides.length; i++) {
1557		slides[i].style.display = "none";
1558	}
1559	/*for (i = 0; i < dots.length; i++) {
1560		dots[i].className = dots[i].className.replace(" active", "");
1561	}*/
1562	slides[localIndex-1].style.display = "block";
1563	//dots[slideIndex-1].className += " active";
1564	captionText.innerHTML = slides[localIndex-1].getAttribute('caption');
1565}
1566/* END PHOTO GALLERY LIGHTBOX */
1567
1568/* BEGIN PHOTO GALLERY LIGHTBOX */
1569//photoGallery2
1570function openGalleryModal2() {
1571	document.getElementById("photoGallery2").style.display = "block";
1572}
1573
1574// Close the Modal
1575function closeGalleryModal2() {
1576	document.getElementById("photoGallery2").style.display = "none";
1577}
1578
1579var slideIndex2 = 1;
1580if(document.getElementsByClassName("photoGallerySlides2").length) {
1581	showGallerySlides2(slideIndex2);
1582}
1583
1584// Next/previous controls
1585function plusGallerySlides2(n) {
1586	showGallerySlides2(slideIndex2 += n);
1587}
1588
1589// Thumbnail image controls
1590function currentGallerySlide2(n) {
1591	showGallerySlides2(slideIndex2 = n);
1592}
1593
1594function showGallerySlides2(n) {
1595	var i;
1596	var slides = document.getElementsByClassName("photoGallerySlides2");
1597	var localIndex = slideIndex2;
1598	//var dots = document.getElementsByClassName("demo");
1599	var captionText = document.getElementById("galleryCaption2");
1600	if (n > slides.length) {localIndex = 1}
1601	if (n < 1) {localIndex = slides.length}
1602	for (i = 0; i < slides.length; i++) {
1603		slides[i].style.display = "none";
1604	}
1605	/*for (i = 0; i < dots.length; i++) {
1606		dots[i].className = dots[i].className.replace(" active", "");
1607	}*/
1608	slides[localIndex-1].style.display = "block";
1609	//dots[slideIndex-1].className += " active";
1610	captionText.innerHTML = slides[localIndex-1].getAttribute('caption');
1611}
1612/* END PHOTO GALLERY LIGHTBOX */
1613
1614/* BEGIN PHOTO GALLERY LIGHTBOX */
1615//photoGallery3
1616function openGalleryModal3() {
1617	document.getElementById("photoGallery3").style.display = "block";
1618}
1619
1620// Close the Modal
1621function closeGalleryModal3() {
1622	document.getElementById("photoGallery3").style.display = "none";
1623}
1624
1625var slideIndex3 = 1;
1626if(document.getElementsByClassName("photoGallerySlides3").length) {
1627	showGallerySlides3(slideIndex3);
1628}
1629
1630// Next/previous controls
1631function plusGallerySlides3(n) {
1632	showGallerySlides3(slideIndex3 += n);
1633}
1634
1635// Thumbnail image controls
1636function currentGallerySlide3(n) {
1637	showGallerySlides3(slideIndex3 = n);
1638}
1639
1640function showGallerySlides3(n) {
1641	var i;
1642	var slides = document.getElementsByClassName("photoGallerySlides3");
1643	var localIndex = slideIndex3;
1644	//var dots = document.getElementsByClassName("demo");
1645	var captionText = document.getElementById("galleryCaption3");
1646	if (n > slides.length) {localIndex = 1}
1647	if (n < 1) {localIndex = slides.length}
1648	for (i = 0; i < slides.length; i++) {
1649		slides[i].style.display = "none";
1650	}
1651	/*for (i = 0; i < dots.length; i++) {
1652		dots[i].className = dots[i].className.replace(" active", "");
1653	}*/
1654	slides[localIndex-1].style.display = "block";
1655	//dots[slideIndex-1].className += " active";
1656	captionText.innerHTML = slides[localIndex-1].getAttribute('caption');
1657}
1658/* END PHOTO GALLERY LIGHTBOX */
1659
1660/* BEGIN PHOTO GALLERY LIGHTBOX */
1661//photoGallery4
1662function openGalleryModal4() {
1663	document.getElementById("photoGallery4").style.display = "block";
1664}
1665
1666// Close the Modal
1667function closeGalleryModal4() {
1668	document.getElementById("photoGallery4").style.display = "none";
1669}
1670
1671var slideIndex4 = 1;
1672if(document.getElementsByClassName("photoGallerySlides4").length) {
1673	showGallerySlides4(slideIndex4);
1674}
1675
1676// Next/previous controls
1677function plusGallerySlides4(n) {
1678	showGallerySlides4(slideIndex4 += n);
1679}
1680
1681// Thumbnail image controls
1682function currentGallerySlide4(n) {
1683	showGallerySlides4(slideIndex4 = n);
1684}
1685
1686function showGallerySlides4(n) {
1687	var i;
1688	var slides = document.getElementsByClassName("photoGallerySlides4");
1689	var localIndex = slideIndex4;
1690	//var dots = document.getElementsByClassName("demo");
1691	var captionText = document.getElementById("galleryCaption4");
1692	if (n > slides.length) {localIndex = 1}
1693	if (n < 1) {localIndex = slides.length}
1694	for (i = 0; i < slides.length; i++) {
1695		slides[i].style.display = "none";
1696	}
1697	/*for (i = 0; i < dots.length; i++) {
1698		dots[i].className = dots[i].className.replace(" active", "");
1699	}*/
1700	slides[localIndex-1].style.display = "block";
1701	//dots[slideIndex-1].className += " active";
1702	captionText.innerHTML = slides[localIndex-1].getAttribute('caption');
1703}
1704/* END PHOTO GALLERY LIGHTBOX */
1705
1706/* BEGIN PHOTO GALLERY LIGHTBOX */
1707//photoGallery4
1708function openGalleryModal5() {
1709	document.getElementById("photoGallery5").style.display = "block";
1710}
1711
1712// Close the Modal
1713function closeGalleryModal5() {
1714	document.getElementById("photoGallery5").style.display = "none";
1715}
1716
1717var slideIndex5 = 1;
1718if(document.getElementsByClassName("photoGallerySlides5").length) {
1719	showGallerySlides5(slideIndex5);
1720}
1721
1722// Next/previous controls
1723function plusGallerySlides5(n) {
1724	showGallerySlides5(slideIndex5 += n);
1725}
1726
1727// Thumbnail image controls
1728function currentGallerySlide5(n) {
1729	showGallerySlides5(slideIndex5 = n);
1730}
1731
1732function showGallerySlides5(n) {
1733	var i;
1734	var slides = document.getElementsByClassName("photoGallerySlides5");
1735	var localIndex = slideIndex5;
1736	//var dots = document.getElementsByClassName("demo");
1737	var captionText = document.getElementById("galleryCaption5");
1738	if (n > slides.length) {localIndex = 1}
1739	if (n < 1) {localIndex = slides.length}
1740	for (i = 0; i < slides.length; i++) {
1741		slides[i].style.display = "none";
1742	}
1743	/*for (i = 0; i < dots.length; i++) {
1744		dots[i].className = dots[i].className.replace(" active", "");
1745	}*/
1746	slides[localIndex-1].style.display = "block";
1747	//dots[slideIndex-1].className += " active";
1748	captionText.innerHTML = slides[localIndex-1].getAttribute('caption');
1749}
1750/* END PHOTO GALLERY LIGHTBOX */
1751
1752function update_cart_count_in_nav() {
1753	var cartTotal = getCartCount();
1754	if(cartTotal > 0) {
1755		jQuery('.cart-item').html(cartTotal).addClass('has-item');
1756	}
1757}
1758
1759function go_to_shopping_cart() {
1760	location.href = '/shopping-cart/';
1761}
1762
1763function displayMobileCalendar_custom(data, isMerged) {
1764	var thisHtml = '';
1765	console.log('displayMobileCalendar_custom', {data, isMerged});
1766	if(true || isMerged) {
1767		thisHtml += '<div class="cal-title-wrapper">' + data.title + '</div>';
1768		thisHtml += '<div class="show-times">';
1769		for(var tIdx = 0; tIdx < (data.timeSlot || []).length; tIdx++) {
1770			var thisTimeSlot = data.timeSlot[tIdx];
1771			var thisTimeSlodIsSoldOut = thisTimeSlot.isSoldOut;
1772			if(thisTimeSlodIsSoldOut) {
1773				thisHtml += '<span class="btn-primary ' + (thisTimeSlodIsSoldOut ? 'sold-out-showtime' : '') + '" href="'+thisTimeSlot.showUrl+'">' + thisTimeSlot.sTime + ' - Sold Out' + '</span>';
1774			} else {
1775				thisHtml += '<a class="btn-primary" href="'+thisTimeSlot.showUrl+'">' + thisTimeSlot.sTime+'</a>';
1776			}
1777		}
1778		thisHtml += '</div>';
1779	} else {
1780		thisHtml += '<div class="cal-title-wrapper">' + data.title + '</div>';
1781		var keyIds = Object.keys(data.timeSlots).sort()
1782		for(var i = 0; i < (keyIds || []).length; i++) {
1783			var eachData = data.timeSlots[keyIds[i]];
1784			thisHtml += '<div class="cal-info-each">';
1785			thisHtml += '<div class="cal-depart-wrapper">' + eachData.departure + '</div>';
1786			thisHtml += '<div class="show-times">';
1787			for(var j = 0; j < (eachData.timeSlot || []).length; j++) {
1788				var thisTimeSlot = eachData.timeSlot[j];
1789				var thisTimeSlodIsSoldOut = thisTimeSlot.isSoldOut;
1790				if(thisTimeSlodIsSoldOut) {
1791					thisHtml += '<span class="btn-primary ' + (thisTimeSlodIsSoldOut ? 'sold-out-showtime' : '') + '" href="'+thisTimeSlot.showUrl+'">' + thisTimeSlot.sTime + ' - Sold Out' + '</span>';
1792				} else {
1793					thisHtml += '<a class="btn-primary" href="'+thisTimeSlot.showUrl+'">' + thisTimeSlot.sTime+'</a>';
1794				}
1795			}
1796			thisHtml += '</div>';
1797			thisHtml += '</div>';
1798		}
1799	}
1800	return thisHtml;
1801}
1802
1803function clickedCalDate_custom(data) {
1804	//console.log('clickedCalDate_custom', data);
1805	var thisHtml = calendarDayRenderCustom(data, false);
1806	return thisHtml;
1807}
1808
1809function calendarDayRenderCustom(data, settings = {}, isDesktopView = true) {
1810	var thisHtml = '';
1811	var toursKeys = Object.keys(data.tours || []).sort();
1812	//console.log('calendarDayRenderCustom11', {data,toursKeys});
1813	if(toursKeys.length) {
1814		if(isDesktopView) {
1815			thisHtml += '<a href="#" data-id="'+data.dateStr+'" class="cal-date-mobile date-'+data.dateStr+'" data-show-date="'+data.dateStr2+'"><span class=""></span></a>';
1816		}
1817		thisHtml += '<div class="cal-tours-wrapper">';
1818		for(var i = 0; i < toursKeys.length; i++) {
1819			var tourInfo = data.tours[toursKeys[i]];
1820			var tourDeparts = tourInfo.departure || [];
1821			var departKeys = Object.keys(tourDeparts);
1822			//console.log('tourInfo', {tourInfo, tourDeparts, departKeys});
1823			if(departKeys.length) {
1824				thisHtml += '<div class="cal-tour-wrapper">';
1825				thisHtml += '<h4 class="cal-tour-title">' + tourInfo.title + '</h4>';
1826				for(var j = 0; j < departKeys.length; j++) {
1827					var eachDepart = tourDeparts[departKeys[j]];
1828					var departTimeslots = eachDepart.timeSlot || [];
1829					if(departTimeslots.length) {
1830						thisHtml += '<div class="cal-depart-wrapper">';
1831						if(eachDepart.departure !== undefined) {
1832							var trimmedEventRank = eachDepart.eventRank.trim();
1833							var departureStr = 'From ' + eachDepart.departure + ' to ' + eachDepart.destination;
1834							thisHtml += '<div class="cal-depart-title">' + departureStr + '</div>';
1835						}
1836						thisHtml += '<div class="cal-timeslot-wrapper">';
1837						for(var k = 0; k < departTimeslots.length; k++) {
1838							var eachTimeslot = departTimeslots[k];
1839							var timeSlotTag = 'a';
1840							if(eachTimeslot.isSoldOut) {
1841								timeSlotTag = 'span';
1842							}
1843							thisHtml += '<'+timeSlotTag+' class="cal-timeslot '+ (eachTimeslot.isSoldOut ? ' sold-out ' : '') +'" href="'+eachTimeslot.showUrl+'">' + eachTimeslot.sTime + (eachTimeslot.isSoldOut ? ' - Sold Out' : '') + '</'+timeSlotTag+'>';
1844						}
1845						thisHtml += '</div>';
1846						thisHtml += '</div>';
1847					}
1848				}
1849				thisHtml += '</div>';
1850			}
1851		}
1852		thisHtml += '</div>';
1853	}
1854	return thisHtml;
1855}
1856
1857function loadShowByDateCustom(showsByDate) {
1858	var newShowsByDate = [];
1859	var foundDateBookId = [];
1860	var dateKeys = Object.keys(showsByDate);
1861	for(var i = 0; i < dateKeys.length; i++) {
1862		var thisDate = dateKeys[i];
1863		var thisDateArr = thisDate.split('-');
1864		var thisDate2 = thisDateArr[1] + '/' + thisDateArr[2] + '/' + thisDateArr[0];
1865		var thisDateTours = showsByDate[thisDate];
1866		if(newShowsByDate[thisDate] === undefined) {
1867			newShowsByDate[thisDate] = {
1868				"start": thisDate + 'T00:00:01',
1869				"dateStr": thisDate,
1870				"dateStr2": thisDate2,
1871				"tours": { }
1872			}
1873		}
1874		for(var j = 0; j < thisDateTours.length; j++) {
1875			var thisDateTour = thisDateTours[j];
1876			var thisEpochTime = thisDateTour.epochTime;
1877			var thisBookId = thisDateTour.bookingTypeId;
1878			var thisFromStopId = thisDateTour.fromStopId;
1879			var thisTitle = thisDateTour.title;
1880			var tourWithEpoch = thisEpochTime + '-' + thisBookId;
1881			var tourEpochWithFromStopId = thisEpochTime + '-' + thisBookId + '-' + thisFromStopId;
1882			if(foundDateBookId[thisDate+'-'+thisBookId] === undefined) {
1883				foundDateBookId[thisDate+'-'+thisBookId] = tourWithEpoch;
1884			}
1885			var tourWithEpochMap = foundDateBookId[thisDate+'-'+thisBookId];
1886			if(newShowsByDate[thisDate].tours[tourWithEpochMap] === undefined) {
1887				newShowsByDate[thisDate].tours[tourWithEpochMap] = { 
1888					"title": thisTitle,
1889					"departure": { }
1890				};
1891			}
1892			if(newShowsByDate[thisDate].tours[tourWithEpochMap]['departure'][tourEpochWithFromStopId] === undefined) {
1893				newShowsByDate[thisDate].tours[tourWithEpochMap]['departure'][tourEpochWithFromStopId] = thisDateTour;
1894			}
1895		}
1896		//console.log('thisDate', thisDate, thisDateTours, foundDateBookId, newShowsByDate[thisDate]);
1897	}
1898	//console.log('loadShowByDateCustom', {dateKeys,showsByDate,newShowsByDate});
1899	return newShowsByDate;
1900}
1901
1902
1903/*function clickedCalDate(dateStr) {
1904	var linkObj = jQuery('.cal-date-mobile.date-'+dateStr);
1905	var isMerged = linkObj.attr('data-merge') === 'true';
1906	var thisData = loadedShowByDate[dateStr] || [];
1907	var thisHtml = '';
1908	var thisDateStr = linkObj.attr('data-show-date');
1909	jQuery('.hbg-cal-mobile-info-wrapper').addClass('open');
1910	if(!linkObj.hasClass('selected')) {
1911		jQuery('.cal-date-mobile').removeClass('selected');
1912		linkObj.addClass('selected');
1913		for(var idx = 0; idx < thisData.length; idx++) {
1914			thisHtml += '<div class="cal-info-wrapper">';
1915			thisHtml += displayMobileCalendar(thisData[idx], isMerged);
1916			thisHtml += '</div>';
1917		}
1918		//console.log('clickedCalDate', {dateStr,isMerged,thisData});
1919		jQuery('.hbg-cal-mobile-info .hbg-cal-mobile-info-date').html(thisDateStr);
1920		jQuery('.hbg-cal-mobile-info .hbg-cal-mobile-info-list').html(thisHtml);
1921	}
1922}*/
1923
1924(function ($) {
1925    'use strict';
1926
1927    $(document).ready(function () {
1928
1929        /*$('select#switchCitiesRedirect').on('change', function() {
1930            var selected = $(this).val();
1931            if(selected !== '') {
1932                location.href = selected;
1933            }
1934        });
1935        $("#datepicker-cruise-mobile").datepicker({
1936            autoclose: true,
1937            todayHighlight: true,
1938            orientation: "auto left",
1939            startDate: new Date(),
1940            clearBtn: true,
1941        }).datepicker('', new Date());*/
1942
1943        $(document).on('click', '[data-toggle="lightbox"]', function (event) {
1944            event.preventDefault();
1945            $(this).ekkoLightbox({
1946                alwaysShowClose: true
1947            });
1948        });
1949
1950        /*$('select[name=region-drop]').on('change', function() {
1951            location.href = $(this).val();
1952        });
1953
1954        $('.itinerary-main .itinerary-days .itin-day').on('click', function() {
1955            $('.itinerary-main .itinerary-days .itin-day').removeClass('selected');
1956            $(this).addClass('selected');
1957            var dataRole = $(this).attr('data-role');
1958            console.log(dataRole);
1959        });
1960
1961        $('select.redirect-url-value-select').on('change', function(e) {
1962            if($(this).val() !== '') {
1963                location.href = $(this).val();
1964            }
1965        });
1966
1967        $('button.search-bar-button').on('click', function(evt) {
1968            evt.preventDefault();
1969            var redirectURL = $('select#destination-mobile').val() + '?selMonth=' + $('select#datepicker-cruise').val();
1970            //console.log('redirectURL',redirectURL);
1971            location.href = redirectURL;
1972        });
1973		
1974		$('a.close-top-header-banner').on('click', function(e) {
1975			e.preventDefault();
1976			$('.top-download-app-wrapper').addClass('hide');
1977			updateHeaderHeight($('.followWrap'), $('header'))
1978		});*/
1979		
1980		$('.faq-collapsible').on('click', function(e) {
1981			var thisId = $(this).attr('data-id');
1982			if(!$('#'+thisId+'.hbg-block-content.faq-homepage').hasClass('open')) {
1983				$('.hbg-block-content.faq-homepage').removeClass('open');
1984				$('#'+thisId+'.hbg-block-content.faq-homepage').addClass('open')
1985			}
1986		});
1987		
1988		if($('.homepage-review-container').length) {
1989			$('.homepage-review-container .wpb_wrapper').slick({
1990				slidesToShow: 1,
1991				slidesToScroll: 1,
1992				arrows: true,
1993				dots: true
1994			});
1995		}
1996		
1997		$('a.mobile-close').on('click', function(e) {
1998			e.preventDefault();
1999			$('body').removeClass('onepress-menu-mobile-opening');
2000			$('nav .onepress-menu').removeClass('onepress-menu-mobile');
2001			$('#nav-toggle').removeClass('nav-is-visible');
2002		});
2003		
2004		$('button.btn-close').on('click', function(e) {
2005			e.preventDefault();
2006			var modalId = $(this).attr('data-bs-id');
2007			$('#'+modalId).modal('toggle');
2008		});
2009		
2010		var tagIdUrl = getUrlParam('tagId', '');
2011		if(tagIdUrl.length) {
2012			console.log('aaa', tagIdUrl, document.getElementById(tagIdUrl));
2013			jQuery('html, body').animate({
2014                scrollTop: document.getElementById(tagIdUrl).offsetTop - 50
2015            }, 800, function(e){
2016            });
2017		}
2018		
2019		update_cart_count_in_nav();
2020		
2021    });
2022})(jQuery);
2023
2024

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.