PageSourceSearch

https://www.blueandgoldfleet.com/wp-content/themes/blueandgoldflee…?ver=191370674dbc32ab2cf66563d23acedb

js blueandgoldfleet.com collected 2026-09-25 20:26:37 UTC 73,206 bytes, 1,604 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 signWaiverInlineStyle = {
37	".header.waiverPageFont": {
38        "display": "none !important"
39    },
40};
41
42var allTranslations = ['ar','da','de','el','es','fr','he','hi','it','ja','ko','ms','nl','pt','ru','sw','tr','vi','zh'];
43
44function plusSlides(slideId, n) {
45    //window['slide_' + slideId] += n;
46    hbShowSlides(slideId, window['slide_' + slideId] += n);
47}
48
49function currentSlide(slideId, n) {
50    //window['slide_' + slideId] = n;
51    hbShowSlides(slideId, window['slide_' + slideId] = n);
52}
53
54function hbShowSlides(id, n) {
55    var slides = jQuery('.hbSlides[data-id='+id+']');
56    var dots = jQuery('.hb-dot[data-id='+id+']');
57    if (n > slides.length) {window['slide_' + id] = 1}
58    if (n < 1) {window['slide_' + id] = slides.length}
59    slides.attr('style', 'display: none;').removeClass('show');
60    for (var i = 0; i < dots.length; i++) {
61        dots[i].className = dots[i].className.replace(" active", "");
62    }
63    jQuery(slides[window['slide_' + id]-1]).attr('style', 'display: block;').addClass('show');
64    jQuery(dots).removeClass('active');
65    jQuery(dots[window['slide_' + id]-1]).addClass('active');;
66}
67
68function prepareHBSlideImages(id, slideIndex) {
69    window['slide_' + id] = slideIndex;
70    hbShowSlides(id, slideIndex);
71}
72
73function getPageTranslation() {
74    var thisPath = window.location.pathname.split('/');
75    var thisPath = jQuery.map( thisPath, function(v){
76        return v === "" ? null : v;
77    });
78    if(thisPath.length === 0) {
79        return 'en';
80    } else {
81        if(allTranslations.includes(thisPath[0])) {
82            //console.log('found',thisPath[0]);
83            return thisPath[0];
84        } else {
85            return 'en';
86        }
87    }
88}
89
90function updateHeaderHeight(el, head) {
91    console.log('el', el.height());
92    console.log('head', head.height());
93    if(el.height() < head.height()) {
94        el.attr('style','height:'+head.height()+'px;');
95    }
96}
97
98function populateDefaultTour(obj) {
99    var selTour = '';
100    //selTour = '/tour-options/alcatraz-day-tour/';
101    //selTour = '/tour-options/alcatraz-night-tour/';
102    //selTour = '/tour-options/alcatraz-behind-the-scenes-tour/';
103    //selTour = '/tour-options/alcatraz-angel-island-combo-tour/';
104    if(selTour.length > 0) obj.val(selTour);
105}
106
107function buildPaginationList(tot, cur, cName) {
108    var paginationHTML = '';
109    paginationHTML += '<ul>';
110    for(var pIdx=0; pIdx < tot; pIdx++) {
111        var thisIdx = pIdx + 1;
112        paginationHTML += '<li class="page-'+thisIdx+'">';
113        paginationHTML += '<a href="" class="'+cName+' '+(thisIdx === cur ? 'selected' : '')+'" role-num="'+thisIdx+'">'+thisIdx+'</a>';
114        paginationHTML += '</li>';
115    }
116    paginationHTML += '</ul>';
117    return paginationHTML;
118}
119
120function assignIframeClassW(iframeID) {
121    var iframeW = jQuery('iframe#'+iframeID).width();
122    //console.log('iframeW',iframeW);
123    var selClass = '';
124    if(iframeW < 500) {
125        selClassNum = 'sm';
126    } else if (iframeW >= 500) {
127        selClassNum = 'md';
128    }
129    jQuery('iframe#'+iframeID).attr('data-size',selClassNum);
130}
131
132function setCookie(cname, cvalue, exdays) {
133    var d = new Date();
134    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
135    var expires = "expires="+d.toUTCString();
136    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
137}
138
139function getCookie(cname) {
140    var name = cname + "=";
141    var ca = document.cookie.split(';');
142    for(var i = 0; i < ca.length; i++) {
143        var c = ca[i];
144        while (c.charAt(0) == ' ') {
145            c = c.substring(1);
146        }
147        if (c.indexOf(name) == 0) {
148            return c.substring(name.length, c.length);
149        }
150    }
151    return "";
152}
153
154function checkCookie() {
155    var user = getCookie("username");
156    if (user != "") {
157        alert("Welcome again " + user);
158    } else {
159        user = prompt("Please enter your name:", "");
160        if (user != "" && user != null) {
161            setCookie("username", user, 365);
162        }
163    }
164}
165
166function getElementProp_listing(obj) {
167    var elProp = [];
168    if (obj.length) {
169        var pos = obj.position();
170        elProp['posX'] = pos.left;
171        elProp['posY'] = pos.top;
172        elProp['w'] = obj.width();
173        elProp['h'] = obj.height();
174    }
175
176    return elProp;
177}
178
179function updateExpNav_listing(mainObj, ulWrap, ulObj, prevObj, nextObj) {
180    var expList = getElementProp_listing(ulWrap);
181    var listLen = ulObj.width();
182    var screenXsize = mainObj.width();
183    //ulWrap.attr('style', 'left:'+expList['posX']+'px; width:'+listLen+'px;');
184    if (listLen <= screenXsize - expList['posX']) {
185        nextObj.addClass('hide');
186    } else if (expList['w'] > screenXsize) {
187        nextObj.removeClass('hide');
188    }
189
190    if (expList['posX'] < 0) {
191        prevObj.removeClass('hide');
192    } else {
193        prevObj.addClass('hide');
194    }
195}
196
197function isJson(str) {
198    try {
199        JSON.parse(str);
200    } catch (e) {
201        return false;
202    }
203    return true;
204}
205
206function nextBtn_listing(mainObj, ulWrap, ulObj, prevObj, nextObj) {
207    var screenXsize = mainObj.width();
208    var listLen = ulObj.width();
209    var expList = getElementProp_listing(ulWrap);
210    var nextLeft = -(expList.posX - screenXsize);
211    console.log('screenXsize',screenXsize);
212    console.log('listLen',listLen);
213    console.log('expList',expList);
214    console.log('nextLeft',nextLeft);
215    nextLeft = nextLeft + screenXsize > listLen ? listLen - screenXsize : nextLeft;
216    console.log('nextLeft',nextLeft);
217    ulWrap.animate({
218        left: -nextLeft
219    }, 800, function () {
220        console.log('done animation');
221        updateExpNav_listing(mainObj, ulWrap, ulObj, prevObj, nextObj);
222    });
223}
224
225function prevBtn_listing(mainObj, ulWrap, ulObj, prevObj, nextObj) {
226    var screenXsize = mainObj.width();
227    var listLen = ulObj.width();
228    var expList = getElementProp_listing(ulWrap);
229    var nextRight = expList.posX + screenXsize > 0 ? 0 : expList.posX + screenXsize;
230    nextRight = nextRight > 0 ? 0 : nextRight;
231    ulWrap.animate({
232        left: nextRight
233    }, 800, function () {
234        updateExpNav_listing(mainObj, ulWrap, ulObj, prevObj, nextObj);
235    });
236}
237
238function calculateToShowFiller(mainObj, liDataObj, liFillerObj) {
239    var item_per_row = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2;
240    var allDataCount = liDataObj.length;
241    var allHiddenDataCount = 0; //liDataObj.attr('class','hide').length;
242
243    jQuery(liDataObj).each(function (liItem) {
244        allHiddenDataCount += jQuery(this).hasClass('hide') ? 1 : 0;
245    });
246    var allShowDataCount = allDataCount - allHiddenDataCount;
247    var fillerMax = liFillerObj.length;
248    var modVal = allShowDataCount % item_per_row;
249    var needFillerCount = allShowDataCount == 0 ? item_per_row : modVal ? item_per_row - modVal : modVal; //console.log('allDataCount',allDataCount);
250    //console.log('allHiddenDataCount',allHiddenDataCount);
251    //console.log('allShowDataCount',allShowDataCount);
252    //console.log('fillerMax',fillerMax);
253    //console.log('item_per_row',item_per_row);
254
255    var fillerIdx = [];
256
257    for (var idx = 0; idx < needFillerCount; idx++) {
258        fillerIdx = getAvailableIndex(fillerIdx, fillerMax);
259    } //console.log('fillerIdx',fillerIdx);
260
261
262    for (var fidx = 0; fidx < fillerIdx.length; fidx++) {
263        jQuery(liFillerObj).each(function (tx) {
264            //console.log('tx',tx,'fidx',fillerIdx[fidx]);
265            if (tx + 1 == fillerIdx[fidx]) {
266                //console.log('tx',tx);
267                jQuery(this).removeClass('hide');
268            }
269        });
270    }
271
272    ;
273}
274
275function getTodayDate() {
276    var today = new Date();
277    var dd = String(today.getDate()).padStart(2, '0');
278    var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
279    var yyyy = today.getFullYear();
280
281    return mm + '/' + dd + '/' + yyyy;
282}
283
284function getTodayDateOrUrlParam(urlParam) {
285    var selUrlParam = decodeURIComponent(getUrlParam(urlParam,''));
286    var today = new Date();
287    var dd = String(today.getDate()).padStart(2, '0');
288    var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
289    var yyyy = today.getFullYear();
290
291    return selUrlParam.length ? selUrlParam : mm + '/' + dd + '/' + yyyy;
292}
293
294function getAvailableIndex(existing, max) {
295    var found = false;
296    var maxIter = 10;
297    var curIter = 0;
298    var nextNum = 0;
299
300    while (!found && curIter < maxIter) {
301        nextNum = Math.floor(Math.random() * 1000000 % max) + 1;
302
303        if (existing.indexOf(nextNum) < 0) {
304            existing.push(nextNum);
305            found = true;
306            curIter = maxIter;
307        }
308
309        curIter++;
310    }
311
312    if (!found) {
313        for (idx = 0; idx < max; idx++) {
314            if (existing.indexOf(idx) < 0) {
315                existing.push(idx);
316                idx = max;
317            }
318        }
319    }
320
321    return existing;
322}
323
324function removeActiveFilterByClass(filterClass) {
325    jQuery('.' + filterClass).removeClass('active');
326}
327
328function hideAllListItemsByElement() {
329    for (i = 0; i < arguments.length; i++) {
330        jQuery(arguments[i]).addClass('hide');
331    }
332}
333
334function showAllListItemsByClass(liObj, cName) {
335    jQuery(liObj).each(function () {
336        if (cName == '' || jQuery(this).hasClass(cName)) {
337            jQuery(this).removeClass('hide');
338        }
339    });
340}
341
342function populateTour(tour,lang) {
343    var tourObj = {};
344    var thisLang = lang === undefined ? 'en' : lang;
345    //console.log('thisLangthisLang',thisLang);
346    if(tour.unavailable.length) {
347        tourObj = tour.unavailable[0];
348        var localizedEnLang = tourObj.localizedInfo['en'];
349        var localizedLang = tourObj.localizedInfo[thisLang] || localizedEnLang;
350        //console.log('localizedLanglocalizedLang',localizedLang);
351        tourObj.title = localizedLang.title || localizedEnLang.title || 'No Title';
352        tourObj.overview = localizedLang.description || localizedEnLang.description || "";
353        tourObj.whatUget = localizedLang.whatYouGet || localizedEnLang.whatYouGet || "";
354        tourObj.schedule = localizedLang.schedule || localizedEnLang.schedule || "";
355        tourObj.whereToMeet = localizedLang.whereToMeet || localizedEnLang.whereToMeet || "";
356        tourObj.dressCode = localizedLang.dressCode || localizedEnLang.dressCode || "";
357
358        tourObj.has_whereToMeet = tourObj.whereToMeet.length > 0;
359        tourObj.has_whatUget = tourObj.whatUget.length > 0;
360        tourObj.has_schedule = tourObj.schedule.length > 0;
361        tourObj.has_dressCode = tourObj.dressCode.length > 0;
362
363		tourObj.video = (tourObj.media.videos.length ? tourObj.media.videos[0].url : '');
364        tourObj.has_video = (tourObj.media.videos.length ? true : false);
365        tourObj.address = (tourObj.settings['address.formatted'] || '');
366        tourObj.additional_assets = [];
367        tourObj.additional_assets_no_map = [];
368        tourObj.lat = tourObj.settings['address.latitude'];
369        tourObj.lon = tourObj.settings['address.longitude'];
370        tourObj.has_main_image = false;
371
372        tourObj.review = (tourObj.settings.review || "");
373        //tourObj.overview = (tourObj.overview.length ? '<h2>Overview</h2>' + tourObj.overview : "");
374        //tourObj.whatUget = (tourObj.whatUget.length ? '<h2>Includes</h2>' + tourObj.whatUget : "");
375        //tourObj.schedule = (tourObj.schedule.length ? '<h2>Schedule</h2>' + tourObj.schedule : "");
376        //tourObj.whereToMeet = (tourObj.whereToMeet.length ? '<h2>Where to Meet</h2>' + tourObj.whereToMeet : "");
377        //tourObj.dressCode = (tourObj.dressCode.length ? '<h2>Dress Code</h2>' + tourObj.dressCode : "");
378        tourObj.has_review = (tourObj.review.length ? true : false);
379
380        var mainImageIndex = 0;
381        tourObj.has_prime_image = !tourObj.has_video;
382        tourObj.has_main_image = false;
383        if(tourObj.media.images.length && tourObj.has_prime_image) {
384            tourObj.prime_image_url = tourObj.media.images[0].url;
385            mainImageIndex++;
386        }
387
388        if(tourObj.media.images.length > mainImageIndex) {
389            tourObj.main_image_url = tourObj.media.images[mainImageIndex].url;
390            tourObj.main_image_index = mainImageIndex + 1;
391            tourObj.has_main_image = true;
392        }
393			
394		tourObj.liCategories = convertCategories(tourObj.categories || '');
395		if (tourObj.schedule.length) {
396    let _schedule = tourObj.schedule.replace("</p><p>", " / ").replace("<p>", "").replace("</p>", "").split(" / ");
397    if(_schedule.length == 2 && _schedule[0].split(" - ").length == 2 && _schedule[1].split("Time - ").length == 2){
398        tourObj.schedule = { boardingTime: _schedule[0].split(" - ")[1], cruiseTime: _schedule[1].split("Time - ")[1] };
399    }
400    else{
401        tourObj.schedule = false;
402    }
403}
404
405if (tourObj.liCategories.length) {
406    let _cats = tourObj.liCategories, 
407        _catsArr = _cats.split(" ");
408
409    tourObj.childCruisePrice = _catsArr.filter(e => e.indexOf("child-s-cruise-price") > -1);
410    tourObj.windowSeats = _catsArr.filter(e => e.indexOf("window-seats") > -1);
411
412    tourObj.childCruisePrice = tourObj.childCruisePrice.length ? tourObj.childCruisePrice[0].split("---")[1] : "$0.00";
413    tourObj.windowSeats = tourObj.windowSeats.length ? tourObj.windowSeats[0].split("---")[1] : "$0.00";
414}
415
416        //console.log('mainImageIndex',mainImageIndex);
417        var shiftIndex = tour.is_experiences ? 0 : 1;
418        tourObj.max_image_assets = tourObj.media.images.length;
419        for(var idx=mainImageIndex;idx < tourObj.media.images.length; idx+=2) {
420            var add_images = { top: '', top_image_assets: '', bottom: '', bottom_image_assets: '', has_bottom: false};
421            if(idx < tourObj.media.images.length) {
422                add_images.top = tourObj.media.images[idx].url;
423                add_images.top_image_assets = idx + 1;
424            }
425            if(idx + 1 < tourObj.media.images.length) {
426                add_images.bottom = tourObj.media.images[idx+1].url;
427                add_images.bottom_image_assets = idx + 2;
428                add_images.has_bottom = true;
429            }
430            tourObj.additional_assets.push(add_images)
431        }
432    }
433    return tourObj;
434}
435
436var formatter = new Intl.NumberFormat('en-US', {
437    style: 'currency',
438    currency: 'USD',
439});
440
441function getItineraryDayPort(itinObj, dayNum) {
442    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': [] } };
443    var thisPort = itinObj.length > (dayNum-1) ? itinObj[dayNum-1].port : itinObj[itinObj.length-1].port;
444    var thisExcursion = itinObj.length > (dayNum-1) ? itinObj[dayNum-1].excursions : itinObj[itinObj.length-1].excursions;
445    //console.log('itinObj',itinObj);
446    //console.log('thisPort',thisPort);
447    portObj.port_id = thisPort.id;
448    portObj.port_name = (thisPort.localizedInfo.en !== undefined && thisPort.localizedInfo.en.portName) || '';
449    portObj.port_link = '';
450    portObj.port_image = thisPort.media.images[0];
451    portObj.port_content = (thisPort.localizedInfo.en !== undefined && thisPort.localizedInfo.en.portDescription) || '';
452    portObj.has_excursion = thisExcursion.length > 0;
453    portObj.excursions = thisExcursion;
454    return portObj;
455}
456
457function getDateProps(thisDate) {
458    var thisDateProp = { 'ldate': '', 'lsdate': '', 'sdate0': '', 'sdate': '', 'cdate': '', 'mdate': '', 'yydate': '', 'mmdate': '', 'dddate': '', 'phpdate': '', 'ymddate':'', 'gmtdate': '' }
459    var thisDateObj = thisDate.split('-');
460    var thisDateMM = thisDateObj[1];
461    var thisDateM = parseInt(thisDateMM);
462    var thisDateDD = thisDateObj[2];
463    var thisDateD = parseInt(thisDateDD);
464    var thisDateYYYY = thisDateObj[0];
465    var thisDateYY = thisDateYYYY.substr(-2,2);
466    thisDateProp.ldate = monthsLZ[thisDateM] + ' ' + thisDateD + ', ' + thisDateYYYY;
467    thisDateProp.lsdate = monthsSZ[thisDateM] + ' ' + thisDateD + ', ' + thisDateYYYY;
468    thisDateProp.sdate0 = thisDateMM + '/' + thisDateDD + '/' + thisDateYYYY;
469    thisDateProp.sdate = thisDateM + '/' + thisDateD + '/' + thisDateYYYY;
470    thisDateProp.cdate = thisDateM + '/' + thisDateD + '/' + thisDateYYYY;
471    thisDateProp.udate = thisDateM + '-' + thisDateD + '-' + thisDateYYYY;
472    thisDateProp.mdate = thisDateYYYY + '-' + thisDateMM;
473    thisDateProp.yydate = thisDateYYYY;
474    thisDateProp.mmdate = thisDateMM;
475    thisDateProp.dddate = thisDateDD;
476    thisDateProp.phpdate = thisDateYYYY;
477    thisDateProp.ymddate = thisDateYYYY+thisDateMM+thisDateDD;
478    thisDateProp.gmtdate = thisDate;
479    return thisDateProp;
480}
481
482function populateSdkTours(tours, selMonth) {
483    var listObj = { listing: [] };
484    //console.log('selMonth',selMonth);
485    for(var tIdx=0; tIdx < tours.length; tIdx++) {
486        var thisTour = populateSdkTour(tours[tIdx]);
487        //console.log('thisTourthisTour',thisTour);
488        var thisVesselData = thisTour.cruise_data.vessel_data;
489        for(var vIdx=0; vIdx < thisVesselData.length; vIdx++) {
490            var thisListing = { item_image: '', item_name: '', sub_title: '', description: '', depart_date: { ldate: ''}, has_sale_price: false, from_original_price_str: '', permalink: '', sailingId: 0 };
491            thisListing.item_image = thisTour.prime_image_url;
492            thisListing.item_name = thisTour.title;
493            thisListing.sub_title = thisTour.sub_title;
494            thisListing.description = thisTour.localizedInfo.en.shortDescription;
495            thisListing.permalink = thisTour.permalink;
496            thisListing.item_link = thisTour.permalink;
497            var thisVessel = thisVesselData[vIdx];
498            thisListing.itineraryName = thisVesselData[vIdx].itineraryName;
499            thisListing.sailingId = thisVesselData[vIdx].sailingID;
500            thisListing.depart_date = thisVesselData[vIdx].vessel_date;
501            thisListing.arrive_date = thisVesselData[vIdx].vessel_end_date;
502            thisListing.vessel_name = thisVesselData[vIdx].vesselName;
503            thisListing.numDays = thisVesselData[vIdx].numDays;
504            thisListing.cruise_date = thisListing.depart_date.ymddate;
505            thisListing.has_sale_price = thisVesselData[vIdx].has_startingAtSalePrice;
506            thisListing.from_original_price_str = thisVesselData[vIdx].startingFromPrice_str;
507            thisListing.from_sale_price_str = thisVesselData[vIdx].startingAtSalePrice_str;
508            thisListing.save_per_couple_str = thisVesselData[vIdx].starting_save_per_couple_str;
509            if(selMonth === '' || selMonth === thisListing.depart_date.mdate) {
510                listObj.listing.push(thisListing);
511            }
512        }
513    }
514    return listObj;
515}
516
517function populateSdkTour(tour) {
518    var tourObj = {};
519    //console.log('tourtour',tour);
520    tourObj = tour;
521    tourObj.title = (tourObj.localizedInfo.en.title || 'No Title');
522    tourObj.sub_title = (tourObj.localizedInfo.en.subTitle || '');
523    tourObj.video = (tourObj.media.videos.length ? tourObj.media.videos[0].url : '');
524    tourObj.has_video = (tourObj.media.videos.length ? true : false);
525    tourObj.address = (tourObj.settings['address.formatted'] || '');
526    tourObj.additional_assets = [];
527    tourObj.lat = tourObj.settings['address.latitude'];
528    tourObj.lon = tourObj.settings['address.longitude'];
529    tourObj.has_main_image = false;
530
531    tourObj.overview = (tourObj.localizedInfo.en.description || "");
532    tourObj.whatUget = (tourObj.localizedInfo.en.whatYouGet || "");
533    tourObj.schedule = (tourObj.localizedInfo.en.schedule || "");
534    tourObj.whereToMeet = (tourObj.localizedInfo.en.whereToMeet || "");
535    tourObj.dressCode = (tourObj.localizedInfo.en.dressCode || "");
536    tourObj.review = (tourObj.settings.review || "{}");
537    tourObj.overview = (tourObj.overview.length ? '<h2>Cruise Highlights</h2>' + tourObj.overview : "");
538    tourObj.whatUget = (tourObj.whatUget.length ? '<h2>Itinerary</h2>' + tourObj.whatUget : "");
539    tourObj.schedule = (tourObj.schedule.length ? '<h2>Schedule</h2>' + tourObj.schedule : "");
540    tourObj.whereToMeet = (tourObj.whereToMeet.length ? '<h2>Where to Meet</h2>' + tourObj.whereToMeet : "");
541    tourObj.dressCode = (tourObj.dressCode.length ? '<h2>Dress Code</h2>' + tourObj.dressCode : "");
542    tourObj.has_review = (tourObj.review.length ? true : false);
543    tourObj.listing =  JSON.parse(isJson(tourObj.review) ? tourObj.review :  '{}');
544    tourObj.total_listing = tourObj.listing.length;
545    for(var lidx=0; lidx < tourObj.listing.length; lidx++) {
546        var thisYStr = tourObj.listing[lidx].cruise_date.slice(0,4);
547        var thisMStr = tourObj.listing[lidx].cruise_date.slice(4,6).replace(/^0+/, '');
548        var thisDStr = tourObj.listing[lidx].cruise_date.slice(6,8).replace(/^0+/, '');
549        tourObj.listing[lidx].cruise_date_numeric = thisMStr+'/'+thisDStr+'/'+thisYStr;
550        tourObj.listing[lidx].cruise_date_str_long = monthsLZ[thisMStr]+' '+thisDStr+', '+thisYStr;
551        tourObj.listing[lidx].cruise_date_str_short = monthsSZ[thisMStr]+' '+thisDStr+', '+thisYStr;
552    }
553
554    var mainImageIndex = 0;
555    tourObj.has_prime_image = !tourObj.has_video;
556    tourObj.has_main_image = false;
557    if(tourObj.media.images.length && tourObj.has_prime_image) {
558        tourObj.prime_image_url = tourObj.media.images[0].url;
559        mainImageIndex++;
560    }
561
562    tourObj.max_image_assets = tourObj.media.images.length;
563    for(var idx=mainImageIndex;idx < tourObj.media.images.length; idx+=2) {
564        var add_images = { top: '', top_image_assets: '', bottom: '', bottom_image_assets: '', has_bottom: false};
565        if(idx < tourObj.media.images.length) {
566            add_images.top = tourObj.media.images[idx].url;
567            add_images.top_image_assets = idx + 1;
568        }
569        if(idx + 1 < tourObj.media.images.length) {
570            add_images.bottom = tourObj.media.images[idx+1].url;
571            add_images.bottom_image_assets = idx + 2;
572            add_images.has_bottom = true;
573        }
574        tourObj.additional_assets.push(add_images)
575    }
576    tourObj.has_menu = tourObj.menuId && tourObj.menuId.length ? true : false;
577    tourObj.has_itineraries = (tourObj.itineraries || []).length ? true : false;
578    tourObj.itinerariesData = [];
579    tourObj.portData = [];
580    tourObj.vesselData = [];
581    tourObj.cruise_data = { cruise_year: [], cruise_date: [], vessel_data: [] };
582    if(tourObj.has_itineraries) {
583        for(var itinIdx=0; itinIdx < tourObj.itineraries.length; itinIdx++) {
584            var thisItinProp = {};
585            var thisItin = tourObj.itineraries[itinIdx];
586            thisItinProp.itinID = thisItin.id;
587            thisItinProp.mapFrame = thisItin.settings.itineraryMapEmbedLink;
588            thisItinProp.has_map = (thisItinProp.mapFrame || '').length ? true : false;
589            thisItinProp.z_index = itinIdx === 0 ? 100 : 1;
590            thisItinProp.numDays = thisItin.settings.itineraryNumberOfDays;
591            thisItinProp.vesselID = thisItin.settings.vesselId;
592            thisItinProp.vessel = thisItin.vessel;
593            thisItinProp.sailing = thisItin.sailings;
594            thisItinProp.itineraryName = thisItin.localizedInfo.en.itineraryName;
595            thisItinProp.numDays = thisItin.settings.itineraryNumberOfDays;
596            thisItinProp.itineraryInternalName = thisItin.localizedInfo.en.itineraryInternalName;
597            thisItinProp.itineraryDayItem = [];
598            for(var iDayIdx=0; iDayIdx < thisItin.itineraryDayItem.length; iDayIdx++) {
599                var thisItinDay = thisItin.itineraryDayItem[iDayIdx];
600                var thisItinObj = {
601                    itineraryDayNumber: thisItinDay.settings.itineraryDayNumber,
602                    itineraryPortId: thisItinDay.settings.itineraryPortId,
603                    itineraryIncludedPortExcursions: thisItinDay.settings.itineraryIncludedPortExcursions,
604                    itineraryPremiumPortExcursions: thisItinDay.settings.itineraryPremiumPortExcursions,
605                    active: iDayIdx === 0 ? 'active' : '',
606                    show:  iDayIdx === 0 ? 'show' : '',
607                    media: thisItinDay.media,
608                    port: thisItinDay.port,
609                    excursions: thisItinDay.excursions,
610                    port_id: thisItinDay.port.id,
611                    port_name: (thisItinDay.port.localizedInfo.en !== undefined && thisItinDay.port.localizedInfo.en.portName) || '',
612                    port_int_name: (thisItinDay.port.localizedInfo.en !== undefined && thisItinDay.port.localizedInfo.en.portInternalName) || '',
613                    port_desc: (thisItinDay.port.localizedInfo.en !== undefined && thisItinDay.port.localizedInfo.en.portDescription) || '',
614                    port_image: thisItinDay.port.media.images.length ? thisItinDay.port.media.images[0].url : '',
615                    inc_excursions: [],
616                    prm_excursions: [],
617                    has_excursion: false,
618                    has_inc_exc: false,
619                    has_prm_exc: false,
620                }
621                for(var iExcIdx=0; iExcIdx < thisItinObj.excursions.length; iExcIdx++) {
622                    var thisExcursion = thisItinObj.excursions[iExcIdx];
623                    var thisExcObj = {
624                        exc_id: thisExcursion.id,
625                        exc_price_str: thisExcursion.settings.excursionDisplayPrice,
626                        exc_type: thisExcursion.settings.excursionType,
627                        exc_port_id: thisExcursion.settings.portId,
628                        exc_port_name: thisExcursion.settings.portName,
629                        exc_link: thisExcursion.settings.excursionLink,
630                        exc_name: thisExcursion.localizedInfo.en.excursionName,
631                        exc_desc: thisExcursion.localizedInfo.en.excursionDescription,
632                        exc_int_name: thisExcursion.localizedInfo.en.excursionInternalTitle,
633                        exc_image: thisExcursion.media.images.length > 0 ? thisExcursion.media.images[0].url : '',
634                        exc_has_img: thisExcursion.media.images.length > 0,
635                        exc_media: thisExcursion.media,
636                        exc_show: false,
637                    };
638                    if(thisExcObj.exc_type === 'Included') {
639                        thisExcObj.exc_idx = thisItinObj.inc_excursions.length + 1;
640                        thisExcObj.exc_show = thisItinObj.inc_excursions.length === 0;
641                        thisItinObj.inc_excursions.push(thisExcObj);
642                    } else if(thisExcObj.exc_type === 'Premium') {
643                        thisExcObj.exc_show = thisItinObj.prm_excursions.length === 0;
644                        thisExcObj.exc_idx = thisItinObj.prm_excursions.length + 1;
645                        thisItinObj.prm_excursions.push(thisExcObj);
646                    }
647                }
648                thisItinObj.has_inc_exc = thisItinObj.inc_excursions.length > 0;
649                thisItinObj.has_prm_exc = thisItinObj.prm_excursions.length > 0;
650                thisItinObj.has_excursion = thisItinObj.has_inc_exc || thisItinObj.has_prm_exc;
651                thisItinProp.itineraryDayItem.push(thisItinObj);
652            }
653            for(var iSailIdx=0; iSailIdx < thisItin.sailings.length; iSailIdx++) {
654                var thisSailingProp = {};
655                var thisSailing = thisItin.sailings[iSailIdx];
656                thisSailingProp.itineraryName = thisItinProp.itineraryName;
657                thisSailingProp.numDays = thisItinProp.numDays;
658                thisSailingProp.id = thisSailing.id;
659                thisSailingProp.voyageCode = thisSailing.settings.voyageCode;
660                thisSailingProp.sailingID = thisSailing.id;
661                thisSailingProp.vesselID = thisSailing.settings.vesselId;
662                thisSailingProp.vessel_start_date = getDateProps(thisSailing.settings.startDate);
663                thisSailingProp.vessel_date = thisSailingProp.vessel_start_date;
664                thisSailingProp.vessel_end_date = getDateProps(thisSailing.settings.endDate);
665                //thisSailingProp.startingFromPrice = thisSailing.settings.startingFromPrice;
666                //thisSailingProp.startingAtSalePrice = thisSailing.settings.startingAtSalePrice;
667
668                //thisSailingProp.startingFromPrice_str = thisSailing.settings.startingFromPrice || '';
669                thisSailingProp.startingFromPrice_str = thisSailing.settings.startingFromPrice === '' ? formatter.format(0) : formatter.format(thisSailing.settings.startingFromPrice.replace(/\$|\,/g,'').trim());
670                thisSailingProp.startingAtSalePrice_str = thisSailing.settings.startingAtSalePrice || '';
671                thisSailingProp.startingFromPrice = thisSailingProp.startingFromPrice_str.replace(/\$|\,/g,'').trim();
672                thisSailingProp.startingAtSalePrice = thisSailingProp.startingAtSalePrice_str.replace(/\$|\,/g,'').trim();
673                thisSailingProp.has_startingAtSalePrice = thisSailingProp.startingAtSalePrice.length > 0;
674                thisSailingProp.starting_save_per_couple_str = '';
675                thisSailingProp.starting_save_per_couple = 0;
676                if(thisSailingProp.has_startingAtSalePrice) {
677                    thisSailingProp.starting_save_per_couple = thisSailingProp.startingFromPrice - thisSailingProp.startingAtSalePrice;
678                    thisSailingProp.starting_save_per_couple_str = formatter.format(thisSailingProp.starting_save_per_couple);
679                }
680
681                thisSailingProp.vessel_start_port = getItineraryDayPort(thisItinProp.itineraryDayItem, 1);
682                thisSailingProp.vessel_end_port = getItineraryDayPort(thisItinProp.itineraryDayItem, thisItinProp.numDays);
683                thisSailingProp.vesselName = thisSailing.vessel.translations.en.name;
684                thisSailingProp.shortDescription = thisSailing.vessel.translations.en.shortDescription;
685                thisSailingProp.vesselMedia = thisSailing.vessel.media;
686                if(!tourObj.cruise_data.cruise_year.includes(thisSailingProp.vessel_start_date.yydate)) {
687                    tourObj.cruise_data.cruise_year.push(thisSailingProp.vessel_start_date.yydate);
688                }
689                if(!tourObj.cruise_data.cruise_date.includes(thisSailingProp.vessel_start_date.mdate)) {
690                    tourObj.cruise_data.cruise_date.push(thisSailingProp.vessel_start_date.mdate);
691                }
692                thisSailingProp.cabins = [];
693                thisSailingProp.vessel_from_original_price = "";
694                thisSailingProp.vessel_from_sale_price = "";
695                thisSailingProp.vessel_save_per_couple = "";
696                thisSailingProp.vessel_from_original_price_str = "";
697                thisSailingProp.vessel_from_sale_price_str = "";
698                thisSailingProp.vessel_save_per_couple_str = "";
699                thisSailingProp.has_vessel_from_sale_price = false;
700                for(var iCabinIdx=0; iCabinIdx < thisSailing.vessel.cabins.length; iCabinIdx++) {
701                    var thisCabin = thisSailing.vessel.cabins[iCabinIdx];
702                    var thisCabinProp = {};
703                    if(thisSailing.cabinStandardPrice[thisCabin.id] !== undefined) {
704                        thisCabinProp.id = thisCabin.id;
705                        thisCabinProp.cabin_idx = thisSailingProp.cabins.length + 1;
706                        thisCabinProp.cabin_active = thisCabinProp.cabin_idx === 1 ? true : false;
707                        thisCabinProp.cabin_id = thisCabin.id;
708                        thisCabinProp.cabin_name = thisCabin.translations.en.name;
709                        thisCabinProp.cabin_desc = thisCabin.translations.en.description;
710                        thisCabinProp.media = thisCabin.media;
711                        thisCabinProp.cabin_image = thisCabinProp.media.images.length > 0 ? thisCabinProp.media.images[0].url : '';
712                        thisCabinProp.standardPrice = thisSailing.cabinStandardPrice[thisCabin.id];
713                        thisCabinProp.salePrice = thisSailing.cabinSalePrice[thisCabin.id] || '';
714                        thisCabinProp.cabin_price_str = thisCabinProp.standardPrice.trim();
715                        thisCabinProp.cabin_price_sale_str = thisCabinProp.salePrice.trim();
716                        var thisCabinStandardPrice = thisCabinProp.cabin_price_str.replace(/\$|\,/g,'').trim();
717                        thisCabinStandardPrice = thisCabinStandardPrice.length > 0 ? parseFloat(thisCabinStandardPrice).toFixed(2) : thisCabinStandardPrice;
718                        var thisCabinSalePrice = thisCabinProp.cabin_price_sale_str.replace(/\$|\,/g,'').trim();
719                        thisCabinSalePrice = thisCabinSalePrice.length > 0 ? parseFloat(thisCabinSalePrice).toFixed(2) : thisCabinSalePrice;
720                        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)) {
721                            thisSailingProp.vessel_from_original_price = thisCabinStandardPrice;
722                            thisSailingProp.vessel_from_sale_price = thisCabinSalePrice;
723                            thisSailingProp.vessel_from_original_price_str = thisCabinProp.standardPrice.trim();
724                            thisSailingProp.vessel_from_sale_price_str = thisCabinProp.salePrice.trim();
725                            thisSailingProp.has_vessel_from_sale_price = thisSailingProp.vessel_from_sale_price.length > 0 ? true : false;
726                            if(thisSailingProp.has_vessel_from_sale_price) {
727                                thisSailingProp.vessel_save_per_couple = (thisSailingProp.vessel_from_original_price - thisSailingProp.vessel_from_sale_price) * 2;
728                                thisSailingProp.vessel_save_per_couple_str = formatter.format(thisSailingProp.vessel_save_per_couple);
729                            }
730                        }
731                        thisSailingProp.cabins.push(thisCabinProp);
732                    }
733                }
734                for(var cIdx=0; cIdx < thisSailingProp.cabins.length; cIdx++) {
735                    thisSailingProp.cabins[cIdx].prev_cabin_idx = cIdx === 0 ? thisSailingProp.cabins.length : cIdx;
736                    thisSailingProp.cabins[cIdx].next_cabin_idx = thisSailingProp.cabins.length - (cIdx + 1) > 0 ? cIdx + 2 : 1;
737                }
738                tourObj.cruise_data.vessel_data.push(thisSailingProp);
739            }
740            tourObj.itinerariesData.push(thisItinProp);
741        }
742    }
743    tourObj.cruise_data.vessel_data.sort(function (a, b) {
744        var numberToSortA = a.vessel_start_date.ymddate === null ? 0 : parseInt(a.vessel_start_date.ymddate);
745        var numberToSortB = b.vessel_start_date.ymddate === null ? 0 : parseFloat(b.vessel_start_date.ymddate);
746        return numberToSortA - numberToSortB;
747    });
748    //console.log('sortedTours',sortedTours);
749    tourObj.cruise_data.cruise_year = tourObj.cruise_data.cruise_year.sort();
750    tourObj.cruise_data.cruise_date = tourObj.cruise_data.cruise_date.sort();
751    return tourObj;
752}
753
754function populateTours() {
755    var tours = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
756    var maxCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
757    var availability = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
758    var max_show_onload = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
759    var steps_show_more = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
760    var localMyObj = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
761    var excludeList = localMyObj.exclude_list || '';
762    var lang = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'en';
763    var toursObj = {
764        listing: []
765    };
766    console.log('localMyObj',localMyObj);
767    var numberPattern = /[\d|.]+/g;
768    var tourList = availability ? tours.available : tours.unavailable;
769    var maxTourCount = maxCount === 0 ? tourList.length : tourList.length <= maxCount ? tourList.length : maxCount;
770    max_show_onload = max_show_onload === 0 ? maxTourCount : max_show_onload;
771    var excludeArr = excludeList.split(',');
772
773    for (i = 0; i < maxTourCount; i++) {
774        var localTour = tourList[i];
775		console.log('exclude', localTour.tourId, excludeArr);
776        if (excludeArr.indexOf(localTour.tourId) < 0 && !(localTour.isArchived||false)) {
777            localTour.liCategories = convertCategories(localTour.categories || '');
778            localTour.localizedInfo.en.shortDesc = (localTour.localizedInfo.en.shortDescription || '').replace(/\n/g, '<br />');
779            localTour.settings.displayPriceOnly = (localTour.settings.displayPrice || '').match(numberPattern);
780            localTour.settings.displayPriceSign = (localTour.settings.displayPrice || '').replace(localTour.settings.displayPriceOnly, '');
781            localTour.noMedia = localTour.media.images.length ? false : true;
782            localTour.hasTileMedia = localTour.media.tiles.length ? true : false;
783            localTour.slider_max = localTour.media.images.length;
784			localTour.has_no_price = localTour.settings.displayPriceOnly === null;
785
786            for (j = 0; j < localTour.media.images.length; j++) {
787                localTour.media.images[j].slide_num = j + 1;
788                localTour.media.images[j].active = j == 0 ? 'active' : '';
789            }
790
791            localTour.no_image = localTour.noMedia;
792            localTour.has_image = !localTour.no_image;
793            localTour.has_event_data = true; //localTour.use_filler = !localTour.has_event_data;
794
795			if(localTour.hasTileMedia) {
796				localTour.item_image = localTour.media.tiles[0].url;
797			} else if (!localTour.no_image) {
798                localTour.item_image = localTour.media.images[0].url;
799            }
800
801            localTour.item_link = localTour.permalink;
802
803            var localizedEnLang = localTour.localizedInfo['en'];
804            var localizedLang = localTour.localizedInfo[lang] || localizedEnLang;
805
806            localTour.item_name = localizedLang.title || localizedEnLang.title || 'No Title';
807            localTour.description = localizedLang.description || localizedEnLang.description || '';
808            localTour.overview = (localizedLang.description || localizedEnLang.description || '').replace(/<(?:.|\n)*?>/gm, '');
809            localTour.clean_desc = (localizedLang.description || localizedEnLang.description || '').replace(/<(?:.|\n)*?>/gm, '');
810            localTour.clean_schedule = (localizedLang.schedule || localizedEnLang.schedule || '').replace(/<(?:.|\n)*?>/gm, '');
811            localTour.slider_id = localTour.tourId;
812            localTour.show_after_click_btn = max_show_onload <= i;
813            localTour.tourReview = localTour.settings.review || '';
814            localTour.has_tourReview = localTour.tourReview.length ? true : false;
815			
816			if(localMyObj.settings.show_mp4_video || false) {
817				localTour.show_mp4_video = localTour.bookingTypeId === localMyObj.settings.booking_with_video_mp4;
818				
819			}
820			
821            toursObj.listing.push(localTour);
822        }
823    }
824
825    return toursObj;
826}
827
828function convertCategories(categories) {
829    var cat = [];
830    categories.split(',').map(function (category) {
831        cat.push(category.trim().replace(/ |\'/g, '-'));
832    });
833    return cat.join(' ');
834}
835
836function build_nav_script_js(listingID, listingName) {
837    window[listingID + '_mainObj'] = jQuery( listingName );
838    window[listingID + '_ulScrollObj'] = jQuery( listingName + ' .glisting-container' );
839    window[listingID + '_ulWrapObj'] = jQuery( listingName + ' .glisting-content' );
840    window[listingID + '_ulObj'] = jQuery( listingName + ' .glisting-content ul.glisting' );
841    window[listingID + '_next'] = jQuery( listingName + ' .nav-arrow a.next' );
842    window[listingID + '_prev'] = jQuery( listingName + ' .nav-arrow a.prev' );
843    window[listingID + '_next'].on('click', function(e) {
844        console.log('clicked next');
845        e.preventDefault();
846        console.log('_mainObj',window[listingID + '_mainObj']);
847        console.log('_ulScrollObj',window[listingID + '_ulScrollObj']);
848        console.log('_ulWrapObj',window[listingID + '_ulWrapObj']);
849        console.log('_ulObj',window[listingID + '_ulObj']);
850        console.log('_next',window[listingID + '_next']);
851        console.log('_prev',window[listingID + '_prev']);
852        nextBtn_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
853    });
854    window[listingID + '_prev'].on('click', function(e) {
855        console.log('clicked prev');
856        e.preventDefault();
857        prevBtn_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
858    });
859    window[listingID + '_ulScrollObj'].on('scroll', function(e) {
860        console.log('scrolled');
861        updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
862    });
863    updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
864}
865
866function build_nav_assets_script_js(listingID, listingName) {
867    window[listingID + '_mainObj'] = jQuery( listingName );
868    window[listingID + '_ulScrollObj'] = jQuery( listingName + ' .event-assets' );
869    window[listingID + '_ulWrapObj'] = jQuery( listingName + ' .assets-wrapper' );
870    window[listingID + '_ulObj'] = jQuery( listingName + ' .assets-wrapper ul.assets-list' );
871    window[listingID + '_next'] = jQuery( listingName + ' .nav-arrow a.next' );
872    window[listingID + '_prev'] = jQuery( listingName + ' .nav-arrow a.prev' );
873    window[listingID + '_next'].on('click', function(e) {
874        console.log('clicked next');
875        e.preventDefault();
876        nextBtn_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
877    });
878    window[listingID + '_prev'].on('click', function(e) {
879        console.log('clicked prev');
880        e.preventDefault();
881        prevBtn_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
882    });
883    window[listingID + '_ulScrollObj'].on('scroll', function(e) {
884        console.log('scrolled');
885        updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
886    });
887    updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
888}
889
890function addTourListFilterAction(name, show_nav, listingID) {
891    var alink = jQuery('.hbg-display-tour-listing.' + name + ' ul.filter-list li a.detach-filter').on('click', function(e) {
892        e.preventDefault();
893        jQuery('.hbg-display-tour-listing.' + name + ' ul.filter-list li a.detach-filter').removeClass('active');
894        jQuery(this).addClass('active');
895        var filterName = jQuery(this).attr('data-class');
896        jQuery('.hbg-display-tour-listing.' + name + ' .glisting-content.nav ul.glisting li.glisting-item').addClass('hide');
897        jQuery('.hbg-display-tour-listing.' + name + ' .glisting-container .loading-event').fadeIn( 'slow', function() {
898            jQuery('.hbg-display-tour-listing.' + name + ' .glisting-content.nav').attr('style', '');
899            jQuery('.hbg-display-tour-listing.' + name + ' .glisting-container .loading-event').fadeOut( 'slow', function() {
900                if(filterName !== '') {
901                    jQuery('.hbg-display-tour-listing.' + name + ' .glisting-content.nav ul.glisting li.glisting-item.' + filterName).removeClass('hide');
902                } else {
903                    jQuery('.hbg-display-tour-listing.' + name + ' .glisting-content.nav ul.glisting li.glisting-item').removeClass('hide');
904                }
905                if(show_nav) {
906                    updateExpNav_listing(window[listingID + '_mainObj'], window[listingID + '_ulWrapObj'], window[listingID + '_ulObj'], window[listingID + '_prev'], window[listingID + '_next']);
907                }
908            });
909        });
910    });
911}
912
913function prepareImgWrapWithSlider() {
914    var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
915
916    if (id.length > 0) {
917        jQuery('#' + id + '.img-wrap.with-slider a.prev').on('click', function (e) {
918            e.preventDefault();
919            var wrapperID = jQuery(this).attr('wrapper-id');
920            var curSlide = parseInt(jQuery('#' + wrapperID).attr('slider-cur'));
921            var curNextSlide = parseInt(jQuery('#' + wrapperID).attr('slider-next'));
922            var maxSlide = parseInt(jQuery('#' + wrapperID).attr('slider-max'));
923
924            if (curSlide === curNextSlide) {
925                var nextSlide = curSlide - 1;
926
927                if (nextSlide <= 0) {
928                    nextSlide = maxSlide;
929                }
930
931                jQuery('#' + wrapperID).attr('slider-next', nextSlide);
932                sliderActionRight(wrapperID, curSlide, nextSlide, maxSlide);
933            }
934        });
935        jQuery('#' + id + '.img-wrap.with-slider a.next').on('click', function (e) {
936            e.preventDefault();
937            var wrapperID = jQuery(this).attr('wrapper-id');
938            var curSlide = parseInt(jQuery('#' + wrapperID).attr('slider-cur'));
939            var curNextSlide = parseInt(jQuery('#' + wrapperID).attr('slider-next'));
940            var maxSlide = parseInt(jQuery('#' + wrapperID).attr('slider-max'));
941
942            if (curSlide === curNextSlide) {
943                var nextSlide = curSlide + 1;
944
945                if (nextSlide > maxSlide) {
946                    nextSlide = 1;
947                }
948
949                jQuery('#' + wrapperID).attr('slider-next', nextSlide);
950                sliderActionLeft(wrapperID, curSlide, nextSlide, maxSlide);
951            }
952        });
953        jQuery('#' + id + '.img-wrap.with-slider a.radio').on('click', function (e) {
954            e.preventDefault();
955            var wrapperID = jQuery(this).attr('wrapper-id');
956            var curSlide = parseInt(jQuery('#' + wrapperID).attr('slider-cur'));
957            var curNextSlide = parseInt(jQuery('#' + wrapperID).attr('slider-next'));
958            var maxSlide = parseInt(jQuery('#' + wrapperID).attr('slider-max'));
959            var nextSlide = jQuery(this).attr('slide-id');
960
961            if (curSlide === curNextSlide && curSlide != nextSlide) {
962                if (curSlide < nextSlide) {
963                    jQuery('#' + wrapperID).attr('slider-next', nextSlide);
964                    sliderActionLeft(wrapperID, curSlide, nextSlide, maxSlide);
965                } else {
966                    jQuery('#' + wrapperID).attr('slider-next', nextSlide);
967                    sliderActionRight(wrapperID, curSlide, nextSlide, maxSlide);
968                }
969            }
970        });
971    }
972}
973
974function topFunction() {
975    document.body.scrollTop = 0; // For Safari
976
977    document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
978}
979
980function gravityFormRearrange(bObj) {
981    gBody = jQuery(bObj).find('div.gform_body'); //console.log('calling gravityFormRearrange',bObj);
982
983    if (gBody) {
984        jQuery(gBody).find('ul.gform_fields li.gfield').each(function () {
985            var labelTag = jQuery(this).find('label');
986            var divTag = jQuery(this).find('div.ginput_container');
987
988            if (divTag.hasClass('ginput_container_text') || divTag.hasClass('ginput_container_phone') || divTag.hasClass('ginput_container_email') || divTag.hasClass('ginput_container_textarea')) {
989                divTag.addClass('mui-textfield mui-textfield--float-label');
990                divTag.append(labelTag);
991            } else if (divTag.hasClass('ginput_container_select')) {
992                divTag.addClass('mui-select');
993                divTag.append(labelTag);
994            } else if (divTag.hasClass('ginput_container_date')) {
995                //divTag.addClass('mui-textfield');
996                //divTag.append(labelTag);
997            }
998
999        });
1000    }
1001}
1002
1003function populateFleets() {
1004    var fleets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1005    var excludeList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1006    var maxCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1007    var max_show_onload = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1008    //console.log('populateFleets');
1009    var fleetsObj = {
1010        listing: []
1011    };
1012    var maxFleetCount = maxCount === 0 ? fleets.length : fleets.length <= maxCount ? fleets.length : maxCount;
1013    exArr = excludeList.split(',');
1014    max_show_onload = max_show_onload === 0 ? maxFleetCount : max_show_onload;
1015
1016    for (idx = 0; idx < maxFleetCount; idx++) {
1017        var localFleet = fleets[idx];
1018
1019        if (exArr.indexOf(localFleet.id) == -1) {
1020            /*
1021            localFleet.fleet_images = (localFleet.media || []);
1022            localFleet.noMedia = (localFleet.media.images.length ? false : true);
1023            localFleet.no_image = localFleet.noMedia;
1024            localFleet.has_image = !localFleet.no_image;
1025            localFleet.slider_max = localFleet.media.images.length;
1026            for(j=0;j<localFleet.media.images.length;j++) {
1027                localFleet.media.images[j].slide_num = j + 1;
1028                localFleet.media.images[j].active = (j == 0 ? 'active' : '');
1029            }
1030            localFleet.slider_id = localFleet.id;
1031            localFleet.item_link = (localFleet.vesselDetails.permalink || '');
1032            localFleet.item_name = (localFleet.translations.en.name || 'No Title');
1033            localFleet.description = (localFleet.translations.en.description || '');
1034            localFleet.shortDescription = (localFleet.translations.en.shortDescription || '');
1035            localFleet.fleet_overview = localFleet.shortDescription.replace(/<(?:.|\n)*?>/gm, '');
1036            localFleet.has_fleet_data = true;
1037            if(!localFleet.no_image) {
1038                localFleet.item_image = localFleet.media.images[0].url;
1039            }
1040            delete localFleet.media;
1041            localFleet.buffetMealsCapacity = (localFleet.vesselDetails.buffetMealsCapacity || 0);
1042            localFleet.cocktailsCapacity = (localFleet.vesselDetails.cocktailsCapacity || 0);
1043            localFleet.seatedMealsCapacity = (localFleet.vesselDetails.seatedMealsCapacity || 0);
1044            localFleet.fleet_capacity = 'CAPACITY: UP TO ' + Math.max(localFleet.buffetMealsCapacity, localFleet.cocktailsCapacity, localFleet.seatedMealsCapacity) + ' GUESTS';
1045            */
1046            localFleet.show_after_click_btn = max_show_onload < fleetsObj.listing.length + 1;
1047            fleetsObj.listing.push(populateFleet(localFleet));
1048        }
1049    } //console.log('fleetsObj.listing',fleetsObj.listing);
1050
1051
1052    return fleetsObj;
1053}
1054
1055function populateFleet() {
1056    var fleet = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1057    //console.log('fleetfleetfleetfleetfleetfleetfleetfleet', fleet);
1058    var fleetObj = fleet;
1059
1060    if (!jQuery.isEmptyObject(fleet)) {
1061        fleetObj.fleet_has_image = fleetObj.media.images.length > 0;
1062        fleetObj.has_image = fleetObj.fleet_has_image;
1063        fleetObj.fleet_has_video = fleetObj.media.videos.length > 0;
1064        fleetObj.fleet_has_virtual = fleetObj.media.virtualTour.length > 0;
1065
1066        for (i = 0; i < fleetObj.media.images.length; i++) {
1067            fleetObj.media.images[i].item_num = i + 1;
1068            fleetObj.media.images[i].active = i == 0 ? 'active' : '';
1069            fleetObj.media.images[i].item_image = fleetObj.media.images[i].url;
1070        }
1071
1072        for (k = 0; k < fleetObj.media.videos.length; k++) {
1073            fleetObj.media.videos[k].item_num = k + 1;
1074            fleetObj.media.videos[k].active = k == 0 ? 'active' : '';
1075            fleetObj.media.videos[k].video_url = jQuery(fleetObj.media.videos[k].url).attr('src');
1076        }
1077
1078        fleetObj.item_name = fleetObj.translations.en.name || 'No Title';
1079        fleetObj.fleet_main_images = fleetObj.media.images;
1080        fleetObj.fleet_main_image = fleetObj.media.images.length > 0 ? fleetObj.media.images.slice(0, 1) : {};
1081        fleetObj.fleet_additional_images = fleetObj.media.images.slice(1, fleetObj.media.images.length);
1082        fleetObj.main_id = 'main-' + fleetObj.id;
1083        fleetObj.main_max_image = fleetObj.media.images.length;
1084        fleetObj.has_deck = fleetObj.decks.length > 0 ? true : false;
1085        fleetObj.item_link = fleetObj.details.permalink || '';
1086        fleetObj.buffetMealsCapacity = fleetObj.details.buffetMealsCapacity || 0;
1087        fleetObj.cocktailsCapacity = fleetObj.details.cocktailsCapacity || 0;
1088        fleetObj.seatedMealsCapacity = fleetObj.details.seatedMealsCapacity || 0;
1089        fleetObj.has_buffetMealsCapacity = fleetObj.details.buffetMealsCapacity != null || false;
1090        fleetObj.has_cocktailsCapacity = fleetObj.details.cocktailsCapacity != null || false;
1091        fleetObj.has_seatedMealsCapacity = fleetObj.details.seatedMealsCapacity != null || false;
1092        fleetObj.fleet_capacity = 'CAPACITY: UP TO ' + Math.max(fleetObj.buffetMealsCapacity, fleetObj.cocktailsCapacity, fleetObj.seatedMealsCapacity) + ' GUESTS';
1093        fleetObj.slider_id = fleetObj.id;
1094        fleetObj.shortDescription = fleetObj.translations.en.shortDescription || '';
1095        fleetObj.description = fleetObj.translations.en.description || '';
1096        fleetObj.reviews = fleetObj.translations.en.reviews || '';
1097        fleetObj.fleet_overview = fleetObj.shortDescription.replace(/<(?:.|\n)*?>/gm, '');
1098        fleetObj.fleet_clean_desc = fleetObj.description.replace(/<(?:.|\n)*?>/gm, '');
1099        fleetObj.fleet_has_shortDescription = fleetObj.shortDescription.length ? true : false;
1100        fleetObj.fleet_has_description = fleetObj.description.length ? true : false;
1101        fleetObj.fleet_has_reviews = fleetObj.reviews.length ? true : false;
1102        fleetObj.has_fleet_data = true;
1103
1104        for (j = 0; j < fleetObj.decks.length; j++) {
1105            fleetObj.decks[j].active = j == 0 ? 'active' : '';
1106            fleetObj.decks[j].show = j == 0 ? 'in' : '';
1107            fleetObj.decks[j].odd_row = j % 2 ? false : true;
1108            fleetObj.decks[j].even_row = !fleetObj.decks[j].odd_row;
1109            fleetObj.decks[j].deck_has_media = fleetObj.decks[j].media.images.length > 0;
1110
1111            for (k = 0; k < fleetObj.decks[j].media.images.length; k++) {
1112                fleetObj.decks[j].media.images[k].item_num = k + 1;
1113                fleetObj.decks[j].media.images[k].active = k == 0 ? 'active' : '';
1114                fleetObj.decks[j].media.images[k].item_image = fleetObj.decks[j].media.images[k].url;
1115            }
1116
1117            fleetObj.decks[j].deck_has_video = fleetObj.decks[j].media.videos.length > 0;
1118
1119            for (l = 0; l < fleetObj.decks[j].media.videos.length; l++) {
1120                fleetObj.decks[j].media.videos[l].item_num = l + 1;
1121                fleetObj.decks[j].media.videos[l].active = l == 0 ? 'active' : '';
1122                fleetObj.decks[j].media.videos[l].video_url = jQuery(fleetObj.media.videos[l].url).attr('src');
1123            }
1124
1125            fleetObj.decks[j].deck_has_virtual = fleetObj.decks[j].media.virtualTour.length > 0;
1126            fleetObj.decks[j].deck_media = fleetObj.decks[j].media;
1127            fleetObj.decks[j].deck_has_buffetMealsCapacity = fleetObj.decks[j].details.buffetMealsCapacity != null || false;
1128            fleetObj.decks[j].deck_has_cocktailsCapacity = fleetObj.decks[j].details.cocktailsCapacity != null || false;
1129            fleetObj.decks[j].deck_has_seatedMealsCapacity = fleetObj.decks[j].details.seatedMealsCapacity != null || false;
1130            delete fleetObj.decks[j].media;
1131        }
1132
1133        fleetObj.fleet_media = fleetObj.media;
1134        delete fleetObj.media;
1135    } //console.log('fleetObj',fleetObj);
1136
1137
1138    return fleetObj;
1139}
1140
1141function sliderActionLeft(id, cur, final, max) {
1142    var slideLen = jQuery('#' + id).width();
1143    var next = cur + 1;
1144
1145    if (next > max) {
1146        next = 1;
1147    }
1148
1149    jQuery('#' + id + ' .slide-wrapper.slide-' + next).addClass('next');
1150    jQuery('#' + id + ' .slide-wrapper.slide-' + cur).animate({
1151        "left": '-=' + slideLen,
1152        "easing": "linear"
1153    }, 700, function () {
1154        jQuery('#' + id).attr('slider-cur', next);
1155        jQuery('#' + id + ' .slide-wrapper.slide-' + cur).removeClass('active').attr('style', '');
1156        jQuery('#' + id + ' .slide-wrapper.slide-' + next).addClass('active').removeClass('next');
1157        updateRadioSlider(id, next);
1158
1159        if (next < final) {
1160            sliderActionLeft(id, next, final, max);
1161        }
1162    });
1163}
1164
1165function sliderActionRight(id, cur, final, max) {
1166    var slideLen = jQuery('#' + id).width();
1167    var next = cur - 1;
1168
1169    if (next <= 0) {
1170        next = max;
1171    }
1172
1173    jQuery('#' + id + ' .slide-wrapper.slide-' + next).addClass('active').attr('style', 'left: -' + slideLen + 'px');
1174    jQuery('#' + id + ' .slide-wrapper.slide-' + cur).removeClass('active').addClass('next');
1175    jQuery('#' + id + ' .slide-wrapper.slide-' + next).animate({
1176        "left": '+=' + slideLen,
1177        "easing": "linear"
1178    }, 700, function () {
1179        jQuery('#' + id).attr('slider-cur', next);
1180        jQuery('#' + id + ' .slide-wrapper.slide-' + cur).removeClass('next');
1181        updateRadioSlider(id, next);
1182
1183        if (next > final) {
1184            sliderActionRight(id, next, final, max);
1185        }
1186    });
1187}
1188
1189function updateRadioSlider(id, active) {
1190    jQuery('#' + id + ' .nav-radio a.radio').removeClass('active');
1191    jQuery('#' + id + ' .nav-radio a.radio.radio-' + active).addClass('active');
1192    jQuery('#' + id + ' .thumb-wrapper a.radio').removeClass('active');
1193    jQuery('#' + id + ' .thumb-wrapper a.radio.radio-' + active).addClass('active');
1194}
1195
1196function returnAllPortName() {
1197    var portNames = [];
1198    portNames['hbmdr'] = 'Marina del Rey';
1199    portNames['hbsf'] = 'San Francisco';
1200    portNames['hbber'] = 'Berkeley';
1201    portNames['hblb'] = 'Long Beach';
1202    portNames['hbsd'] = 'San Diego';
1203    portNames['hbnpb'] = 'Newport Beach';
1204    portNames['hbsac'] = 'Sacramento';
1205    portNames['hbny'] = 'New York';
1206    return portNames;
1207}
1208
1209function rearrangePortList() {
1210    var portList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1211    var arrangedPortList = [];
1212    var socal = ['hbmdr', 'hblb', 'hbnpb'];
1213    var norcal = ['hbsf', 'hbber', 'hbsac'];
1214
1215    if (socal.includes(portList[0].id)) {
1216        var mainSocalPort = 'hbmdr';
1217
1218        if (portList[0].id != mainSocalPort && portList[1].id == mainSocalPort) {
1219            var tmpPort = portList[0];
1220            portList[0] = portList[1];
1221            portList[1] = tmpPort;
1222        } else if (portList[0].id != mainSocalPort && portList[2].id == mainSocalPort) {
1223            var tmpPort = portList[0];
1224            portList[0] = portList[2];
1225            portList[2] = tmpPort;
1226        }
1227    }
1228
1229    if (norcal.includes(portList[0].id)) {
1230        var mainNorcalPort = 'hbsf';
1231
1232        if (portList[0].id != mainNorcalPort && portList[1].id == mainNorcalPort) {
1233            var tmpPort = portList[0];
1234            portList[0] = portList[1];
1235            portList[1] = tmpPort;
1236        } else if (portList[0].id != mainNorcalPort && portList[2].id == mainNorcalPort) {
1237            var tmpPort = portList[0];
1238            portList[0] = portList[2];
1239            portList[2] = tmpPort;
1240        }
1241    }
1242
1243    return portList;
1244}
1245
1246function assignListingByTagList() {
1247    var listing = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1248    var tagList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1249    var newListing = [];
1250
1251    for (tagIdx = 0; tagIdx < tagList.length; tagIdx++) {
1252        curLTagName = tagList[tagIdx].ltag_name;
1253        newListing[tagIdx] = {
1254            listing: [],
1255            tag_id: tagList[tagIdx].tag_id,
1256            tag_name: tagList[tagIdx].tag_name,
1257            tag_code: tagList[tagIdx].tag_code,
1258            ltag_name: tagList[tagIdx].ltag_name
1259        };
1260
1261        for (listIdx = 0; listIdx < listing.length; listIdx++) {
1262            var thisCatArr = (listing[listIdx].categories || '').split(",");
1263            if(thisCatArr.includes(curLTagName)) {
1264                newListing[tagIdx].listing.push(listing[listIdx]);
1265            }
1266        }
1267
1268        newListing[tagIdx].port_has_data = newListing[tagIdx].listing.length > 0;
1269    }
1270
1271    return newListing;
1272}
1273
1274function generateTagList() {
1275    var tagList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1276    var tagProp = [];
1277    //var portNames = returnAllPortName();
1278    var tagNames = [];
1279    var thisPortName = '';
1280
1281    for (idx = 0; idx < tagList.length; idx++) {
1282        tagProp[idx] = {
1283            tag_name: tagList[idx].tag_name,
1284            tag_code: tagList[idx].tag_code,
1285            ltag_name: tagList[idx].tag_name.toLowerCase(),
1286            tag_id: tagList[idx].tag_id
1287        };
1288    }
1289    //console.log('tagProptagProptagProptagProp',tagProp);
1290
1291    return tagProp;
1292}
1293
1294function dateSelectionButton(id, dropId) {
1295    jQuery('button#'+id).on('click', function() {
1296        location.href = jQuery('#'+dropId).val();
1297    });
1298}
1299
1300function enableDepartureMonths(data) {
1301    //months-wrapper
1302    //console.log('data enableDepartureMonths', data);
1303    for(var mIdx=0; mIdx < data.length; mIdx++) {
1304        jQuery('a.select-departure-month[data-role='+data[mIdx]+']').removeClass('disabled');
1305    }
1306}
1307
1308function selectedDepartureMonth(selMonth) {
1309    //console.log('selMonth',selMonth);
1310    if(selMonth != null && selMonth.length && !jQuery('a.select-departure-month[data-role='+selMonth+']').hasClass('disabled')) {
1311        jQuery('a.select-departure-month[data-role='+selMonth+']').addClass('selected');
1312    }
1313}
1314
1315function enableTriggerSelectDepartureMonth() {
1316    jQuery('a.select-departure-month').on('click', function(e) {
1317        e.preventDefault();
1318        if(!jQuery(this).hasClass('disabled')) {
1319            var thisClicked = jQuery(this).attr('data-role');
1320            var thisHide = jQuery(this).hasClass('selected') ? true : false;
1321            if(thisHide) {
1322                jQuery('div[data-myear='+thisClicked+']').addClass('hide');
1323                jQuery(this).removeClass('selected');
1324            } else {
1325                jQuery('div[data-myear='+thisClicked+']').removeClass('hide');
1326                jQuery(this).addClass('selected');
1327            }
1328        }
1329    });
1330}
1331
1332function triggerNavLinkShortcut() {
1333    jQuery('a.nav-link-shortcut').on('click', function(e) {
1334        e.preventDefault();
1335        //if (this.hash !== "" && jQuery(this.hash).length) {
1336        console.log(this.hash);
1337        //jQuery(this.hash).tab('show');
1338        jQuery('#myTab a[href="'+this.hash+'"]').tab('show')
1339    });
1340}
1341
1342function getUrlVars() {
1343    var vars = {};
1344    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
1345        vars[key] = value;
1346    });
1347    return vars;
1348}
1349
1350function getUrlParam(parameter, defaultvalue){
1351    var urlparameter = defaultvalue;
1352    if(window.location.href.indexOf(parameter) > -1){
1353        urlparameter = getUrlVars()[parameter];
1354    }
1355    return urlparameter;
1356}
1357
1358function mergeDownListing(filterArr) {
1359    var newFilterArr = [];
1360    var keysArr = Object.keys(filterArr);
1361    for(var keyIdx=0; keyIdx < keysArr.length; keyIdx++) {
1362        newFilterArr = newFilterArr.concat(filterArr[keysArr[keyIdx]]);
1363    }
1364    //console.log('newFilterArr',newFilterArr);
1365    return newFilterArr;
1366}
1367
1368function filterByPromotion(filterArr, usePromoID, promoID) {
1369    var promoArr = [];
1370    for(var idx=0; idx < filterArr.length; idx++) {
1371        if( (filterArr[idx]['has_promotion'] && !usePromoID) || (usePromoID && filterArr[idx]['has_promotion'] && filterArr[idx]['promotions'].includes(promoID)) ) {
1372            promoArr.push(filterArr[idx]);
1373        }
1374    }
1375    //console.log('promoID', promoID);
1376    //console.log('promoArr', promoArr);
1377    return promoArr;
1378}
1379
1380function filterListingByBookingID(allArr, filterArr, hasDateParam) {
1381    //console.log('allArr',allArr);
1382    //console.log('filterArr',filterArr);
1383    var allByBookingID = [];
1384    for(var allIdx=0; allIdx < allArr.length; allIdx++) {
1385        allByBookingID[allArr[allIdx].bookingTypeId] = allArr[allIdx];
1386    }
1387    //console.log('allByBookingID',allByBookingID);
1388    var newArr = [];
1389    var filterArr2 = [];
1390    for(var filterIdx=0; filterIdx < filterArr.length; filterIdx++) {
1391        filterArr[filterIdx] = jQuery.extend( filterArr[filterIdx], allByBookingID[filterArr[filterIdx].booking_type_id] );
1392        filterArr[filterIdx]['depart_date_sort'] = filterArr[filterIdx]['depart_date'].phpdate;
1393    }
1394    filterArr = filterArr.sort(function (a, b) {
1395        var numberToSortA = a.depart_date_sort === null ? 0 : parseInt(a.depart_date_sort);
1396        var numberToSortB = b.depart_date_sort === null ? 0 : parseInt(b.depart_date_sort);
1397        return numberToSortA - numberToSortB;
1398    });
1399    return filterArr;
1400}
1401
1402function populateMonthsAndSelected(selObj, selMonth) {
1403    //console.log('selObj',selObj);
1404    //console.log('selMonth',selMonth);
1405    var now = new Date();
1406    var thisMonth = now.getMonth() + 1;
1407    var thisYear = now.getFullYear();
1408    var dateVal = '';
1409    var dateStr = '';
1410    for(var monthIdx=0; monthIdx < 24; monthIdx++) {
1411        if(thisMonth == 13) {
1412            thisMonth = 1;
1413            thisYear += 1;
1414        }
1415        dateStr = monthsLZ[thisMonth] + ' ' + thisYear;
1416        dateVal = thisYear + '-' + (thisMonth < 10 ? '0' + thisMonth : thisMonth);
1417        selObj.append(new Option(dateStr, dateVal, selMonth===dateVal, selMonth===dateVal));
1418        thisMonth += 1;
1419    }
1420}
1421
1422function addOnClickAnchor(id) {
1423    jQuery( '#' + id + ' a.anchor-to-deck' ).on('click', function(e) {
1424        e.preventDefault();
1425        if (this.hash !== "") {
1426            //console.log('jQuery(this.hash)',jQuery(this.hash));
1427            jQuery('html, body').animate({
1428                scrollTop: jQuery(this.hash).offset().top - document.getElementById('masthead').offsetHeight - 50
1429            }, 800, function(e){
1430            });
1431        }
1432    });
1433}
1434
1435function generateTopInAppBannerHTML_local(bannerObj) {
1436	var topBannerHTML = '';
1437	if (bannerObj.length) {
1438		topBannerHTML += '<div class="container">';
1439		topBannerHTML += '<div class="banner-text-wrapper">';
1440		for(var i=0; i < bannerObj.length; i++) {
1441			var thisInAppObj = bannerObj[i];
1442			topBannerHTML += '<div class="each-inApp-notification">' + thisInAppObj.notificationBody + '</div>';
1443		}
1444		topBannerHTML += '</div>';
1445		topBannerHTML += '</div>';
1446		jQuery('div.top-banner-wrapper').removeClass('hide');
1447	}
1448	jQuery('div.top-banner-wrapper').html(topBannerHTML);
1449	jQuery('.followWrap').attr('style','height: '+jQuery('header').height()+'px;');
1450}
1451
1452function closeMobileNav() {
1453	jQuery('body').removeClass('onepress-menu-mobile-opening');
1454	jQuery('ul.onepress-menu').removeClass('onepress-menu-mobile');
1455	jQuery('ul.onepress-menu').attr('style', '');
1456	jQuery('#nav-toggle').removeClass('nav-is-visible');
1457}
1458
1459function showPageData() {
1460	//console.log('showPageData');
1461	jQuery('#passwordModalCenter').removeClass('show');
1462	jQuery('.pass-code-required').addClass('show');
1463}
1464
1465function checkPagePassword(flag, pwd) {
1466	var showModal = true;
1467	if(flag) {
1468		if(pwd === window['pagePCode']) {
1469			setCookie("cpwd", pwd, 0.25);
1470			showModal = false;
1471			showPageData();
1472		}
1473	} else {
1474		var cpwd = getCookie("cpwd");
1475		if(cpwd === window['pagePCode']) {
1476			showModal = false;
1477			showPageData();
1478		}
1479	}
1480	//console.log('checkPagePassword', {flag, pwd});
1481	return showModal;
1482}
1483
1484(function ($) {
1485    'use strict';
1486
1487    $(document).ready(function () {
1488
1489        $('select#switchCitiesRedirect').on('change', function() {
1490            var selected = $(this).val();
1491            if(selected !== '') {
1492                location.href = selected;
1493            }
1494        });
1495        $("#datepicker-cruise-mobile").datepicker({
1496            autoclose: true,
1497            todayHighlight: true,
1498            orientation: "auto left",
1499            startDate: new Date(),
1500            clearBtn: true,
1501        }).datepicker('', new Date());
1502
1503        $(document).on('click', '[data-toggle="lightbox"]', function (event) {
1504            event.preventDefault();
1505            $(this).ekkoLightbox({
1506                alwaysShowClose: true
1507            });
1508        });
1509		
1510		$(window).click(function() {
1511			
1512			//console.log('start clicking');
1513		});
1514		
1515		$('.mobile-placeholder-nav').on('click', function(e) {
1516			//console.log('placeholder');
1517			e.preventDefault();
1518			closeMobileNav();
1519			event.stopPropagation();
1520		});
1521		
1522		
1523		$('nav.main-navigation').on('click', function(e) {
1524			//console.log('nav');
1525			//e.preventDefault();
1526			//event.stopPropagation();
1527		});
1528		
1529		$('ul.onepress-menu li.mobile-close > a').on('click', function(e) {
1530			e.preventDefault();
1531			closeMobileNav();
1532			event.stopPropagation();
1533		});
1534
1535        $('select[name=region-drop]').on('change', function() {
1536            location.href = $(this).val();
1537        });
1538
1539        $('.itinerary-main .itinerary-days .itin-day').on('click', function() {
1540            $('.itinerary-main .itinerary-days .itin-day').removeClass('selected');
1541            $(this).addClass('selected');
1542            var dataRole = $(this).attr('data-role');
1543            console.log(dataRole);
1544        });
1545
1546        $('select.redirect-url-value-select').on('change', function(e) {
1547            if($(this).val() !== '') {
1548                location.href = $(this).val();
1549            }
1550        });
1551
1552        $('button.search-bar-button').on('click', function(evt) {
1553            evt.preventDefault();
1554            var redirectURL = $('select#destination-mobile').val() + '?selMonth=' + $('select#datepicker-cruise').val();
1555            //console.log('redirectURL',redirectURL);
1556            location.href = redirectURL;
1557        });
1558		
1559		$('#enterPassword').on('click', function(e) {
1560			e.preventDefault();
1561			var enterPwd = $('#passwordProtected').val();
1562			if(enterPwd.length) {
1563				checkPagePassword(true, enterPwd);
1564			}
1565		});
1566		
1567		if($('.weatherapi-wrapper').length) {
1568			console.log('call-weatherapi');
1569			$.ajax({
1570				url: "https://api.weatherapi.com/v1/current.json?key=b9b65f54533e471084332700253110&q=San Francisco&aqi=no", 
1571				success: function(result) {
1572					var weatherCity = ((result || {}).location || {}).name || '';
1573					var weatherTimeObj = new Date(((result || {}).location || {}).localtime || '');
1574					var weatherTime = '';
1575					if(typeof weatherTimeObj === 'object') {
1576						var amPm = weatherTimeObj.getHours() > 11 ? 'PM' : 'AM'
1577						var wHour = weatherTimeObj.getHours() > 12 ? weatherTimeObj.getHours() - 12 : weatherTimeObj.getHours();
1578						var wMin = (weatherTimeObj.getMinutes() + '').padStart(2, '0');
1579						var wMonth = monthsSZ[(weatherTimeObj.getMonth() + 1)];
1580						var wDate = weatherTimeObj.getDate();
1581						var wYear = weatherTimeObj.getFullYear();
1582						weatherTime = wHour + ':' + wMin + amPm + ', ' + wMonth + ' ' + wDate + ', ' + wYear;
1583					} else {
1584						weatherTime = '';
1585					}
1586					var weatherIconSrc = result.current.condition.icon;
1587					var weatherTemp = result.current.temp_f + '&deg;F';
1588					console.log('result', result,weatherTimeObj);
1589					var weatherapiHTML = '';
1590					weatherapiHTML += '<span class="weather-city">'+weatherCity+'</span>';
1591					weatherapiHTML += '<span class="weather-time">'+weatherTime+'</span>';
1592					weatherapiHTML += '<span class="weather-wrapper">';
1593					weatherapiHTML += '<span class="weather-icon"><img src="'+weatherIconSrc+'" /></span>';
1594					weatherapiHTML += '<span class="weather-temp">'+weatherTemp+'</span>';
1595					weatherapiHTML += '</span>';
1596					$('.weatherapi-wrapper').html(weatherapiHTML);
1597				}
1598			});
1599		}
1600
1601    });
1602})(jQuery);
1603
1604

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.