1var local_server_position = "us"; 2var http = ("https:" == document.location.protocol) ? "https" : "http"; 3var google_map_api_js = 'https://maps.gstatic.com/intl/en_us/mapfiles/api-3/17/2/main.js'; 4var google_map_api_key = "AIzaSyC6BHBjq1ZPzOiPnIxizIQ0pnU-P-jUdfA"; 5var cn_google_map_api_url = 'https://ditu.google.cn/maps/api/js?language=zh-CN&key=' + google_map_api_key; 6var google_map_api_url = 'https://maps.google.com/maps/api/js?language=en-US&key=' + google_map_api_key; 7var google_places_libraries_url = 'https://maps.googleapis.com/maps/api/js?libraries=places&sensor=true&v=3.10&key=' + google_map_api_key; 8var current_domain = http + '://www.taketours.com'; 9var google_map_jquery_url = current_domain + '/js/gmap3.min.5.js'; 10var google_map_market_label_url = current_domain + '/js/markerwithlabel.js'; 11function ss(w){window.status=w;return true;} 12function cs(){window.status='';} 13function ga(l){if (l) location.href=l;} 14 15function opener_url(url) 16{ 17 var target = window; 18 if (window.opener != null && window.opener.closed == false) 19 { 20 target = window.opener; 21 } 22 target.location.href=url; 23 target.focus(); 24 return false; 25} 26 27 28function open_url_param(url, date) 29{ 30 var lnk = url; 31 if (date != "") 32 { 33 if (lnk.match(/\?/)) 34 { 35 lnk += "&d="+date; 36 } 37 else 38 { 39 lnk += "?"+date; 40 } 41 } 42 opener_url(lnk); 43} 44 45function set_gid_cookie(value, expires) 46{ 47 if (validate_number(value) && value.length < 10) 48 { 49 var name = "gid"; 50 var today = new Date(); 51 today.setTime(today.getTime()); 52 if (!expires) 53 { 54 expires = 7; 55 } 56 expires = expires * 1000 * 60 * 60 * 24; 57 var expires_date = new Date(today.getTime() + expires); 58 document.cookie = name + "=" +escape(value) + (expires ? ";expires=" + expires_date.toGMTString() : "") + ";path=/;domain=taketours.com"; 59} 60} 61 62function pre_set_data() 63{ 64 var date = null; 65 if (window.location.search.length>0) 66 { 67 data = window.location.search.substring(1); 68 if (data.match(/-/)) 69 { 70 var s = document.getElementById('Date'); 71 if(s != null) 72 { 73 if($("#Date").is("select")) 74 { 75 set_tour_date (s, data); 76 } 77 else 78 { 79 on_order_date_clicked(s); 80 } 81 } 82 } 83 else 84 { 85 set_gid_cookie(data); 86 } 87 } 88} 89 90 91function pre_set_date() 92{ 93 var date = null; 94 if (window.location.search.length>0) 95 { 96 date = window.location.search.substring(1); 97 var s = document.getElementById('Date'); 98 set_tour_date (s, date); 99 } 100} 101 102function set_tour_date(obj, selected_date) 103{ 104 if (obj == null || selected_date == null || selected_date == "") 105 { 106 return; 107 } 108 if(obj.type && obj.type.match(/select/)) 109 { 110 return; 111 } 112 var sdate = selected_date.substr(0, 10); 113 for (var i=0; i< obj.options.length; i++) 114 { 115 var val = obj.options[i].value; 116 if (val != "") 117 { 118 val = val.substr(0,10); 119 if (sdate.match(val)) 120 { 121 obj.options.selectedIndex = i; 122 return; 123 } 124 } 125 } 126} 127 128var browser = window.navigator.appName; 129var isIE = false; 130var Win = navigator.userAgent.indexOf("Win") > -1; 131var MSIE = navigator.appName == "Microsoft Internet Explorer"; 132 133function addToFavorites(url, title) 134{ 135 if (window.external) 136 { 137 window.external.AddFavorite(url, title) 138 } 139 else 140 { 141 alert("Sorry! Your browser doesn't support this function."); 142 } 143} 144 145var d_about_up = "http://www.taketours.com/images/explore_up.gif"; 146var d_about_down = "http://www.taketours.com/images/explore_down.gif"; 147function changeImage_aboutus() 148{ 149 if (document.images) { 150 if (document.myImage_aboutus.src == d_about_up) 151 document.myImage_aboutus.src = d_about_down; 152 else 153 document.myImage_aboutus.src = d_about_up; 154 } 155} 156 157function SwitchMenu(obj) 158{ 159 if(document.getElementById) { 160 var el = document.getElementById(obj); 161 if(el.style.display != "block") 162 el.style.display = "block"; 163 else 164 el.style.display = "none"; 165 changeImage_aboutus(); 166 } 167} 168 169function set_selected(obj, v) 170{ 171 for (var i=0; i<obj.options.length; i++) 172 { 173 if (obj.options[i].value == v) 174 { 175 obj.options.selectedIndex = i; 176 return i; 177 } 178 } 179 return -1; 180} 181 182function clear_show_all_text(obj) 183{ 184 if (obj && obj.value == "Show All") 185 { 186 obj.value = ""; 187 } 188} 189 190function set_cookie(name, value, expires) 191{ 192 var today = new Date(); 193 today.setTime(today.getTime()); 194 if (expires) 195 { 196 expires = expires * 1000 * 60 * 60 * 24; 197 } 198 var expires_date = new Date(today.getTime() + expires); 199 document.cookie = name + "=" +escape(value) + (expires ? ";expires=" + expires_date.toGMTString() : "") + ";path=/;domain=taketours.com"; 200} 201 202function get_cookie(name) { 203 if (!name) return ''; 204 const cookies = document.cookie ? document.cookie.split('; ') : []; 205 for (let i = 0; i < cookies.length; i++) { 206 const [key, value] = cookies[i].split('='); 207 if (key === name) { 208 const decoded = decodeURIComponent(value.replace(/\"/g, '')); 209 if (decoded.trim() !== '') { 210 return decoded; 211 } 212 break; 213 } 214 } 215 const localValue = localStorage.getItem(name); 216 if (localValue && localValue.trim() !== '') { 217 return localValue.trim(); 218 } 219 return ''; 220} 221 222function Trim(stringToTrim) { 223 return stringToTrim.replace(/^\s+|\s+$/g,""); 224} 225 226function make_visible(){ 227 var as = document.getElementsByTagName("select"); 228 if(as !=null && as.length>0){ 229 for(var i=0; i < as.length; i++) { 230 as[i].style.visibility="visible"; 231 } 232 } 233} 234 235function remove_cookie(value) 236{ 237 var date = new Date(); 238 date.setTime(date.getTime() - 10000); 239 document.cookie = value + "=a; expires=" + date.toGMTString(); 240} 241 242 243function pageRefresh() 244{ 245 window.location.reload(); 246} 247 248function getElementsByClassName(clsName,htmltag){ 249 var arr = new Array(); 250 var elems = document.getElementsByTagName(htmltag); 251 for (var i = 0; i<elems.length; i++ ) 252 { 253 var elem = elems[i]; 254 if (elem.className == clsName) 255 { 256 arr[arr.length] = elem; 257 } 258 } 259 return arr; 260} 261 262function compatible_form_submit(form) 263{ 264 if($.browser.msie && parseInt($.browser.version) == 6) 265 { 266 setTimeout(function(){ 267 form.submit(); 268 },0); 269 } 270 else 271 { 272 form.submit(); 273 } 274} 275 276// Cross-browser xml parsing 277function parseXML( data ) { 278 var xml, tmp; 279 try { 280 if ( window.DOMParser ) { // Standard 281 tmp = new DOMParser(); 282 xml = tmp.parseFromString( data , "text/xml" ); 283 } else { // IE 284 xml = new ActiveXObject( "Microsoft.XMLDOM" ); 285 xml.async = "false"; 286 xml.loadXML( data ); 287 } 288 } catch( e ) { 289 xml = undefined; 290 } 291 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { 292 jQuery.error( "Invalid XML: " + data ); 293 } 294 return xml; 295} 296//--> 297 298function validate_file_extension(value) 299{ 300 return /\.(?:pdf|ppt|wav|swf|tar|zip|rar|jpg|png|gif|bmp|doc|xls|txt|html|htm|docx|xlsx|pptx|wps|csv|eml|rtf|odt|msg|jpeg)$/i.test(value); 301} 302 303function validate_number(value, advanced) 304{ 305 return advanced ? /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value) : /^-?(?:\d+)?(?:\.\d+)?$/.test(value); 306} 307 308function dispaly_sc_fade_block() 309{ 310 var fadeBlock = document.getElementById("fade_block"); 311 if(!fadeBlock) 312 { 313 fadeBlock = document.createElement("div"); 314 fadeBlock.id = "fade_block"; 315 fadeBlock.style.height = $(document).height() + 'px'; 316 fadeBlock.style.zIndex = 999999; 317 fadeBlock.className="bg_div"; 318 document.body.appendChild(fadeBlock); 319 } 320 var scrolls = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; 321 var img_top = document.documentElement.clientHeight/2 + scrolls; 322 img_top = img_top + 'px'; 323 var img_left = document.body.scrollWidth/2 + 'px'; 324 fadeBlock.innerHTML="<img src='/images/blue-loading.gif' style='margin:0 auto;position:relative;
324left:" + img_left+ ";top:"+img_top+"'/>"; 325 fadeBlock.style.display='block'; 326 return fadeBlock; 327} 328 329function make_tag(key, value) 330{ 331 return "<" + key + ">" + value + "</" + key + ">"; 332} 333 334$(document).ready(function(){ 335 bindModernUI(); 336 if($("a[click_google_map='1']").length > 0) 337 { 338 bindModernClickGoogleMap(); 339 } 340}); 341 342function bindModernUI() 343{ 344 $("ul[modern]:not([readonly])").each(function() { 345 var name = $(this).attr("inputName"); 346 var style = $(this).attr("customStyle"); 347 var li_width = $(this). attr("customwidth"); 348 $(this).delegate("li", "click", function() { 349 $(this).siblings().removeClass("destActive").removeAttr("style"); 350 $(this).addClass("destActive").attr("style", style); 351 if(typeof(li_width) != "undefined" && li_width && li_width != "") 352 { 353 $(this).siblings().width(li_width); 354 $(this).width(li_width); 355 } 356 if(typeof($(this).attr("li_value")) != "undefined") 357 { 358 $(":input[name='" + name + "']").val($(this).attr("li_value")); 359 } 360 else 361 { 362 $(":input[name='" + name + "']").val($(this).attr("value")); 363 } 364 if($(this).attr('click_function_name')) 365 { 366 var click_event = $(this).attr('click_function_name'); 367 if(click_event) 368 { 369 eval(click_event + "();") 370 } 371 } 372 }); 373 }); 374 $("input[type='checkbox'][moderncheckbox]:not([readonly])").each(function() { 375 var name = $(this).attr("inputName"); 376 $(this).click(function(){ 377 var value = 0; 378 if($(this).prop("checked")==true) 379 { 380 value = 1; 381 } 382 $(":input[name='" + name + "']").val(value); 383 if($(this).attr('click_function_name')) 384 { 385 var click_event = $(this).attr('click_function_name'); 386 if(click_event) 387 { 388 eval(click_event + "();") 389 } 390 } 391 }); 392 }); 393 394 $("ul[modern][readonly]").each(function() { 395 $(this).delegate("li", "click", function() { 396 alert("This field is readonly!"); 397 }); 398 }); 399} 400 401function isInternalUrl(url) { 402 try { 403 const currentHost = window.location.hostname; 404 const urlHost = new URL(url).hostname; 405 return urlHost === currentHost; 406 } catch (e) { 407 return false; 408 } 409} 410 411$(function () { 412 const referrer = document.referrer || (window.opener && document.URL) || ""; 413 const blockedDomains = ["alipay.com", "paypal.com", "chinabank.com"]; 414 const isValidReferrer = referrer && 415 !blockedDomains.some(d => referrer.includes(d)) && 416 !isInternalUrl(referrer); 417 if (isValidReferrer) { 418 getApiPromise("POST", "/api/common/set-out-referrer", { referrer }, 0, 1 ); 419 } 420}); 421 422function change_name(obj) 423{ 424 $(obj).addClass("active").siblings().removeClass("active"); 425 var value = $(obj).html(); 426 if(value == "Popular") 427 { 428 $("#n_item_first").parent().children().hide(); 429 $(".n_item_popular").show(); 430 } 431 else 432 { 433 var show_id = "n_item_" + value; 434 $("#n_item_first").parent().children('[id != n_item_first]').hide(); 435 if(document.getElementById(show_id)) 436 { 437 $('[id=' + show_id + ']').show(); 438 } 439 } 440} 441 442function status_change(obj,flag) 443{ 444 var item_id = obj.id + "_item"; 445 if(flag == "v") 446 { 447 if(obj.checked) 448 { 449 $('[id=' + item_id + ']').show(); 450 } 451 else 452 { 453 $('[id=' + item_id + ']').hide(); 454 } 455 return false; 456 } 457 if(obj.checked) 458 { 459 var href = window.location.href; 460 var href_arr = href.split("?"); 461 var local_url = href_arr[0]; 462 var param = href_arr[1]; 463 if(param.indexOf("&"+flag+"=1") >= 0) 464 { 465 $('[id=' + item_id + ']').show(); 466 return false; 467 } 468 var param_url = ""; 469 if (param) 470 { 471 var strs = new Array(); 472 strs = param.split("&"); 473 var i = 0; 474 for(i=0;i<strs.length;i++) 475 { 476 var ds = strs[i]; 477 var ds_array = ds.split("="); 478 if(ds_array.length==2) 479 { 480 var param_name = decodeURIComponent(ds_array[0]); 481 var param_value = decodeURIComponent(ds_array[1]); 482 if(param_name != "s" && param_name != "p" && param_name != "ac") 483 { 484 if(param_url) 485 { 486 param_url += "&"+param_name+"="+param_value; 487 } 488 else 489 { 490 param_url += param_name+"="+param_value; 491 } 492 } 493 } 494 } 495 } 496 var url = local_url + "?" + param_url; 497 var sales_obj = document.getElementById("sales_marketing"); 498 var products_obj = document.getElementById("products"); 499 var accounting_obj = document.getElementById("accounting"); 500 if(sales_obj.checked) 501 { 502 url += "&s=1"; 503 } 504 if(products_obj.checked) 505 { 506 url += "&p=1"; 507 } 508 if(accounting_obj.checked) 509 { 510 url += "&ac=1"; 511 } 512 ga(url); 513 } 514 else 515 { 516 $('[id=' + item_id + ']').hide(); 517 } 518} 519 520var preview_original_image = function() { 521xOffset = -10;
522yOffset = 30; 523$("#original_image_list").find("img").hover(function(e) 524{ 525 var url = this.src; 526 var preview_url = $(this).attr("ivy_preview_url"); 527 if (preview_url != "" && preview_url != undefined) 528 { 529 url = preview_url; 530 } 531 $("<img id='imgshow_temp' style='max-width:500px;max-height:500px;position:absolute;border:1px solid #ccc;background:#333;color:#fff;padding:5px;display:none;' src='" + url + "' />").appendTo("body"); 532 $("#imgshow_temp") 533 .css("top", (e.pageY - xOffset) + "px") 534 .css("left", (e.pageX + yOffset) + "px") 535 .fadeIn("fast"); 536}, 537function() 538{ 539 $("#imgshow_temp").remove(); 540} 541); 542$("#original_image_list").find("img").mousemove(function(e) { 543 $("#imgshow_temp") 544 .css("top", (e.pageY - xOffset) + "px") 545 .css("left", (e.pageX + yOffset) + "px") 546}); 547}; 548 549function td_background_change(value) 550{ 551 $(".vendorList").removeClass("vendorList"); 552 $("." + value).addClass("vendorList"); 553} 554 555function copyToClipboard(txt) { 556 if(window.clipboardData) { 557 window.clipboardData.clearData(); 558 window.clipboardData.setData("Text", txt); 559 } else if(navigator.userAgent.indexOf("Opera") != -1) { 560 window.location = txt; 561 } else if (window.netscape) { 562 try { 563 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 564 } catch (e) { 565 alert("Broser refuse!\n Please input 'about:config' at adress bar then set 'signed.applets.codebase_principal_support' option 'true'!"); 566 } 567 var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); 568 if (!clip) 569 { 570 return; 571 } 572 var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); 573 if (!trans) 574 { 575 return; 576 } 577 trans.addDataFlavor('text/unicode'); 578 var str = new Object(); 579 var len = new Object(); 580 var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 581 var copytext = txt; 582 str.data = copytext; 583 trans.setTransferData("text/unicode",str,copytext.length*2); 584 var clipid = Components.interfaces.nsIClipboard; 585 if (!clip) 586 { 587 return false; 588 } 589 clip.setData(trans,null,clipid.kGlobalClipboard); 590 } 591 alert("Copied successfully."); 592} 593 594function validate_email_input(email){ 595 var flag = true; 596 var temp_array = email.split(","); 597 var count = temp_array.length; 598 var email_array = []; 599 for (i=0; i<count; i++) 600 { 601 var temp_email = temp_array[i]; 602 var emails = temp_email.split(";"); 603 if (emails.length > 1) 604 { 605 for (j=0; j<emails.length; j++) 606 { 607 email_array.push(emails[j]); 608 } 609 } 610 else 611 { 612 email_array.push(temp_email); 613 } 614 } 615 var validate_str = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 616 for (k=0; k<email_array.length; k++) 617 { 618 var email_value = email_array[k]; 619 email_value = Trim(email_value); 620 if (email_value && email_value != "") 621 { 622 if(!validate_str.test(email_value)) 623 { 624 flag = "Please enter a valid Email Address."; 625 } 626 } 627 } 628 return flag; 629} 630 631function getUrlParam(name) 632{ 633 var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 634 var r = window.location.search.substr(1).match(reg); 635 if (r!=null) return unescape(r[2]); return null; 636} 637 638function isSubdomain(c, d) { 639 this.getdomain = function(f) { 640 var e = f.indexOf("://"); 641 if (e > 0) { 642 var h = f.substr(e + 3) 643 } else { 644 var h = f 645 } 646 var g = /^www\./; 647 if (g.test(h)) { 648 h = h.substr(4) 649 } 650 return h 651 }; 652 if (c == d) { 653 return 1 654 } else { 655 var c = this.getdomain(c); 656 var b = this.getdomain(d); 657 if (c == b) { 658 return 1 659 } else { 660 c = c.replace(".", "\\."); 661 var a = new RegExp("\\." + c + "$"); 662 if (b.match(a)) { 663 return 2 664 } else { 665 return 0 666 } 667 } 668 } 669}; 670 671function distinctArray(a) 672{ 673 return $.grep(a, function(v, k) { 674 return $.inArray(v, a) === k; 675 }); 676} 677 678$(document).ready(function(){ 679 date_range_selection_into_event(); 680}) 681 682function date_range_selection_into_event() 683{ 684 $(".dateScopeC").each(function(){ 685 var searchBy = $(this).parent().find("#search_by").val(); 686 $(this).html(searchBy); 687 var searchByBar = $(this).parent().find("#searchByBar").val(); 688 var active_li = $(this).parent().find("span[seletor_tag='"+searchByBar+"']").parent(); 689 active_li.find(".n_checkActive").show(); 690 active_li.siblings().find(".n_checkActive").hide(); 691 }); 692 $(".dateScopeS").click(function(){ 693 $(this).find(":input").click(function(event) { 694 event.stopPropagation(); 695 }); 696 $(this).find(".standardDilogBox li").click(function(event) { 697 event.stopPropagation(); 698 }); 699 $("#ui-datepicker-div").click(function(event) { 700 event.stopPropagation(); 701 }); 702 var seletor = $(this).find("#searchByBar").val(); 703 var compare_seletor = $(this).find("#compare_searchByBar").val(); 704 if(seletor == 1 || compare_seletor == 1) 705 { 706 $(this).find(".date_custom").find(".chooseDate").show(); 707 } 708 else 709 { 710 $(this).find(".date_custom").find(".chooseDate").hide(); 711 } 712 $(this).find(".standardDilogBox").show(function(){ 713 $(document.body).append("<div class='ui-widget-overlay frame-daterange-overlay'></div>"); 714 $(".frame-daterange-overlay").css("opacity", 0); 715 $(".frame-daterange-overlay").click(function() { 716 $(this).remove(); 717 $(".standardDilogBox").hide('fast',function(){ 718 if($(".n_checkActive:visible").parent().siblings().html() == "Customize" || $(".n_checkActive:visible").parent().siblings().html() == "Customize starting date") 719 { 720 $(".date_custom").find(".chooseDate").hide(); 721 } 722 }); 723 }); 724 }); 725 }); 726 $(".dateScopeS .standardDilogBox li").click(function(){ 727 $(this).find(".standardButton").click(function(event) { 728 event.stopPropagation(); 729 }); 730 $(this).find(".standardBut_GrayLow").click(function(event) { 731 event.stopPropagation(); 732 }); 733 if(!$(this).find(".n_checkActive").is(':visible') && $(this).attr("class") != "date_custom" && $(this).attr("class") != "standardNotHideLi") 734 { 735 $(this).find(".n_checkActive").toggle(); 736 $(this).siblings().find(".n_checkActive").hide(); 737 } 738 if($(this).attr("seletor_tag") != 1 && $(this).attr("class") != "date_custom" && $(this).attr("class") != "standardNotHideLi") 739 { 740 var innerhtml = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().html(); 741 var seletor = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().attr("seletor_tag"); 742 if(innerhtml == undefined) 743 { 744 innerhtml = ''; 745 } 746 if((seletor == 2 || seletor == 3) && $(this).attr("class") != "date-search-type") 747 { 748 var n_date = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().attr("n_date"); 749 innerhtml += "<span class='c333 spaceL5'>"+n_date+"</span>"; 750 } 751 $(this).parent().parent().parent().find(".dateScopeC").html(innerhtml); 752 $(this).parent().parent().parent().find("#search_by").val(innerhtml); 753 $(this).parent().parent().parent().find("#searchByBar").val(seletor); 754 if($(this).attr("class") == "date-search-type") 755 { 756 $(this).parent().parent().parent().find("#compare_search_by").val(innerhtml); 757 $(this).parent().parent().parent().find("#compare_searchByBar").val(seletor); 758 } 759 $(".standardDilogBox").hide('fast',function(){ 760 $(".frame-daterange-overlay").remove(); 761 if($("#searchByBar").val() != 1) 762 { 763 $(".date_custom").find(".chooseDate").hide(); 764 } 765 }); 766 } 767 }) 768 $(".date_custom").click(function(){ 769 $(this).find(".chooseDate").show(); 770 }) 771 $(".dateScopeS .standardButtonCustom").click(function(){ 772 $(this).parent().parent().find(".n_checkActive").show(); 773 $(this).parent().parent().siblings().find(".n_checkActive").hide(); 774 var innerhtml = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().html(); 775 var seletor = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().attr("seletor_tag"); 776 if(innerhtml == undefined) 777 { 778 innerhtml = ''; 779 } 780 var start_date = $(this).parent().find(".date_range_start").val(); 781 var end_date = $(this).parent().find(".date_range_end").val(); 782 var compare_start_date = $(this).parent().find(".compare_date_range_start").val(); 783 var compare_end_date = $(this).parent().find(".compare_date_range_end").val(); 784 if ((!start_date || !start_date.match(/\d\d\d\d-\d\d-\d\d/)) && (!compare_start_date || !compare_start_date.match(/\d\d\d\d-\d\d-\d\d/))) 785 { 786 alert("Date must be in the format: YYYY-MM-DD"); 787 return false;
788 } 789 if ((!end_date || !end_date.match(/\d\d\d\d-\d\d-\d\d/)) && (!compare_end_date || !compare_end_date.match(/\d\d\d\d-\d\d-\d\d/))) 790 { 791 alert("Date must be in the format: YYYY-MM-DD"); 792 return false; 793 } 794 $(this).parent().parent().parent().parent().parent().find(".dateScopeC").html(start_date+" to "+end_date); 795 $(this).parent().parent().parent().parent().parent().find("#search_by").val(start_date+" to "+end_date); 796 $(this).parent().parent().parent().parent().parent().find("#searchByBar").val(seletor); 797 if(compare_start_date && compare_end_date) 798 { 799 $(this).parent().parent().parent().parent().parent().find(".dateScopeC").html(compare_start_date+" to "+compare_end_date); 800 $(this).parent().parent().parent().parent().parent().find("#compare_search_by").val(compare_start_date+" to "+compare_end_date); 801 $(this).parent().parent().parent().parent().parent().find("#compare_searchByBar").val(seletor); 802 } 803 $(".standardDilogBox").hide('fast',function(){ 804 $(".frame-daterange-overlay").remove(); 805 if($("#searchByBar").val() != 1) 806 { 807 $(".date_custom").find(".chooseDate").hide(); 808 } 809 }); 810 }); 811 init_time_selector(); 812} 813 814function get_autocomplete_array_min_length(data) 815{ 816 var len = data.length; 817 if(len > 10000) 818 { 819 return 3; 820 } 821 else if(len > 1000) 822 { 823 return 2; 824 } 825 else 826 { 827 return 1; 828 } 829} 830 831function build_columns_html(cells, max_cols, handler) 832{ 833 var html = ""; 834 if(cells.length > 0) 835 { 836 var count_cells = cells.length; 837 var min_cols = Math.min(count_cells, max_cols); 838 var max_rows = Math.ceil(count_cells / min_cols); 839 for(var i = 0; i < min_cols; i++) 840 { 841 var start = i * max_rows; 842 var end = start + max_rows > count_cells ? count_cells : start + max_rows; 843 html += handler(cells.slice(start, end)); 844 } 845 } 846 return html; 847} 848 849function is_input_text_empty(obj) 850{ 851 return $(obj).val() == "" || $(obj).val() == $(obj).data("placeholder"); 852} 853 854function setOuterWidthIncludeMargin(obj, value) 855{ 856 var margin = $(obj).outerWidth(true) + 1 - $(obj).outerWidth(); 857 $(obj).outerWidth(value - margin); 858} 859 860$(document).ready(function(){ 861 days_range_selection_into_event(); 862}); 863 864function days_range_selection_into_event() 865{ 866 $(".daysScopeC").each(function(){ 867 var searchBy = $(this).parent().find("#search_by").val(); 868 $(this).html(searchBy); 869 var searchByBar = $(this).parent().find("#searchByBar").val(); 870 if(searchByBar == "") 871 { 872 searchByBar = 0; 873 } 874 var active_as = $(this).parent().find("[select_days=1]"); 875 $("[select_days=1]").each(function(){ 876 if($(this).attr("seletor_tag") == searchByBar) 877 { 878 $(this).addClass("daysScopeCActive"); 879 } 880 else 881 { 882 $(this).removeClass("daysScopeCActive"); 883 } 884 }); 885 886 }); 887 $(".daysScopeS").click(function(event){ 888 event.stopPropagation(); 889 $(this).find(".standardDilogBox a").click(function(event) { 890 event.stopPropagation(); 891 }); 892 $(this).find(".standardDilogBox span").click(function(event) { 893 event.stopPropagation(); 894 }); 895 $(this).find(".standardDilogBox .standard_selfdate").click(function(event) { 896 event.stopPropagation(); 897 }); 898 $("#ui-dayspicker-div").click(function(event) { 899 event.stopPropagation(); 900 }); 901 var seletor = $(this).find("#searchByBar").val(); 902 if(seletor == "") 903 { 904 seletor = 0; 905 } 906 var active_as = $(this).find("[select_days=1]"); 907 $("[select_days=1]").each(function(){ 908 if($(this).attr("seletor_tag") == seletor) 909 { 910 $(this).addClass("daysScopeCActive"); 911 } 912 else 913 { 914 $(this).removeClass("daysScopeCActive"); 915 } 916 }); 917 if(seletor == 1) 918 { 919 $(this).find(".choosedays").show(); 920 $(this).find("p[name='days_select_p']").hide(); 921 } 922 else 923 { 924 $(this).find(".choosedays").hide(); 925 $(this).find("p[name='days_select_p']").show(); 926 } 927 $(this).find(".standardDilogBox").toggle(); 928 }); 929 $(document).click(function(event){ 930 if(event.which == 1) 931 { 932 $(".daysScopeS .standardDilogBox").hide(); 933 } 934 }); 935 $(".daysScopeS .standardDilogBox").click(function(event){ 936 event.cancelBubble=true; 937 event.stopPropagation(); 938 }); 939 $(".daysScopeS .standardDilogBox").find("[select_days=1]").click(function(){ 940 $(this).find(".standardButton").click(function(event) { 941 event.stopPropagation(); 942 }); 943 $(this).find(".standardBut_GrayLow").click(function(event) { 944 event.stopPropagation(); 945 }); 946 if($(this).attr("seletor_tag") != 1 && $(this).attr("class") != "standardNotHideLi") 947 { 948 var innerhtml = $(this).attr("lan_seltor"); 949 var seletor = $(this).attr("seletor_tag"); 950 if(seletor == 0) 951 { 952 $(this).parent().parent().find("p[name='days_select_p']").show(); 953 $(this).parent().parent().find(".choosedays").hide(); 954 } 955 if(innerhtml == undefined) 956 { 957 innerhtml = 'Any length'; 958 } 959 var duration = $(this).html(); 960 if(duration && duration.indexOf("+") > 0) 961 { 962 duration = duration.replace("+", "-"); 963 } 964 if(seletor == 0) 965 { 966 duration = ''; 967 } 968 969 $(this).closest(".daysScopeS").find(".start_range_days").val(""); 970 $(this).closest(".daysScopeS").find(".end_range_days").val(""); 971 $(this).parent().parent().parent().find(".daysScopeC").html(innerhtml); 972 $(this).parent().parent().parent().find("#search_by").val(innerhtml); 973 $(this).parent().parent().parent().find("#frame_duration").val(duration); 974 $(this).parent().parent().parent().find("#searchByBar").val(seletor); 975 976 var active_as = $(this).parent().find("[select_days=1]"); 977 $("[select_days=1]").each(function(){ 978 if($(this).attr("seletor_tag") == seletor) 979 { 980 $(this).addClass("daysScopeCActive"); 981 } 982 else 983 { 984 $(this).removeClass("daysScopeCActive"); 985 } 986 }); 987 fetch_tour_search_destination_selection_datas(); 988 $(".daysScopeS .standardDilogBox").hide('fast',function(){ 989 $(".duration-overlay").remove(); 990 if($("#searchByBar").val() != 1) 991 { 992 $(".days_custom").find(".choosedays").hide(); 993 } 994 }); 995 } 996 }); 997 $(".days_custom").click(function(){ 998 $(this).parent().parent().find("p[name='days_select_p']").hide(); 999 $(this).parent().parent().find(".choosedays").show(); 1000 var active_as = $(this).parent().find("[select_days=1]"); 1001 $("[select_days=1]").each(function(){ 1002 if($(this).attr("seletor_tag") == 1) 1003 { 1004 $(this).addClass("daysScopeCActive"); 1005 } 1006 else 1007 { 1008 $(this).removeClass("daysScopeCActive"); 1009 } 1010 }); 1011 }); 1012 1013 $(".daysScopeS .standardButtonCustom").click(function(){ 1014 var start_days = $(this).closest(".daysScopeS").find(".start_range_days").val(); 1015 var end_days = $(this).closest(".daysScopeS").find(".end_range_days").val(); 1016 if (!(/^[0-9]*[1-9][0-9]*$/.test(start_days))||start_days ==0) 1017 { 1018 alert("Please input a number to specify tour duration!"); 1019 $("#start_days").focus(); 1020 return false;
1021 } 1022 if (end_days != "" && (!(/^[0-9]*[1-9][0-9]*$/.test(end_days))||end_days ==0)) 1023 { 1024 alert("Please input a number to specify tour duration!"); 1025 $("#end_days").focus(); 1026 return false; 1027 } 1028 if (end_days != "" && (parseInt(end_days) < parseInt(start_days))) 1029 { 1030 alert("Please input a number greater than previous one!"); 1031 $("#end_days").focus(); 1032 return false; 1033 } 1034 var seletor = $(this).attr("seletor_tag"); 1035 if(end_days == 30) 1036 { 1037 end_days = ""; 1038 } 1039 if(end_days == "") 1040 { 1041 $(this).parent().parent().parent().find(".daysScopeC").html(start_days+"+ days"); 1042 $(this).parent().parent().parent().find("#search_by").val(start_days+"+ days"); 1043 } 1044 else 1045 { 1046 $(this).parent().parent().parent().find(".daysScopeC").html(start_days+"-"+end_days+" days"); 1047 $(this).parent().parent().parent().find("#search_by").val(start_days+"-"+end_days+" days"); 1048 } 1049 $(this).parent().parent().parent().find("#frame_duration").val(start_days+"-"+end_days); 1050 $(this).parent().parent().parent().find("#searchByBar").val(1); 1051 fetch_tour_search_destination_selection_datas(); 1052 $(".daysScopeS .standardDilogBox").hide('fast',function(){ 1053 $(".duration-overlay").remove(); 1054 if($("#searchByBar").val() != 1) 1055 { 1056 $(".days_custom").find(".choosedays").hide(); 1057 } 1058 }); 1059 }); 1060 1061} 1062 1063$(document).ready(function(){ 1064 $(".datesScopeC").each(function(){ 1065 var searchBy = $(this).parent().find("#search_by").val(); 1066 $(this).html(searchBy); 1067 var searchByBar = $(this).parent().find("#searchByBar").val(); 1068 var active_li = $(this).parent().find("span[seletor_tag='"+searchByBar+"']").parent(); 1069 active_li.find(".n_checkActive").show(); 1070 active_li.siblings().find(".n_checkActive").hide(); 1071 }); 1072 $(".datesScopeS").click(function(){ 1073 $(this).find(":input").click(function(event) { 1074 event.stopPropagation(); 1075 }); 1076 $(this).find(".standardDilogBox li").click(function(event) { 1077 event.stopPropagation(); 1078 }); 1079 $("#ui-datepicker-div").click(function(event) { 1080 event.stopPropagation(); 1081 }); 1082 var seletor = $(this).find("#searchByBar").val() 1083 if(seletor == 1) 1084 { 1085 $(this).find(".dates_custom").find(".chooseDates").show(); 1086 } 1087 else 1088 { 1089 $(this).find(".dates_custom").find(".chooseDates").hide(); 1090 } 1091 var dates_scope = $(this); 1092 $(this).find(".standardDilogBox").slideDown(50,function(){ 1093 $(document.body).append("<div class='ui-widget-overlay frame-daterange-overlay'></div>"); 1094 $(".frame-daterange-overlay").css("opacity", 0); 1095 $(".frame-daterange-overlay").click(function() { 1096 $(this).remove(); 1097 $(".datesScopeS .standardDilogBox").slideUp('fast'); 1098 }); 1099 }); 1100 }); 1101 $(".datesScopeS .standardDilogBox li").click(function(){ 1102 $(this).find(".standardButton").click(function(event) { 1103 event.stopPropagation(); 1104 }); 1105 $(this).find(".standardBut_GrayLow").click(function(event) { 1106 event.stopPropagation(); 1107 }); 1108 if(!$(this).find(".n_checkActive").is(':visible') && $(this).attr("class") != "dates_custom" && $(this).attr("class") != "standardNotHideLi") 1109 { 1110 $(this).find(".n_checkActive").toggle(); 1111 $(this).siblings().find(".n_checkActive").hide(); 1112 } 1113 if($(this).attr("seletor_tag") != 1 && $(this).attr("class") != "standardNotHideLi") 1114 { 1115 var innerhtml = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().html(); 1116 var seletor = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().attr("seletor_tag"); 1117 if(innerhtml == undefined) 1118 { 1119 innerhtml = ''; 1120 } 1121 $(this).parent().parent().parent().find(".datesScopeC").html(innerhtml); 1122 $(this).parent().parent().parent().find("#search_by").val(innerhtml); 1123 var start_dates_seletors = { 2: 'tomorrow', 3: 'next_3_days', 4: 'this_week', 5: 'next_week', 6: 'this_month', 7: 'next_month' }; 1124 var start_dates = start_dates_seletors[seletor]; 1125 $(this).parent().parent().parent().find("#frame_start_dates").val(start_dates); 1126 $(this).parent().parent().parent().find("#searchByBar").val(seletor); 1127 fetch_tour_search_destination_selection_datas();
1128 $(".datesScopeS .standardDilogBox").hide('fast',function(){ 1129 $(".frame-daterange-overlay").remove(); 1130 if($("#searchByBar").val() != 1) 1131 { 1132 $(".dates_custom").find(".chooseDates").hide(); 1133 } 1134 1135 }); 1136 } 1137 }); 1138 $(".dates_custom").click(function(){ 1139 $(this).find(".chooseDates").show(); 1140 }) 1141 $(".datesScopeS .standardButtonCustom").click(function(){ 1142 var start_date = $(this).parent().find(".dates_range_start").val(); 1143 var end_date = $(this).parent().find(".dates_range_end").val(); 1144 if (!start_date || !start_date.match(/\d\d\d\d-\d\d-\d\d/)) 1145 { 1146 alert("Date must be in the format: YYYY-MM-DD"); 1147 return false; 1148 } 1149 if (!end_date || !end_date.match(/\d\d\d\d-\d\d-\d\d/)) 1150 { 1151 alert("Date must be in the format: YYYY-MM-DD"); 1152 return false; 1153 } 1154 if(start_date > end_date) 1155 { 1156 alert("End Date should be greater than or equal to Start Date."); 1157 return false; 1158 } 1159 $(this).parent().parent().find(".n_checkActive").show(); 1160 $(this).parent().parent().siblings().find(".n_checkActive").hide(); 1161 var innerhtml = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().html(); 1162 var seletor = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().attr("seletor_tag"); 1163 if(innerhtml == undefined) 1164 { 1165 innerhtml = ''; 1166 } 1167 var start_days = $(this).parent().find(".dates_range_start").val(); 1168 var end_days = $(this).parent().find(".dates_range_end").val(); 1169 if(end_days != "" && end_days != start_days) 1170 { 1171 $(this).parent().parent().parent().parent().parent().find(".datesScopeC").html(start_days+" to "+end_days); 1172 $(this).parent().parent().parent().parent().parent().find("#search_by").val(start_days+" to "+end_days); 1173 $(this).parent().parent().parent().parent().parent().find("#frame_start_dates").val(start_days+"~"+end_days); 1174 } 1175 else 1176 { 1177 $(this).parent().parent().parent().parent().parent().find(".datesScopeC").html(start_days); 1178 $(this).parent().parent().parent().parent().parent().find("#search_by").val(start_days); 1179 $(this).parent().parent().parent().parent().parent().find("#frame_start_dates").val(start_days); 1180 } 1181 $(this).parent().parent().parent().parent().parent().find("#searchByBar").val(seletor); 1182 fetch_tour_search_destination_selection_datas(); 1183 $(".datesScopeS .standardDilogBox").hide('fast',function(){ 1184 $(".frame-daterange-overlay").remove(); 1185 if($("#searchByBar").val() != 1) 1186 { 1187 $(".dates_custom").find(".chooseDates").hide(); 1188 } 1189 1190 }); 1191 }); 1192}); 1193 1194 1195$(document).ready(function(){ 1196 $(".datesScopeSS").find(".datesScopeC").each(function(){ 1197 var searchBy = $(this).parent().find("#search_by").val(); 1198 $(this).html(searchBy); 1199 var searchByBar = $(this).parent().find("#searchByBar").val(); 1200 if(searchByBar == "") 1201 { 1202 searchByBar = 0; 1203 } 1204 var active_as = $(this).parent().find("[select_date=1]"); 1205 $("[select_dates=1]").each(function(){ 1206 if($(this).attr("seletor_tag") == searchByBar) 1207 { 1208 $(this).addClass("datesScopeCActive"); 1209 } 1210 else 1211 { 1212 $(this).removeClass("datesScopeCActive"); 1213 } 1214 }); 1215 }); 1216 1217 1218 $(".datesScopeSS").click(function(){ 1219 $(this).find(":input").click(function(event) { 1220 event.stopPropagation(); 1221 }); 1222 $(this).find(".standardDilogBox a").click(function(event) { 1223 event.stopPropagation(); 1224 }); 1225 $(this).find(".standardDilogBox span").click(function(event) { 1226 event.stopPropagation(); 1227 }); 1228 $(this).find(".standardDilogBox .standard_selfdate").click(function(event) { 1229 event.stopPropagation(); 1230 }); 1231 $("#ui-datepicker-div").click(function(event) { 1232 event.stopPropagation(); 1233 }); 1234 var seletor = $(this).find("#searchByBar").val(); 1235 if(seletor == "") 1236 { 1237 seletor = 0; 1238 } 1239 var active_as = $(this).find("[select_dates=1]"); 1240 $("[select_dates=1]").each(function(){ 1241 if($(this).attr("seletor_tag") == seletor) 1242 { 1243 $(this).addClass("datesScopeCActive"); 1244 } 1245 else 1246 { 1247 $(this).removeClass("datesScopeCActive"); 1248 } 1249 }); 1250 if(seletor == 1) 1251 { 1252 $(this).find(".chooseDates").show(); 1253 $(this).find("p[name='date_select_p']").hide(); 1254 } 1255 else 1256 { 1257 $(this).find(".chooseDates").hide(); 1258 $(this).find("p[name='date_select_p']").show(); 1259 1260 } 1261 var dates_scope = $(this); 1262 $(this).find(".standardDilogBox").slideDown(50,function(){ 1263 $(document.body).append("<div class='ui-widget-overlay frame-daterange-overlay'></div>"); 1264 $(".frame-daterange-overlay").css("opacity", 0); 1265 $(".frame-daterange-overlay").click(function() { 1266 $(this).remove();
1267 $(".datesScopeSS .standardDilogBox").slideUp('fast'); 1268 }); 1269 }); 1270 }); 1271 1272 $(".datesScopeSS .standardDilogBox").find("[select_dates=1]").click(function(){ 1273 $(this).find(".standardButton").click(function(event) { 1274 event.stopPropagation(); 1275 }); 1276 $(this).find(".standardBut_GrayLow").click(function(event) { 1277 event.stopPropagation(); 1278 }); 1279 if(!$(this).find(".n_checkActive").is(':visible') && $(this).attr("class") != "dates_custom" && $(this).attr("class") != "standardNotHideLi") 1280 { 1281 $(this).find(".n_checkActive").toggle(); 1282 $(this).siblings().find(".n_checkActive").hide(); 1283 } 1284 if($(this).attr("seletor_tag") != 1 && $(this).attr("class") != "standardNotHideLi") 1285 { 1286 var innerhtml = $(this).attr("lan_seltor"); 1287 var seletor = $(this).attr("seletor_tag"); 1288 if(seletor == 0) 1289 { 1290 $(this).parent().parent().find("p[name='date_select_p']").show(); 1291 $(this).parent().parent().find(".chooseDates").hide(); 1292 } 1293 if(innerhtml == undefined) 1294 { 1295 innerhtml = ''; 1296 } 1297 $(this).parent().parent().parent().find(".datesScopeC").html(innerhtml); 1298 $(this).parent().parent().parent().find("#search_by").val(innerhtml); 1299 var start_dates_seletors = { 2: 'tomorrow', 3: 'next_3_days', 4: 'this_week', 5: 'next_week', 6: 'this_month', 7: 'next_month' }; 1300 var start_dates = start_dates_seletors[seletor]; 1301 $(this).parent().parent().parent().find("#frame_start_dates").val(start_dates); 1302 $(this).parent().parent().parent().find("#searchByBar").val(seletor); 1303 fetch_tour_search_destination_selection_datas(); 1304 $(".datesScopeSS .standardDilogBox").hide('fast',function(){ 1305 $(".frame-daterange-overlay").remove(); 1306 if($("#searchByBar").val() != 1) 1307 { 1308 $(".dates_custom").find(".chooseDates").hide(); 1309 } 1310 1311 }); 1312 } 1313 }); 1314 1315 $(".dates_custom").click(function(){ 1316 1317 $(this).parent().parent().find("p[name='date_select_p']").hide(); 1318 $(this).parent().parent().find(".chooseDates").show(); 1319 var active_as = $(this).parent().find("[select_dates=1]"); 1320 $("[select_dates=1]").each(function(){ 1321 if($(this).attr("seletor_tag") == 1) 1322 { 1323 $(this).addClass("datesScopeCActive"); 1324 } 1325 else 1326 { 1327 $(this).removeClass("datesScopeCActive"); 1328 } 1329 }); 1330 }); 1331 1332 $(".datesScopeSS .standardButtonCustom").click(function(){ 1333 var start_date = $(this).parent().find(".dates_range_start").val(); 1334 var end_date = $(this).parent().find(".dates_range_end").val(); 1335 var end_date_default = $(this).parent().find(".dates_range_end").attr("lan_default"); 1336 if(end_date == end_date_default) 1337 { 1338 end_date = ""; 1339 } 1340 1341 if (!start_date || !start_date.match(/\d\d\d\d-\d\d-\d\d/)) 1342 { 1343 alert("Date must be in the format: YYYY-MM-DD"); 1344 return false; 1345 } 1346 if (end_date != "" && !end_date.match(/\d\d\d\d-\d\d-\d\d/)) 1347 { 1348 alert("Date must be in the format: YYYY-MM-DD"); 1349 return false; 1350 } 1351 if(end_date != "" && start_date > end_date) 1352 { 1353 alert("End Date should be greater than or equal to Start Date."); 1354 return false; 1355 } 1356 $(this).parent().parent().find(".n_checkActive").show(); 1357 $(this).parent().parent().siblings().find(".n_checkActive").hide(); 1358 var innerhtml = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().html(); 1359 var seletor = $(this).parent().parent().parent().find(".n_checkActive:visible").parent().siblings().attr("seletor_tag"); 1360 if(innerhtml == undefined) 1361 { 1362 innerhtml = ''; 1363 } 1364 var start_days = $(this).parent().find(".dates_range_start").val(); 1365 var end_days = $(this).parent().find(".dates_range_end").val(); 1366 if(end_days == end_date_default) 1367 { 1368 end_days = ""; 1369 } 1370 if(end_days != "" && end_days != start_days) 1371 { 1372 $(this).parent().parent().parent().find(".datesScopeC").html(start_days+" to "+end_days); 1373 $(this).parent().parent().parent().find("#search_by").val(start_days+" to "+end_days); 1374 $(this).parent().parent().parent().find("#frame_start_dates").val(start_days+"~"+end_days); 1375 } 1376 else 1377 { 1378 $(this).parent().parent().parent().find(".datesScopeC").html(start_days); 1379 $(this).parent().parent().parent().find("#search_by").val(start_days); 1380 $(this).parent().parent().parent().find("#frame_start_dates").val(start_days); 1381 } 1382 1383 $(this).parent().parent().parent().find("#searchByBar").val(1); 1384 fetch_tour_search_destination_selection_datas();
1385 $(".datesScopeSS .standardDilogBox").hide('fast',function(){ 1386 $(".frame-daterange-overlay").remove(); 1387 if($("#searchByBar").val() != 1) 1388 { 1389 $(".dates_custom").find(".chooseDates").hide(); 1390 } 1391 1392 }); 1393 }); 1394}); 1395 1396 1397 1398 1399 1400function tour_cookie_login(c_cgi, sc_cgi, ce_cgi) 1401{ 1402 if(isUserLoggedIn()) 1403 { 1404 if(!c_cgi) 1405 { 1406 c_cgi = '/cgi-bin/app.fcgi'; 1407 } 1408 if(!sc_cgi) 1409 { 1410 sc_cgi = '/cgi-bin/app.fcgi'; 1411 } 1412 if(!ce_cgi) 1413 { 1414 ce_cgi = '/cgi-bin/ce.fcgi'; 1415 } 1416 var javaon = true; 1417 if (document.domain.startsWith("m.")) { 1418 javaon = false; 1419 } 1420 var account_url = sc_cgi + "?a=main"; 1421 var signout_url = sc_cgi + "?a=signout"; 1422 if(javaon) 1423 { 1424 account_url = "/app/member/account"; 1425 signout_url = "/app/do/signout"; 1426 } 1427 var cookie_email = get_cookie("IvyCustomer_LoginEmail"); 1428 var cookie_uid = get_cookie("IvyCustomer_FirstName"); 1429 if(cookie_uid == "") 1430 { 1431 cookie_uid = get_cookie("IvyCustomer_Uid"); 1432 } 1433 if(cookie_uid == "" || cookie_uid.indexOf("_auto_") != -1) 1434 { 1435 cookie_uid = cookie_email; 1436 } 1437 else if(cookie_uid.indexOf("@") != -1) 1438 { 1439 cookie_uid = cookie_uid.substr(0, cookie_uid.indexOf("@")); 1440 } 1441 var account_html ="<a class='dropdown-toggle' data-toggle='dropdown' href='"+account_url+"'><i class='icon-user fa-lg'></i>" + cookie_uid + "<i class='icon-down-dir'></i></a>"; 1442 var sign_out_new_html = "<li><a href='"+signout_url+"' title='Log Out'>Log Out</a></li>"; 1443 var is_aff = get_cookie("IvyCustomer_IsAffiliate"); 1444 var role = get_cookie("IvyCustomer_role"); 1445 var my_account_url; 1446 var my_account_title; 1447 if(is_aff == "1" || role >= 3) 1448 { 1449 my_account_url = account_url; 1450 my_account_title = "My Account"; 1451 } 1452 else 1453 { 1454 my_account_url = sc_cgi + "?a=purchase_report"; 1455 my_account_title = "My Bookings"; 1456 } 1457 var my_account_new_html = "<li><a href='"+my_account_url+"' title='"+my_account_title+"'>"+my_account_title+"</a></li>"; 1458 var my_deals_html = "<li><a href='/app/member/coupon' title='My Deals' class='top-deals'>My Deals</a></li>"; 1459 var new_html = account_html + "<ul class='dropdown-menu' role='menu'>" + my_account_new_html + my_deals_html + sign_out_new_html + "</ul>"; 1460 if(document.getElementById('tt_responsive_head_login')) 1461 { 1462 if($("#tt_responsive_head_login").closest(".new-header").length > 0) 1463 { 1464 var account_new_html = "<li><a href='"+my_account_url+"' title='"+my_account_title+"'><i class='fa fa-lg icon-gauge'></i> " + my_account_title + "</a></li>"; 1465 var my_deals_new_html = "<li><a href='/app/member/coupon' title='My Deals' class='top-deals'><i class='fa fa-lg icon-gift'></i> My Deals</a></li>"; 1466 var notification_html = '<li><a id="notification_span" href="/app/member/notification/notification-status-list" title="Notifications"><i class="fa icon-mail-alt fa-lg"></i> Notifications</a></li>'; 1467 var wishlist_html = '<li><a href="' + ce_cgi + '?a=my_wishlist" id="wishlist_head" title="My Wishlist"><i class="icon-heart-empty fa-lg"></i> My Wishlist</a></li>'; 1468 var log_out_new_html = "<li><a href='"+signout_url+"' title='Log Out'><i class='fa fa-lg icon-logout'></i> Log Out</a></li>"; 1469 var new_login_html = "<a class='dropdown-toggle' data-toggle='dropdown' href='"+account_url+"'><i class='icon-user fa-lg'></i><span>" + cookie_uid + "</span><i class='icon-angle-down'></i></a>" + 1470 "<ul class='dropdown-menu' role='menu'>" + account_new_html + my_deals_new_html + notification_html + wishlist_html + log_out_new_html + "</ul>"; 1471 $("#tt_responsive_head_login").html(new_login_html); 1472 if($(".new-mobile-header").find(".top-deals").length == 0) 1473 { 1474 $(".account-item-mb").after(my_deals_new_html); 1475 $(".language-item-mb").after(log_out_new_html); 1476 } 1477 update_wishlist_head(); 1478 } 1479 else 1480 { 1481 $("#tt_responsive_head_login").html(new_html); 1482 $("#tt_responsive_head_login").addClass("dropdown"); 1483 } 1484 } 1485 var offcanvas_html = `<a class="user" href="${account_url}"><i class="fa icon-user fa-lg"></i><span title="Acount">${cookie_uid}</span></a>`; 1486 $("#welcome_span_nav").html(offcanvas_html); 1487 if($(".top-deals").find("em").length == 0) 1488 { 1489 var datas = get_local_storage("MyDeals"); 1490 if(datas != null && datas != undefined && datas != "") 1491 { 1492 datas = eval("("+datas+")"); 1493 var num = 0; 1494 for (let data of datas) 1495 { 1496 if(data.endDate != null && data.endDate != undefined && data.endDate != "") 1497 { 1498 var datearr = data.endDate.split("-"); 1499 var endDate = new Date(datearr[0], datearr[1] - 1, datearr[2], 23, 59, 59); 1500 var time_diff = endDate.getTime() - new Date().getTime(); 1501 if(time_diff < 0) 1502 { 1503 } 1504 else 1505 { 1506 num++; 1507 } 1508 } 1509 else 1510 { 1511 num++; 1512 } 1513 } 1514 if(num > 0) 1515 {
1516 if($("#tt_responsive_head_login").closest(".new-header").length > 0) 1517 { 1518 $(".top-deals").html("<i class='fa fa-lg icon-gift'></i> My Deals<em class='num'>" + num + "</em>"); 1519 } 1520 else 1521 { 1522 $(".top-deals").html("My Deals<em>" + num + "</em>"); 1523 } 1524 } 1525 } 1526 } 1527} 1528} 1529 1530$(document).ready(function() { 1531 updateShoppingItems(); 1532 update_new_notification_count_cookie(); 1533 init_tour_vacation_menu(); 1534 init_tour_vacation_menu_group(); 1535 update_wishlist_head(); 1536 show_deals(); 1537 show_compare_products(); 1538 init_top_sellers(); 1539 init_d_img_tours(); 1540 init_traveler_moments(); 1541 init_customer_reviews(); 1542 init_short_title_tabs(); 1543 init_destination_attractions(); 1544 init_destination_routes(); 1545 init_destination_guides(); 1546 init_browsing_tours(); 1547 $(".currency-popover").popover({ 1548 }).on('shown.bs.popover', function () { 1549 switch_currency(); 1550 }); 1551}); 1552 1553function init_destination_guides() 1554{ 1555 var $guides = $("[data-d-guide]"); 1556 if($guides.length == 0) 1557 { 1558 return; 1559 } 1560 update_destination_guide_more(); 1561 $(document).off("click.destinationGuideMore").on("click.destinationGuideMore", ".d-guide-see-more", function(event) { 1562 event.preventDefault(); 1563 var $button = $(this); 1564 var $item = $button.closest(".d-guide-item"); 1565 $item.addClass("is-expanded"); 1566 $button.attr("aria-expanded", "true").hide(); 1567 }); 1568 $(window).off("resize.destinationGuides").on("resize.destinationGuides", function() { 1569 update_destination_guide_more(); 1570 }); 1571} 1572 1573function update_destination_guide_more() 1574{ 1575 $(".d-guide-item").each(function() { 1576 var $item = $(this); 1577 var $text = $item.find(".d-guide-item-text").first(); 1578 var $button = $item.find(".d-guide-see-more").first(); 1579 if($text.length == 0 || $button.length == 0) 1580 { 1581 return; 1582 } 1583 if($item.hasClass("is-expanded")) 1584 { 1585 $button.attr("aria-expanded", "true").hide(); 1586 return; 1587 } 1588 var text = $text.get(0); 1589 var needsMore = text.scrollHeight > text.clientHeight + 1; 1590 $item.toggleClass("has-more", needsMore); 1591 $button.attr("aria-expanded", "false").toggle(needsMore); 1592 }); 1593 $("[data-d-guide]").addClass("is-ready"); 1594} 1595 1596function init_destination_routes() 1597{ 1598 var $routes = $(".d-route-compare"); 1599 if($routes.length == 0) 1600 { 1601 return; 1602 } 1603 $routes.each(function() { 1604 var $compare = $(this); 1605 var isCollapsed = $compare.hasClass("is-collapsed"); 1606 $compare.find(".d-route-compare-title").first().attr("aria-expanded", isCollapsed ? "false" : "true"); 1607 update_destination_route_compare_icon($compare); 1608 }); 1609 $(document).off("click.destinationRoutesCompare").on("click.destinationRoutesCompare", ".d-route-compare-title", function(event) { 1610 event.preventDefault(); 1611 var $compare = $(this).closest(".d-route-compare"); 1612 $compare.toggleClass("is-collapsed"); 1613 $(this).attr("aria-expanded", $compare.hasClass("is-collapsed") ? "false" : "true"); 1614 update_destination_route_compare_icon($compare); 1615 }); 1616} 1617 1618function update_destination_route_compare_icon($compare) 1619{ 1620 var $icon = $compare.find(".d-route-compare-title i").first(); 1621 if($compare.hasClass("is-collapsed")) 1622 { 1623 $icon.removeClass("icon-up-open").addClass("icon-down-open"); 1624 } 1625 else 1626 { 1627 $icon.removeClass("icon-down-open").addClass("icon-up-open"); 1628 } 1629} 1630 1631function init_destination_attractions() 1632{ 1633 var $lists = $(".d-attraction-list"); 1634 if($lists.length == 0) 1635 { 1636 return; 1637 } 1638 $lists.each(function() { 1639 var $list = $(this); 1640 $list.data("destinationAttractionIndex", 0); 1641 update_destination_attraction_track($list, false); 1642 update_destination_attraction_nav($list); 1643 }); 1644 $(document).off("click.destinationAttractionNav").on("click.destinationAttractionNav", ".d-attraction-nav", function(event) { 1645 event.preventDefault(); 1646 var $list = $(this).closest(".d-attraction-list"); 1647 var index = Number($list.data("destinationAttractionIndex") || 0); 1648 var maxIndex = destination_attraction_max_index($list); 1649 if($(this).hasClass("d-attraction-next")) 1650 { 1651 index = Math.min(index + destination_attraction_page_step($list), maxIndex); 1652 } 1653 else 1654 { 1655 index = Math.max(index - destination_attraction_page_step($list), 0); 1656 } 1657 $list.data("destinationAttractionIndex", index); 1658 update_destination_attraction_track($list, true); 1659 update_destination_attraction_nav($list); 1660 }).off("error.destinationAttractionImage").on("error.destinationAttractionImage", ".d-attraction-item-image img", function() { 1661 $(this).closest(".d-attraction-item").addClass("is-image-missing"); 1662 }); 1663 $(window).off("resize.destinationAttractions").on("resize.destinationAttractions", function() { 1664 $(".d-attraction-list").each(function() { 1665 var $list = $(this); 1666 update_destination_attraction_track($list, false); 1667 update_destination_attraction_nav($list); 1668 }); 1669 }); 1670} 1671 1672function destination_attraction_max_index($list) 1673{ 1674 var itemCount = parseInt($list.attr("data-item-count"), 10); 1675 var visibleCount = parseInt($list.attr("data-visible-count"), 10); 1676 if(isNaN(itemCount)) 1677 { 1678 itemCount = $list.find(".d-attraction-item").length; 1679 } 1680 if(isNaN(visibleCount) || visibleCount <= 0) 1681 { 1682 visibleCount = 4; 1683 } 1684 return Math.max(itemCount - visibleCount, 0); 1685} 1686 1687function destination_attraction_page_step($list) 1688{ 1689 var visibleCount = parseInt($list.attr("data-visible-count"), 10); 1690 if(isNaN(visibleCount) || visibleCount <= 0) 1691 { 1692 visibleCount = 4; 1693 } 1694 return Math.max(Math.min(visibleCount, 4), 1); 1695} 1696 1697function update_destination_attraction_track($list, animate) 1698{ 1699 if($list.length == 0) 1700 { 1701 return; 1702 } 1703 var $track = $list.find(".d-attraction-grid").first(); 1704 var cards = $track.find(".d-attraction-item").toArray(); 1705 if(cards.length == 0 || (window.matchMedia && window.matchMedia("(max-width: 991.98px)").matches)) 1706 { 1707 $track.css("transform", ""); 1708 return; 1709 } 1710 var index = Math.max(0, Math.min(Number($list.data("destinationAttractionIndex") || 0), destination_attraction_max_index($list))); 1711 $list.data("destinationAttractionIndex", index); 1712 var firstCard = cards[0]; 1713 var targetCard = cards[index] || firstCard; 1714 var offset = targetCard.getBoundingClientRect().left - firstCard.getBoundingClientRect().left; 1715 if(!animate) 1716 { 1717 $track.css("transition", "none"); 1718 } 1719 $track.css("transform", "translateX(-" + Math.max(offset, 0) + "px)"); 1720 if(!animate) 1721 { 1722 window.setTimeout(function() { 1723 $track.css("transition", ""); 1724 }, 20); 1725 } 1726} 1727 1728function update_destination_attraction_nav($list) 1729{ 1730 if($list.length == 0) 1731 { 1732 return; 1733 } 1734 var isMobile = window.matchMedia && window.matchMedia("(max-width: 991.98px)").matches; 1735 var index = Number($list.data("destinationAttractionIndex") || 0); 1736 var maxIndex = destination_attraction_max_index($list); 1737 $list.find(".d-attraction-prev").toggle(!isMobile && index > 0); 1738 $list.find(".d-attraction-next").toggle(!isMobile && index < maxIndex); 1739} 1740 1741function init_short_title_tabs() 1742{ 1743 var $shortTitleTabs = $(".short-title-tabs"); 1744 if($shortTitleTabs.length == 0) 1745 { 1746 return; 1747 } 1748 1749 $shortTitleTabs.each(function() { 1750 var $tabs = $(this); 1751 $tabs.find("a").each(function() { 1752 var target = $(this).attr("href"); 1753 var $target = target && target.charAt(0) == "#" ? $(target) : $(); 1754 if($target.length == 0 || !$target.is("[data-short-title]")) 1755 { 1756 $(this).closest("li").remove(); 1757 } 1758 }); 1759 if($tabs.find("li").length == 0) 1760 { 1761 $tabs.hide(); 1762 } 1763 }); 1764 $shortTitleTabs = $(".short-title-tabs:visible").filter(function() { 1765 return $(this).find("li").length > 0; 1766 }); 1767 if($shortTitleTabs.length == 0) 1768 { 1769 return; 1770 } 1771 1772 function short_title_tabs_header_offset() 1773 { 1774 var isMobile = window.matchMedia ? window.matchMedia("(max-width: 991px)").matches : $(window).width() < 992; 1775 if(!isMobile) 1776 { 1777 return 0; 1778 } 1779 var $header = $(".new-header-container:visible").first(); 1780 return $header.length > 0 ? Math.ceil($header.outerHeight() || 0) : 55; 1781 } 1782 1783 function update_short_title_tabs_offset() 1784 { 1785 var offset = short_title_tabs_header_offset(); 1786 if(document.documentElement.style && document.documentElement.style.setProperty) 1787 { 1788 document.documentElement.style.setProperty("--short-title-tabs-top", offset + "px"); 1789 } 1790 $(".short-title-tabs.is-fixed").css("top", offset + "px"); 1791 update_short_title_tabs_fixed(); 1792 } 1793 1794 function update_short_title_tabs_fixed() 1795 { 1796 var headerOffset = short_title_tabs_header_offset(); 1797 var scrollTop = $(window).scrollTop(); 1798 $shortTitleTabs.each(function() { 1799 var $tabs = $(this);
1800 var $placeholder = $tabs.prev(".short-title-tabs-placeholder"); 1801 if($placeholder.length == 0) 1802 { 1803 $placeholder = $('<div class="short-title-tabs-placeholder"></div>'); 1804 $tabs.before($placeholder); 1805 } 1806 var originalTop = $placeholder.hasClass("is-active") ? $placeholder.offset().top : $tabs.offset().top; 1807 var shouldFix = scrollTop + headerOffset >= originalTop; 1808 if(shouldFix) 1809 { 1810 $placeholder.height($tabs.outerHeight(true)).addClass("is-active"); 1811 $tabs.addClass("is-fixed").css("top", headerOffset + "px"); 1812 } 1813 else 1814 { 1815 $tabs.removeClass("is-fixed").css("top", ""); 1816 $placeholder.removeClass("is-active").height(0); 1817 } 1818 }); 1819 } 1820 1821 update_short_title_tabs_offset(); 1822 $(window).off("scroll.shortTitleTabs").on("scroll.shortTitleTabs", update_short_title_tabs_fixed); 1823 $(window).off("resize.shortTitleTabs orientationchange.shortTitleTabs").on("resize.shortTitleTabs orientationchange.shortTitleTabs", update_short_title_tabs_offset); 1824 1825 $(document).off("click.shortTitleTabs").on("click.shortTitleTabs", ".short-title-tabs a", function(event) { 1826 var target = $(this).attr("href"); 1827 if(!target || target.charAt(0) != "#") 1828 { 1829 return; 1830 } 1831 var $target = $(target); 1832 if($target.length == 0) 1833 { 1834 return; 1835 } 1836 event.preventDefault(); 1837 update_short_title_tabs_offset(); 1838 var $tabs = $(this).closest(".short-title-tabs"); 1839 var offset = short_title_tabs_header_offset() + ($tabs.outerHeight() || 0) + 12; 1840 var top = Math.max($target.offset().top - offset, 0); 1841 $("html, body").animate({scrollTop: top}, 300); 1842 if(history && history.replaceState) 1843 { 1844 history.replaceState(null, "", target); 1845 } 1846 }); 1847} 1848 1849function init_top_sellers() 1850{ 1851 var $sections = $(".top-seller-section"); 1852 if($sections.length == 0) 1853 { 1854 return; 1855 } 1856 $sections.each(function() { 1857 var $section = $(this); 1858 $section.find(".top-seller-list").each(function() { 1859 var $list = $(this); 1860 $list.data("topSellerIndex", 0); 1861 init_top_seller_show_more($list); 1862 update_top_seller_nav($list); 1863 }); 1864 init_top_seller_wishlist_buttons($section); 1865 $section.find(".top-seller-tab-ul a").off("click.topSellers").on("click.topSellers", function(event) { 1866 event.preventDefault(); 1867 var $link = $(this); 1868 var target = $link.attr("href"); 1869 if(!target) 1870 { 1871 return; 1872 } 1873 $section.find(".top-seller-tab-ul li").removeClass("active"); 1874 $link.parent().addClass("active"); 1875 $section.find(".top-seller-list").removeClass("active"); 1876 var $target = $section.find(target); 1877 $target.addClass("active"); 1878 $target.data("topSellerIndex", 0); 1879 update_top_seller_track($target, false); 1880 update_top_seller_nav($target); 1881 $section.find(".top-seller-head .see-more").removeClass("active"); 1882 $section.find(".top-seller-head .see-more" + target.replace("#tab_", "#see_more")).addClass("active"); 1883 }); 1884 }); 1885 $(document).off("click.topSellersNav").on("click.topSellersNav", ".top-seller-nav", function(event) { 1886 event.preventDefault(); 1887 var $list = $(this).closest(".top-seller-list"); 1888 var index = Number($list.data("topSellerIndex") || 0); 1889 var maxIndex = top_seller_max_index($list); 1890 var pageMode = $list.hasClass("top-seller-list-style-slide") || $list.hasClass("top-seller-left-text"); 1891 if($(this).hasClass("top-seller-next")) 1892 { 1893 index = pageMode ? Math.min(index + top_seller_page_step($list), maxIndex) : maxIndex; 1894 } 1895 else 1896 { 1897 index = pageMode ? Math.max(index - top_seller_page_step($list), 0) : 0; 1898 } 1899 $list.data("topSellerIndex", index); 1900 update_top_seller_track($list, true); 1901 update_top_seller_nav($list); 1902 }).off("click.topSellersMore").on("click.topSellersMore", ".top-seller-show-more", function(event) { 1903 event.preventDefault(); 1904 show_more_top_seller_items($(this).closest(".top-seller-list")); 1905 if(typeof switch_currency == "function") 1906 { 1907 switch_currency(); 1908 } 1909 }); 1910 $(window).off("resize.topSellers").on("resize.topSellers", function() { 1911 $(".top-seller-list").each(function() { 1912 update_top_seller_track($(this), false); 1913 update_top_seller_nav($(this)); 1914 }); 1915 }); 1916} 1917 1918function init_top_seller_show_more($list) 1919{ 1920 if(!$list.hasClass("top-seller-grid") || !$list.hasClass("is-collapsed")) 1921 { 1922 return; 1923 } 1924 var expandedCount = parseInt($list.attr("data-expanded-count"), 10); 1925 if(isNaN(expandedCount) || expandedCount <= 0) 1926 { 1927 expandedCount = 8; 1928 } 1929 $list.data("topSellerVisibleCount", expandedCount); 1930 $list.find(".top-seller-see-all").not(".top-seller-see-all-bottom").hide(); 1931} 1932 1933function show_more_top_seller_items($list) 1934{ 1935 if($list.length == 0) 1936 { 1937 return; 1938 } 1939 var itemCount = parseInt($list.attr("data-item-count"), 10); 1940 var expandedCount = parseInt($list.attr("data-expanded-count"), 10); 1941 if(isNaN(expandedCount) || expandedCount <= 0) 1942 { 1943 expandedCount = 8; 1944 } 1945 if(isNaN(itemCount)) 1946 { 1947 itemCount = $list.find(".top-seller-card").length; 1948 } 1949 var visibleCount = parseInt($list.data("topSellerVisibleCount"), 10); 1950 if(isNaN(visibleCount) || visibleCount <= 0) 1951 { 1952 visibleCount = expandedCount; 1953 } 1954 var nextVisibleCount = Math.min(visibleCount + expandedCount, itemCount); 1955 $list.data("topSellerVisibleCount", nextVisibleCount); 1956 $list.find(".top-seller-card").slice(0, nextVisibleCount).show(); 1957 if(nextVisibleCount >= itemCount) 1958 { 1959 $list.removeClass("is-collapsed").addClass("is-expanded is-all-expanded"); 1960 $list.find(".top-seller-show-more").hide(); 1961 $list.find(".top-seller-see-all").show(); 1962 } 1963} 1964 1965function init_top_seller_wishlist_buttons($scope) 1966{ 1967 var wishlist_pids = get_local_storage("MyProductWishlist"); 1968 $scope.find(".top-seller-card .wishlist-btn[data-pid]").each(function() { 1969 var $button = $(this); 1970 var pid = $button.attr("data-pid"); 1971 var saved = wishlist_pids != null && wishlist_pids.length > 0 && weak_in_array(pid, wishlist_pids) >= 0; 1972 update_top_seller_wishlist_button(pid, saved); 1973 }); 1974} 1975 1976function update_top_seller_wishlist_button(pid, saved) 1977{ 1978 $(".top-seller-card .wishlist-btn").filter(function() { 1979 return String($(this).attr("data-pid")) == String(pid); 1980 }).each(function() { 1981 var $button = $(this); 1982 var title = saved ? "Cancel Saving to Wishlist" : "Save to Wishlist"; 1983 $button.toggleClass("is-saved", saved) 1984 .attr("title", title) 1985 .attr("aria-label", title) 1986 .attr("aria-pressed", saved ? "true" : "false") 1987 .attr("onclick", "top_seller_wishlist_click(event, " + pid + ");"); 1988 $button.find("i").removeClass("icon-heart icon-heart-empty").addClass(saved ? "icon-heart" : "icon-heart-empty"); 1989 }); 1990} 1991
1992function top_seller_wishlist_click(event, pid) 1993{ 1994 if(event) 1995 { 1996 event.preventDefault(); 1997 event.stopPropagation(); 1998 } 1999 var wishlist_pids = get_local_storage("MyProductWishlist"); 2000 if(wishlist_pids != null && wishlist_pids.length > 0 && weak_in_array(pid, wishlist_pids) >= 0) 2001 { 2002 remove_from_wishlist(pid); 2003 } 2004 else 2005 { 2006 save_to_wishlist(pid); 2007 } 2008 return false; 2009} 2010 2011function init_d_img_tours() 2012{ 2013 var $sections = $(".d-img-tours"); 2014 if($sections.length == 0) 2015 { 2016 return; 2017 } 2018 $sections.each(function() { 2019 init_d_img_tours_wishlist_buttons($(this)); 2020 }); 2021} 2022 2023function init_d_img_tours_wishlist_buttons($scope) 2024{ 2025 var wishlist_pids = get_local_storage("MyProductWishlist"); 2026 $scope.find(".d-img-tours-card .wishlist-btn[data-pid]").each(function() { 2027 var $button = $(this); 2028 var pid = $button.attr("data-pid"); 2029 var saved = wishlist_pids != null && wishlist_pids.length > 0 && weak_in_array(pid, wishlist_pids) >= 0; 2030 update_d_img_tours_wishlist_button(pid, saved); 2031 }); 2032} 2033 2034function update_d_img_tours_wishlist_button(pid, saved) 2035{ 2036 $(".d-img-tours-card .wishlist-btn").filter(function() { 2037 return String($(this).attr("data-pid")) == String(pid); 2038 }).each(function() { 2039 var $button = $(this); 2040 var title = saved ? "Cancel Saving to Wishlist" : "Save to Wishlist"; 2041 $button.toggleClass("is-saved", saved) 2042 .attr("title", title) 2043 .attr("aria-label", title) 2044 .attr("aria-pressed", saved ? "true" : "false") 2045 .attr("onclick", "d_img_tours_wishlist_click(event, " + pid + ");"); 2046 $button.find("i").removeClass("icon-heart icon-heart-empty").addClass(saved ? "icon-heart" : "icon-heart-empty"); 2047 }); 2048} 2049 2050function d_img_tours_wishlist_click(event, pid) 2051{ 2052 if(event) 2053 { 2054 event.preventDefault(); 2055 event.stopPropagation(); 2056 } 2057 var wishlist_pids = get_local_storage("MyProductWishlist"); 2058 if(wishlist_pids != null && wishlist_pids.length > 0 && weak_in_array(pid, wishlist_pids) >= 0) 2059 { 2060 remove_from_wishlist(pid); 2061 update_d_img_tours_wishlist_button(pid, false); 2062 } 2063 else 2064 { 2065 save_to_wishlist(pid); 2066 update_d_img_tours_wishlist_button(pid, true); 2067 } 2068 return false; 2069} 2070 2071function top_seller_max_index($list) 2072{ 2073 var itemCount = parseInt($list.attr("data-item-count"), 10); 2074 var visibleCount = parseInt($list.attr("data-visible-count"), 10); 2075 if(isNaN(itemCount)) 2076 { 2077 itemCount = $list.find(".top-seller-card").length; 2078 } 2079 if(isNaN(visibleCount) || visibleCount <= 0) 2080 { 2081 visibleCount = 4; 2082 } 2083 return Math.max(itemCount - visibleCount, 0); 2084} 2085 2086function top_seller_page_step($list) 2087{ 2088 var visibleCount = parseInt($list.attr("data-visible-count"), 10); 2089 if(isNaN(visibleCount) || visibleCount <= 0) 2090 { 2091 visibleCount = 4; 2092 } 2093 return Math.max(Math.min(visibleCount, 4), 1); 2094} 2095 2096function update_top_seller_track($list, animate) 2097{ 2098 if($list.length == 0 || !$list.hasClass("top-seller-carousel")) 2099 { 2100 return; 2101 } 2102 var $viewport = $list.find(".top-seller-viewport"); 2103 var $track = $list.find(".top-seller-track"); 2104 if($track.length == 0) 2105 { 2106 $track = $viewport; 2107 } 2108 var cards = $track.find(".top-seller-card").toArray(); 2109 if(cards.length == 0 || (window.matchMedia && window.matchMedia("(max-width: 991.98px)").matches)) 2110 { 2111 $track.css("transform", ""); 2112 return; 2113 } 2114 var index = Math.max(0, Math.min(Number($list.data("topSellerIndex") || 0), top_seller_max_index($list))); 2115 var firstCard = cards[0]; 2116 var targetCard = cards[index] || firstCard; 2117 var offset = targetCard.getBoundingClientRect().left - firstCard.getBoundingClientRect().left; 2118 if(!animate) 2119 { 2120 $track.css("transition", "none"); 2121 } 2122 $track.css("transform", "translateX(-" + Math.max(offset, 0) + "px)"); 2123 if(!animate) 2124 { 2125 window.setTimeout(function() { 2126 $track.css("transition", ""); 2127 }, 20); 2128 } 2129} 2130 2131function update_top_seller_nav($list) 2132{ 2133 if($list.length == 0 || !$list.hasClass("top-seller-carousel")) 2134 { 2135 return; 2136 } 2137 var isMobile = window.matchMedia && window.matchMedia("(max-width: 991.98px)").matches; 2138 var index = Number($list.data("topSellerIndex") || 0); 2139 var maxIndex = top_seller_max_index($list); 2140 $list.find(".top-seller-pre").toggle(!isMobile && index > 0); 2141 $list.find(".top-seller-next").toggle(!isMobile && index < maxIndex); 2142} 2143 2144function init_traveler_moments() 2145{ 2146 var $lists = $(".tt-moments-list"); 2147 if($lists.length == 0) 2148 { 2149 return; 2150 } 2151 $lists.each(function() { 2152 var $list = $(this); 2153 $list.data("ttMomentsIndex", 0); 2154 update_traveler_moments_track($list, false); 2155 update_traveler_moments_nav($list); 2156 });
2157 $(document).off("click.travelerMomentsNav").on("click.travelerMomentsNav", ".tt-moments-nav", function(event) { 2158 event.preventDefault(); 2159 var $list = $(this).closest(".tt-moments-section").find(".tt-moments-list").first(); 2160 var index = Number($list.data("ttMomentsIndex") || 0); 2161 var maxIndex = traveler_moments_max_index($list); 2162 if($(this).hasClass("tt-moments-next")) 2163 { 2164 index = Math.min(index + traveler_moments_page_step($list), maxIndex); 2165 } 2166 else 2167 { 2168 index = Math.max(index - traveler_moments_page_step($list), 0); 2169 } 2170 $list.data("ttMomentsIndex", index); 2171 update_traveler_moments_track($list, true); 2172 update_traveler_moments_nav($list); 2173 }).off("click.travelerMomentsPlay").on("click.travelerMomentsPlay", ".tt-moments-media", function(event) { 2174 if($(event.target).closest(".tt-moments-product-link").length > 0) 2175 { 2176 return; 2177 } 2178 event.preventDefault(); 2179 toggle_traveler_moments_video($(this)); 2180 this.blur(); 2181 }).off("keydown.travelerMomentsPlay").on("keydown.travelerMomentsPlay", ".tt-moments-media", function(event) { 2182 var key = event.key || ""; 2183 if(key == "Enter" || key == " " || event.which == 13 || event.which == 32) 2184 { 2185 if($(event.target).closest(".tt-moments-product-link").length > 0) 2186 { 2187 return; 2188 } 2189 event.preventDefault(); 2190 toggle_traveler_moments_video($(this)); 2191 } 2192 }).off("ended.travelerMomentsVideo pause.travelerMomentsVideo").on("ended.travelerMomentsVideo pause.travelerMomentsVideo", ".tt-moments-video", function() { 2193 if(this.paused || this.ended) 2194 { 2195 $(this).closest(".tt-moments-media").removeClass("is-playing"); 2196 } 2197 }); 2198 $(window).off("resize.travelerMoments").on("resize.travelerMoments", function() { 2199 $(".tt-moments-list").each(function() { 2200 update_traveler_moments_track($(this), false); 2201 update_traveler_moments_nav($(this)); 2202 }); 2203 }); 2204} 2205 2206function traveler_moments_max_index($list) 2207{ 2208 var itemCount = parseInt($list.attr("data-item-count"), 10); 2209 var visibleCount = parseInt($list.attr("data-visible-count"), 10); 2210 if(isNaN(itemCount)) 2211 { 2212 itemCount = $list.find(".tt-moments-card").length; 2213 } 2214 if(isNaN(visibleCount) || visibleCount <= 0) 2215 { 2216 visibleCount = 5; 2217 } 2218 return Math.max(itemCount - visibleCount, 0); 2219} 2220 2221function traveler_moments_page_step($list) 2222{ 2223 var visibleCount = parseInt($list.attr("data-visible-count"), 10); 2224 if(isNaN(visibleCount) || visibleCount <= 0) 2225 { 2226 visibleCount = 5; 2227 } 2228 return Math.max(Math.min(visibleCount, 5), 1); 2229} 2230 2231function update_traveler_moments_track($list, animate) 2232{ 2233 if($list.length == 0) 2234 { 2235 return; 2236 } 2237 var $track = $list.find(".tt-moments-track"); 2238 if($track.length == 0) 2239 { 2240 return; 2241 } 2242 if(window.matchMedia && window.matchMedia("(max-width: 991.98px)").matches) 2243 { 2244 $track.css("transform", ""); 2245 return; 2246 } 2247 var cards = $track.find(".tt-moments-card").toArray(); 2248 if(cards.length == 0) 2249 { 2250 return; 2251 } 2252 var index = Math.max(0, Math.min(Number($list.data("ttMomentsIndex") || 0), traveler_moments_max_index($list))); 2253 var firstCard = cards[0]; 2254 var targetCard = cards[index] || firstCard; 2255 var offset = targetCard.getBoundingClientRect().left - firstCard.getBoundingClientRect().left; 2256 if(!animate) 2257 { 2258 $track.css("transition", "none"); 2259 } 2260 $track.css("transform", "translateX(-" + Math.max(offset, 0) + "px)"); 2261 if(!animate) 2262 { 2263 window.setTimeout(function() { 2264 $track.css("transition", ""); 2265 }, 20); 2266 } 2267} 2268 2269function update_traveler_moments_nav($list) 2270{ 2271 if($list.length == 0) 2272 { 2273 return; 2274 } 2275 var isMobile = window.matchMedia && window.matchMedia("(max-width: 991.98px)").matches; 2276 var index = Number($list.data("ttMomentsIndex") || 0); 2277 var maxIndex = traveler_moments_max_index($list); 2278 var $section = $list.closest(".tt-moments-section"); 2279 $section.find(".tt-moments-pre").toggle(!isMobile && index > 0); 2280 $section.find(".tt-moments-next").toggle(!isMobile && index < maxIndex); 2281} 2282 2283function toggle_traveler_moments_video($media) 2284{ 2285 if($media.length == 0) 2286 { 2287 return; 2288 } 2289 var video = $media.find(".tt-moments-video").get(0); 2290 if(!video) 2291 { 2292 return; 2293 } 2294 if(video.paused || video.ended) 2295 { 2296 if(!video.getAttribute("src")) 2297 { 2298 var src = $(video).attr("data-src"); 2299 if(!src) 2300 { 2301 return; 2302 } 2303 video.setAttribute("src", src); 2304 video.load(); 2305 } 2306 video.muted = true; 2307 video.setAttribute("muted", "muted");
2308 var playPromise = video.play(); 2309 if(playPromise && typeof playPromise.catch == "function") 2310 { 2311 playPromise.catch(function() { 2312 $media.removeClass("is-playing"); 2313 }); 2314 } 2315 $media.addClass("is-playing"); 2316 } 2317 else 2318 { 2319 video.pause(); 2320 $media.removeClass("is-playing"); 2321 } 2322} 2323 2324function init_customer_reviews() 2325{ 2326 var $lists = $(".d-review"); 2327 if($lists.length == 0) 2328 { 2329 return; 2330 } 2331 $lists.each(function() { 2332 var $list = $(this); 2333 $list.data("dReviewIndex", 0); 2334 update_customer_review_text($list); 2335 update_customer_reviews_track($list, false); 2336 update_customer_reviews_nav($list); 2337 }); 2338 $(document).off("click.customerReviewsNav").on("click.customerReviewsNav", ".d-review-nav", function(event) { 2339 event.preventDefault(); 2340 var $list = $(this).closest(".d-review"); 2341 var index = Number($list.data("dReviewIndex") || 0); 2342 var maxIndex = customer_reviews_max_index($list); 2343 if($(this).hasClass("d-review-next")) 2344 { 2345 index = Math.min(index + customer_reviews_page_step($list), maxIndex); 2346 } 2347 else 2348 { 2349 index = Math.max(index - customer_reviews_page_step($list), 0); 2350 } 2351 $list.data("dReviewIndex", index); 2352 update_customer_reviews_track($list, true); 2353 update_customer_reviews_nav($list); 2354 }).off("click.customerReviewsMore").on("click.customerReviewsMore", ".d-review-more", function(event) { 2355 event.preventDefault(); 2356 var $item = $(this).closest(".d-review-item"); 2357 var $list = $item.closest(".d-review"); 2358 $item.addClass("is-review-expanded").removeClass("has-review-more"); 2359 update_customer_reviews_track($list, false); 2360 }); 2361 $(window).off("resize.customerReviews").on("resize.customerReviews", function() { 2362 $(".d-review").each(function() { 2363 update_customer_review_text($(this)); 2364 update_customer_reviews_track($(this), false); 2365 update_customer_reviews_nav($(this)); 2366 }); 2367 }); 2368} 2369 2370function update_customer_review_text($scope) 2371{ 2372 $scope.find(".d-review-item").each(function() { 2373 var $item = $(this); 2374 if($item.hasClass("is-review-expanded")) 2375 { 2376 return; 2377 } 2378 var text = $item.find(".d-review-text").get(0); 2379 if(!text) 2380 { 2381 return; 2382 } 2383 $item.removeClass("has-review-more"); 2384 if(text.scrollHeight > text.clientHeight + 1) 2385 { 2386 $item.addClass("has-review-more"); 2387 } 2388 }); 2389} 2390 2391function customer_reviews_visible_count($list) 2392{ 2393 if(window.matchMedia && window.matchMedia("(max-width: 767.98px)").matches) 2394 { 2395 return 1; 2396 } 2397 if(window.matchMedia && window.matchMedia("(max-width: 1199.98px)").matches) 2398 { 2399 return 2; 2400 } 2401 var visibleCount = parseInt($list.attr("data-visible-count"), 10); 2402 if(isNaN(visibleCount) || visibleCount <= 0) 2403 { 2404 visibleCount = 3; 2405 } 2406 return visibleCount; 2407} 2408 2409function customer_reviews_max_index($list) 2410{ 2411 var itemCount = parseInt($list.attr("data-item-count"), 10); 2412 if(isNaN(itemCount)) 2413 { 2414 itemCount = $list.find(".d-review-item").length; 2415 } 2416 return Math.max(itemCount - customer_reviews_visible_count($list), 0); 2417} 2418 2419function customer_reviews_page_step($list) 2420{ 2421 return Math.max(customer_reviews_visible_count($list), 1); 2422} 2423 2424function update_customer_reviews_track($list, animate) 2425{ 2426 if($list.length == 0) 2427 { 2428 return; 2429 } 2430 var $track = $list.find(".d-review-track"); 2431 if($track.length == 0) 2432 { 2433 return; 2434 } 2435 if(window.matchMedia && window.matchMedia("(max-width: 991.98px)").matches) 2436 { 2437 $track.css("transform", ""); 2438 return; 2439 } 2440 var cards = $track.find(".d-review-item").toArray(); 2441 if(cards.length == 0) 2442 { 2443 return; 2444 } 2445 var index = Math.max(0, Math.min(Number($list.data("dReviewIndex") || 0), customer_reviews_max_index($list))); 2446 var firstCard = cards[0]; 2447 var targetCard = cards[index] || firstCard; 2448 var offset = targetCard.getBoundingClientRect().left - firstCard.getBoundingClientRect().left; 2449 if(!animate) 2450 { 2451 $track.css("transition", "none"); 2452 } 2453 $track.css("transform", "translateX(-" + Math.max(offset, 0) + "px)"); 2454 if(!animate) 2455 { 2456 window.setTimeout(function() { 2457 $track.css("transition", ""); 2458 }, 20); 2459 } 2460} 2461 2462function update_customer_reviews_nav($list) 2463{ 2464 if($list.length == 0) 2465 { 2466 return; 2467 } 2468 var isMobile = window.matchMedia && window.matchMedia("(max-width: 991.98px)").matches; 2469 var index = Number($list.data("dReviewIndex") || 0); 2470 var maxIndex = customer_reviews_max_index($list); 2471 $list.find(".d-review-pre").toggle(!isMobile && index > 0); 2472 $list.find(".d-review-next").toggle(!isMobile && index < maxIndex); 2473} 2474 2475var browsing_tours_state = { 2476 items: [], 2477 page: 0, 2478 pageSize: 3, 2479 switching: false 2480}; 2481var browsing_tours_cache_key = "browsing_tours_cache"; 2482 2483function init_browsing_tours() 2484{ 2485 var $anchor = $(".search-box-container-new").first(); 2486 if($anchor.find(".background").length == 0 || $("#browsing_tours_section").length > 0 || $(".experience-search-box-container").length > 0) 2487 { 2488 return; 2489 } 2490 var items = browsing_tours_map_to_items(browsing_tours_read_cache()); 2491 if(items.length == 0) 2492 { 2493 return; 2494 } 2495 browsing_tours_state.items = items; 2496 browsing_tours_state.page = 0; 2497 bind_browsing_tours_resize(); 2498 $anchor.after('<section id="browsing_tours_section" class="browsing-tours-section container"></section>'); 2499 render_browsing_tours(); 2500 } 2501 2502function browsing_tours_read_cache() 2503{ 2504 try 2505 { 2506 var cache = window.localStorage ? window.localStorage.getItem(browsing_tours_cache_key) : null; 2507 if(!cache) 2508 { 2509 return []; 2510 } 2511 var cacheData = JSON.parse(cache); 2512 if(!cacheData || !cacheData.expiresAt || cacheData.expiresAt < new Date().getTime()) 2513 { 2514 window.localStorage.removeItem(browsing_tours_cache_key); 2515 return []; 2516 } 2517 return $.isArray(cacheData.items) ? cacheData.items : []; 2518 } 2519 catch(e) 2520 { 2521 if(window.localStorage) 2522 { 2523 window.localStorage.removeItem(browsing_tours_cache_key); 2524 } 2525 return []; 2526 } 2527} 2528 2529function browsing_tours_map_to_items(productMap) 2530{ 2531 var items = []; 2532 if(!productMap) 2533 { 2534 return items; 2535 } 2536 if($.isArray(productMap)) 2537 { 2538 for(var i = 0; i < productMap.length; i++) 2539 { 2540 if(productMap[i]) 2541 { 2542 productMap[i]._browsingTourIndex = i; 2543 items.push(productMap[i]); 2544 } 2545 } 2546 return browsing_tours_sort_items(items); 2547 } 2548 var index = 0; 2549 $.each(productMap, function(pid, item) { 2550 if(item) 2551 { 2552 if(!item.pid) 2553 { 2554 item.pid = pid; 2555 } 2556 item._browsingTourIndex = index++; 2557 items.push(item); 2558 } 2559 }); 2560 return browsing_tours_sort_items(items); 2561} 2562 2563function browsing_tours_sort_items(items) 2564{ 2565 return items.sort(function(left, right) { 2566 var leftOrder = parseInt(left.displayOrder, 10); 2567 var rightOrder = parseInt(right.displayOrder, 10); 2568 if(!isNaN(leftOrder) && !isNaN(rightOrder) && leftOrder != rightOrder) 2569 { 2570 return leftOrder - rightOrder; 2571 } 2572 return Number(left._browsingTourIndex || 0) - Number(right._browsingTourIndex || 0); 2573 }); 2574} 2575 2576function render_browsing_tours() 2577{ 2578 var $section = $("#browsing_tours_section"); 2579 if($section.length == 0 || browsing_tours_state.items.length == 0) 2580 { 2581 return; 2582 } 2583 var items = browsing_tours_state.items; 2584 var mobile = is_browsing_tours_mobile(); 2585 browsing_tours_state.pageSize = browsing_tours_page_size(); 2586 var maxPage = browsing_tours_max_start_index(); 2587 if(!mobile && browsing_tours_state.page > maxPage) 2588 { 2589 browsing_tours_state.page = maxPage; 2590 } 2591 var visibleItems = items; 2592 var singleClass = items.length == 1 ? " is-single" : ""; 2593 var html = '<h2 class="browsing-tours-title">Continue Planning Your Trip</h2>' + 2594 '<div class="browsing-tours-shell' + singleClass + '">' + 2595 '<button type="button" class="browsing-tours-nav browsing-tours-prev" aria-label="Previous" style="' + (!mobile && browsing_tours_state.page > 0 ? "" : "display:none;") + '"><i class="fa icon-angle-left"></i></button>' + 2596 '<div class="browsing-tours-viewport"><div class="browsing-tours-list">'; 2597 for(var i = 0; i < visibleItems.length; i++) 2598 { 2599 html += browsing_tours_card_html(visibleItems[i]); 2600 } 2601 html += '</div></div>' + 2602 '<button type="button" class="browsing-tours-nav browsing-tours-next" aria-label="Next" style="' + (!mobile && browsing_tours_state.page < maxPage ? "" : "display:none;") + '"><i class="fa icon-angle-right"></i></button>' + 2603 '</div>'; 2604 $section.html(html); 2605 browsing_tours_apply_logo_backgrounds($section); 2606 update_browsing_tours_track(false); 2607 update_browsing_tours_nav(); 2608 $section.find(".browsing-tours-prev").click(function() { 2609 if(!browsing_tours_state.switching && browsing_tours_state.page > 0) 2610 { 2611 switch_browsing_tours_page(browsing_tours_state.page - browsing_tours_page_step(), -1); 2612 } 2613 }); 2614 $section.find(".browsing-tours-next").click(function() { 2615 if(!browsing_tours_state.switching && browsing_tours_state.page < maxPage) 2616 { 2617 switch_browsing_tours_page(browsing_tours_state.page + browsing_tours_page_step(), 1); 2618 } 2619 }); 2620 $section.find(".browsing-tour-badge").click(function(event) { 2621 event.preventDefault(); 2622 event.stopPropagation(); 2623 show_browsing_tour_badge_tooltip($(this)); 2624 }).mouseenter(function() { 2625 show_browsing_tour_badge_tooltip($(this)); 2626 }).mouseleave(function() { 2627 $("#browsing_tour_badge_tooltip").remove(); 2628 }); 2629 $section.find(".browsing-tour-card").click(function(event) { 2630 if($(event.target).closest(".browsing-tour-badge").length > 0) 2631 { 2632 return; 2633 } 2634 var href = $(this).attr("data-href"); 2635 if(href) 2636 { 2637 window.location.href = href; 2638 } 2639 }); 2640 $section.find(".browsing-tour-link").keydown(function(event) { 2641 if(event.keyCode == 13) 2642 { 2643 $(this).closest(".browsing-tour-card").click(); 2644 } 2645 }); 2646} 2647 2648function switch_browsing_tours_page(nextPage, direction) 2649{ 2650 if(is_browsing_tours_mobile()) 2651 { 2652 browsing_tours_state.page = nextPage; 2653 render_browsing_tours(); 2654 return; 2655 } 2656 browsing_tours_state.switching = true; 2657 nextPage = Math.max(0, Math.min(nextPage, browsing_tours_max_start_index())); 2658 browsing_tours_state.page = nextPage; 2659 update_browsing_tours_nav(); 2660 update_browsing_tours_track(true); 2661 window.setTimeout(function() { 2662 browsing_tours_state.switching = false;
2663 }, 820); 2664} 2665 2666function update_browsing_tours_nav() 2667{ 2668 var maxPage = browsing_tours_max_start_index(); 2669 var mobile = is_browsing_tours_mobile(); 2670 $("#browsing_tours_section .browsing-tours-prev").toggle(!mobile && browsing_tours_state.page > 0); 2671 $("#browsing_tours_section .browsing-tours-next").toggle(!mobile && browsing_tours_state.page < maxPage); 2672} 2673 2674function browsing_tours_max_start_index() 2675{ 2676 return Math.max(browsing_tours_state.items.length - browsing_tours_state.pageSize, 0); 2677} 2678 2679function browsing_tours_page_step() 2680{ 2681 return Math.max(Math.min(browsing_tours_state.pageSize, browsing_tours_max_start_index()), 1); 2682} 2683 2684function browsing_tours_page_size() 2685{ 2686 if(window.matchMedia && window.matchMedia("(min-width: 992px) and (max-width: 1399.98px)").matches) 2687 { 2688 return 2; 2689 } 2690 return 3; 2691} 2692 2693function update_browsing_tours_track(animate) 2694{ 2695 var $list = $("#browsing_tours_section .browsing-tours-list"); 2696 var $card = $list.find(".browsing-tour-card").first(); 2697 if($list.length == 0 || $card.length == 0) 2698 { 2699 return; 2700 } 2701 if(is_browsing_tours_mobile()) 2702 { 2703 $list.css("transform", ""); 2704 return; 2705 } 2706 var cards = $list.find(".browsing-tour-card").toArray(); 2707 var firstCard = cards[0]; 2708 var targetCard = cards[browsing_tours_state.page] || firstCard; 2709 var offset = targetCard.getBoundingClientRect().left - firstCard.getBoundingClientRect().left; 2710 if(browsing_tours_state.page > 0) 2711 { 2712 offset = Math.max(offset - 1, 0); 2713 } 2714 if(!animate) 2715 { 2716 $list.addClass("no-transition"); 2717 } 2718 $list.css("transform", "translateX(-" + offset + "px)"); 2719 if(!animate) 2720 { 2721 window.setTimeout(function() { 2722 $list.removeClass("no-transition"); 2723 }, 20); 2724 } 2725} 2726 2727function browsing_tours_card_html(item) 2728{ 2729 var pid = browsing_tours_escape_attr(item.pid || ""); 2730 var logo = browsing_tours_escape_attr(item.logo || ""); 2731 var name = browsing_tours_escape_html(item.name || ""); 2732 var tag = item.tag && item.tag.name ? browsing_tours_escape_html(item.tag.name) : ""; 2733 var tagClass = item.tag && item.tag.colorClass ? browsing_tours_escape_attr(item.tag.colorClass) : "color-blue"; 2734 var tagDescription = item.tag && item.tag.description ? String(item.tag.description) : tag; 2735 var tagTitle = browsing_tours_escape_attr(tagDescription); 2736 var displayPrice = item.displayPriceText || (item.displayPrice ? "$" + item.displayPrice : ""); 2737 var originalPrice = item.originalPriceText || (item.originalPrice ? "$" + item.originalPrice : ""); 2738 var href = browsing_tours_escape_attr(item.productUrl || ("/page/tour-package/" + pid + ".html")); 2739 var reviewHtml = browsing_tours_review_html(item); 2740 return '<article class="browsing-tour-card" data-href="' + href + '">' + 2741 '<div class="browsing-tour-link" role="link" tabindex="0">' + 2742 '<div class="browsing-tour-logo-wrap">' + 2743 (logo ? '<span class="browsing-tour-logo" data-logo="' + logo + '" role="img" aria-label="' + browsing_tours_escape_attr(item.name || "") + '"></span>' : '<span class="browsing-tour-logo-placeholder"></span>') + 2744 '</div>' + 2745 '<div class="browsing-tour-body">' + 2746 '<h3 class="browsing-tour-name">' + name + '</h3>' + 2747 (tag ? '<div class="browsing-tour-badge-row"><span class="tp-promo-badge browsing-tour-badge product-tag ' + tagClass + '" data-description-html="' + tagTitle + '">' + tag + '</span></div>' : '') + 2748 '<div class="browsing-tour-meta-price">' + 2749 reviewHtml + 2750 '<span class="browsing-tour-price ' + (originalPrice ? 'has-original-price' : 'no-original-price') + '"><span class="browsing-tour-price-top"><span class="browsing-tour-from">From</span>' + (originalPrice ? ' <del>' + originalPrice + '</del>' : '') + '</span>' + (originalPrice ? '' : ' ') + '<strong>' + displayPrice + '</strong></span>' + 2751 '</div>' + 2752 '</div>' + 2753 '</div>' + 2754 '</article>'; 2755} 2756 2757function browsing_tours_apply_logo_backgrounds($section) 2758{ 2759 $section.find(".browsing-tour-logo[data-logo]").each(function() { 2760 var logo = $(this).attr("data-logo"); 2761 if(logo) 2762 { 2763 $(this).css("background-image", 'url("' + logo.replace(/"/g, '\\"') + '")'); 2764 } 2765 }); 2766} 2767 2768function browsing_tours_review_html(item) 2769{ 2770 var count = parseInt(item.reviewCount, 10); 2771 var rating = parseFloat(item.averageRating); 2772 if(isNaN(count) || count <= 0 || isNaN(rating) || rating <= 0) 2773 { 2774 return '<span class="browsing-tour-review"> </span>'; 2775 } 2776 var ratingText = rating.toFixed(1).replace(/\.0$/, ""); 2777 return '<span class="browsing-tour-review"><span class="browsing-tour-review-rating"><strong>' + browsing_tours_escape_html(ratingText) + '</strong> <i class="fa icon-star"></i></span> <em>(' + browsing_tours_escape_html(browsing_tours_format_count(count)) + ')</em></span>'; 2778} 2779 2780function browsing_tours_format_count(count) 2781{ 2782 return String(count).replace(/\B(?=(\d{3})+(?!\d))/g, ","); 2783} 2784 2785function is_browsing_tours_mobile() 2786{ 2787 return window.matchMedia && window.matchMedia("(max-width: 991.98px)").matches; 2788} 2789 2790function browsing_tours_escape_html(value) 2791{ 2792 return String(value).replace(/[&<>"']/g, function(ch) { 2793 return {"&":"&","<":"<",">":">","\"":""","'":"'"}[ch]; 2794 }); 2795} 2796 2797function browsing_tours_escape_attr(value) 2798{ 2799 return browsing_tours_escape_html(value); 2800} 2801 2802function show_browsing_tour_badge_tooltip($badge) 2803{ 2804 var html = $badge.attr("data-description-html") || browsing_tours_escape_html($badge.text()); 2805 $("#browsing_tour_badge_tooltip").remove(); 2806 if(!html) 2807 { 2808 return; 2809 } 2810 var offset = $badge.offset(); 2811 var $tooltip = $('<div id="browsing_tour_badge_tooltip" class="browsing-tour-badge-tooltip"></div>').html(html).appendTo("body"); 2812 var badgeCenter = offset.left + ($badge.outerWidth() / 2); 2813 var left = badgeCenter - ($tooltip.outerWidth() / 2); 2814 var top = offset.top + $badge.outerHeight() + 7; 2815 var minLeft = $(window).scrollLeft() + 8; 2816 var maxLeft = $(window).scrollLeft() + $(window).width() - $tooltip.outerWidth() - 8; 2817 if(left < minLeft) 2818 { 2819 left = minLeft; 2820 } 2821 if(left > maxLeft) 2822 { 2823 left = Math.max(minLeft, maxLeft); 2824 } 2825 var arrowLeft = badgeCenter - left; 2826 arrowLeft = Math.max(12, Math.min($tooltip.outerWidth() - 12, arrowLeft)); 2827 $tooltip.css({ 2828 left: left, 2829 top: top 2830 }); 2831 $tooltip.css("--tooltip-arrow-left", arrowLeft + "px"); 2832 if(typeof switch_currency == "function") 2833 { 2834 switch_currency(); 2835 } 2836} 2837 2838function bind_browsing_tours_resize() 2839{
2840 $(document).off("click.browsingToursBadge").on("click.browsingToursBadge", function() { 2841 $("#browsing_tour_badge_tooltip").remove(); 2842 }); 2843 $(window).off("resize.browsingTours").on("resize.browsingTours", function() { 2844 $("#browsing_tour_badge_tooltip").remove(); 2845 if($("#browsing_tours_section").length > 0) 2846 { 2847 render_browsing_tours(); 2848 } 2849 }); 2850} 2851 2852function updateShoppingItems() 2853{ 2854 var items_count = get_cookie('IvyCustomer_ShoppingItems'); 2855 if(items_count && items_count > 0) 2856 { 2857 if(items_count > 99) 2858 { 2859 items_count = "99+"; 2860 } 2861 if($("#lan_shopping_cart_nav").find(".num").length > 0) 2862 { 2863 $("#lan_shopping_cart_nav").find(".num").html(items_count); 2864 } 2865 else 2866 { 2867 $("#lan_shopping_cart_nav").append("<em class='num'>"+items_count+"</em>"); 2868 } 2869 if($("#lan_shopping_cart_new").find(".num").length > 0) 2870 { 2871 $("#lan_shopping_cart_new").find(".num").html(items_count); 2872 } 2873 else 2874 { 2875 $("#lan_shopping_cart_new").append("<em class='num'>"+items_count+"</em>");//taketours 2876 } 2877 } 2878 else 2879 { 2880 $("#lan_shopping_cart_nav").find(".num").remove(); 2881 $("#lan_shopping_cart_new").find(".num").remove(); 2882 } 2883} 2884 2885function update_new_notification_count_cookie() 2886{ 2887 var new_notification_count = get_cookie("IvyCustomer_NewNotificationCount"); 2888 if(new_notification_count > 0) 2889 { 2890 if(new_notification_count > 99) 2891 { 2892 new_notification_count = "99+"; 2893 } 2894 if($("#notification_span a").length > 0) 2895 { 2896 $("#notification_span a").append("<em>" + new_notification_count + "</em>"); 2897 $("#notification_span_nav a").append("<em>" + new_notification_count + "</em>"); 2898 } 2899 else 2900 { 2901 $("#notification_span").append("<em class='num'>" + new_notification_count + "</em>"); 2902 $("#notification_span_nav").append("<em class='num'>" + new_notification_count + "</em>"); 2903 } 2904 } 2905} 2906 2907function bindModernClickGoogleMap() 2908{ 2909 try{ 2910 if($("a[click_google_map='1']").length > 0) 2911 { 2912 $("a[click_google_map='1']").click(function(){ 2913 var city_id = $(this).attr("id"); 2914 if(city_id) 2915 { 2916 show_city_map(city_id); 2917 } 2918 else 2919 { 2920 $("#map_canvas_div").remove(); 2921 var longitude = $(this).attr("longitude"); 2922 var latitude = $(this).attr("latitude"); 2923 var full_text = $(this).attr("full_text"); 2924 var is_responsive = $(this).attr("is_responsive"); 2925 if($("#map_canvas_div").length == 0) 2926 { 2927 var title_info = $(this).attr("name") + " map"; 2928 if(is_responsive) 2929 { 2930 $(this).after("<div id='map_canvas_div' style='margin:8px 0;' title='" +title_info+"'><div id='map_canvas' style='width:265px;height:400px;' ivy_goto_google_map='1'></div></div>"); 2931 } 2932 else 2933 { 2934 $(this).after("<div id='map_canvas_div' style='margin:8px 0;' title='" +title_info+"'><div id='map_canvas' style='width:520px;height:400px;' ivy_goto_google_map='1'></div></div>"); 2935 } 2936 } 2937 var name = "<div class='font12' style='margin-top:15px;margin-left:10px;'>" +full_text+"</div>"; 2938 if(typeof(google) != "undefined") 2939 { 2940 var myLatlng = new google.maps.LatLng(latitude,longitude); 2941 var myOptions = { 2942 zoom: 15, 2943 center: myLatlng, 2944 mapTypeId: google.maps.MapTypeId.ROADMAP, 2945 scaleControl : false, 2946 mapTypeControl : false, 2947 zoomControlOptions: { 2948 style: google.maps.ZoomControlStyle.BIG, 2949 position: google.maps.ControlPosition.LEFT_TOP 2950 } 2951 } 2952 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 2953 var marker1 = new google.maps.Marker({ 2954 position: myLatlng, 2955 map: map 2956 }) 2957 infowindow = new google.maps.InfoWindow( 2958 { 2959 content: name, 2960 size : new google.maps.Size(20, 30), 2961 maxWidth:180 2962 2963 }); 2964 2965 google.maps.event.addListener(marker1, 'click', function(e){ 2966 2967 infowindow.open(map,marker1); 2968 }); 2969 infowindow.open(map,marker1); 2970 } 2971 $("#map_canvas_div").dialog({ 2972 width: "auto", 2973 height: "auto", 2974 resizable: false 2975 }); 2976 } 2977 2978 }); 2979 } 2980 } 2981 catch(e) 2982 { 2983 2984 } 2985 set_load_map_finish(); 2986} 2987 2988 2989function show_city_map(city_id) 2990{ 2991 var methods = 'show_city_map_detail("' + city_id + '");'; 2992 load_google_map_js('', methods); 2993} 2994 2995function show_city_map_detail(city_id) 2996{ 2997 var obj = $("#" + city_id); 2998 $("#map_canvas_div").remove(); 2999 var longitude = $(obj).attr("longitude"); 3000 var latitude = $(obj).attr("latitude"); 3001 var full_text = $(obj).attr("full_text"); 3002 var is_responsive = $(obj).attr("is_responsive"); 3003 if($("#map_canvas_div").length == 0) 3004 { 3005 var title_info = $(obj).attr("name") + " map"; 3006 if(is_responsive) 3007 { 3008 $(obj).after("<div id='map_canvas_div' style='margin:8px 0;' title='" +title_info+"'><div id='map_canvas' style='width:265px;height:400px;' ivy_goto_google_map='1'></div></div>"); 3009 } 3010 else 3011 { 3012 $(obj).after("<div id='map_canvas_div' style='margin:8px 0;' title='" +title_info+"'><div id='map_canvas' style='width:520px;height:400px;' ivy_goto_google_map='1'></div></div>"); 3013 } 3014 } 3015 var name = "<div class='font12' style='margin-top:15px;margin-left:10px;'>" +full_text+"</div>"; 3016 if(typeof(google) != "undefined") 3017 { 3018 var myLatlng = new google.maps.LatLng(latitude,longitude); 3019 var myOptions = { 3020 zoom: 15, 3021 center: myLatlng, 3022 mapTypeId: google.maps.MapTypeId.ROADMAP, 3023 scaleControl : false, 3024 mapTypeControl : false, 3025 zoomControlOptions: { 3026 style: google.maps.ZoomControlStyle.BIG, 3027 position: google.maps.ControlPosition.LEFT_TOP 3028 } 3029 } 3030 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 3031 var marker1 = new google.maps.Marker({ 3032 position: myLatlng, 3033 map: map 3034 }) 3035 infowindow = new google.maps.InfoWindow({ 3036 content: name, 3037 size : new google.maps.Size(20, 30), 3038 maxWidth:180 3039 }); 3040 google.maps.event.addListener(marker1, 'click', function(e){ 3041 infowindow.open(map,marker1); 3042 }); 3043 infowindow.open(map,marker1); 3044 } 3045 $("#map_canvas_div").dialog({ 3046 width: "auto", 3047 height: "auto", 3048 resizable: false 3049 }); 3050} 3051 3052function submit_pagination_click(obj) 3053{ 3054 var current_page = $(obj).attr('ivy_current_page'); 3055 var current_page_hidden_html = '<input type="hidden" name="current_page" id="current_page" value="' + current_page + '" >'; 3056 $(obj).closest("form[ivy_pagination_sumit_form='1']").append(current_page_hidden_html); 3057 $(obj).closest("form[ivy_pagination_sumit_form='1']").submit(); 3058 3059} 3060 3061 3062function validateXML(txt) 3063{ 3064 // code for IE 3065 if (window.ActiveXObject) 3066 { 3067 var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 3068 xmlDoc.async="false"; 3069 xmlDoc.loadXML(document.all(txt).value); 3070 3071 if(xmlDoc.parseError.errorCode!=0) 3072 { 3073 txt="Error Code: " + xmlDoc.parseError.errorCode; 3074 txt=txt+"Error Reason: " + xmlDoc.parseError.reason; 3075 txt=txt+"Error Line: " + xmlDoc.parseError.line; 3076 alert(txt); 3077 return false;
3078 } 3079 else 3080 { 3081 return true; 3082 } 3083 3084 } 3085 // code for Mozilla, Firefox, Opera, etc. 3086 else if (document.implementation.createDocument) 3087 { 3088 var parser=new DOMParser(); 3089 var text=document.getElementById(txt).value; 3090 var xmlDoc=parser.parseFromString(text,"text/xml"); 3091 3092 if (xmlDoc.documentElement.nodeName=="parsererror") 3093 { 3094 3095 var msg = xmlDoc.documentElement.childNodes[0].nodeValue; 3096 alert(msg); 3097 return false; 3098 } 3099 else 3100 { 3101 return true; 3102 } 3103 } 3104 else 3105 { 3106 alert('Your browser cannot handle XML validation'); 3107 return false; 3108 } 3109} 3110 3111function create_tab_slide(name, slideWidth, display_count) 3112{ 3113 if(typeof(display_count) == "undefined") 3114 { 3115 display_count = 3; 3116 } 3117 $(document).ready(function(){ 3118 var currentPosition = 0; 3119 var slides = $('.des_sortContent'+name); 3120 var numberOfSlides = slides.length; 3121 $('#des_sortBox'+name).css('overflow', 'hidden'); 3122 slides.wrapAll('<div id="slideInner'+name+'"></div>').css({ 3123 'float' : 'left', 3124 'width' : slideWidth, 3125 'margin-right' : "6px", 3126 '_margin-right' : "3px" 3127 }); 3128 slides.eq(numberOfSlides - 1).css({'margin-right' : "0px"}); 3129 if(numberOfSlides == 1) 3130 { 3131 slides.eq(numberOfSlides - 1).css({'width' : "100%"}); 3132 $('#slideInner'+name).css('width', "100%"); 3133 return ''; 3134 } 3135 else 3136 { 3137 if(slideWidth>300) 3138 { 3139 if(name.match(/bottom/)) 3140 { 3141 $('#slideInner'+name).css('width', slideWidth * numberOfSlides + (numberOfSlides + 1) * 5.5 + slideWidth * 40); 3142 } 3143 else 3144 { 3145 $('#slideInner'+name).css('width', slideWidth * numberOfSlides + (numberOfSlides + 1) * 5.5); 3146 } 3147 } 3148 else 3149 { 3150 3151 $('#slideInner'+name).css('width', slideWidth * numberOfSlides + (numberOfSlides + 1) * 5); 3152 } 3153 } 3154 3155 if(numberOfSlides > 1) 3156 { 3157 if(slideWidth > 800) 3158 { 3159 $('#des_slideBox'+name) 3160 .prepend('<a id="des_sortL'+name+'" class="deals_slideArrowL" style="display:none;" href="javascript:void(0)"></a><a id="des_sortActiveL'+name+'" class="des_control deals_slideArrowActiveL des_control'+name+'" href="javascript:void(0)"></a>') 3161 .append('<a id="des_sortR'+name+'" class="deals_slideArrowR" style="display:none;" href="javascript:void(0)"></a><a id="des_sortActiveR'+name+'" class="des_control deals_slideArrowActiveR des_control'+name+'" href="javascript:void(0)"></a>'); 3162 } 3163 else 3164 { 3165 $('#des_slideBox'+name) 3166 .prepend('<a id="des_sortL'+name+'" class="des_n_sortL" style="display:none;" href="javascript:void(0)"></a><a id="des_sortActiveL'+name+'" class="des_control des_n_sortActiveL des_control'+name+'" href="javascript:void(0)"></a>') 3167 .append('<a id="des_sortR'+name+'" class="des_n_sortR" style="display:none;" href="javascript:void(0)"></a><a id="des_sortActiveR'+name+'" class="des_control des_n_sortActiveR des_control'+name+'" href="javascript:void(0)"></a>'); 3168 } 3169 3170 } 3171 manageControls(currentPosition, name, numberOfSlides, slideWidth,display_count); 3172 3173 $('.des_control'+name) 3174 .bind('click', function(){ 3175 currentPosition = ($(this).attr('id')=='des_sortActiveR'+name) ? currentPosition+1 : currentPosition-1; 3176 manageControls(currentPosition, name, numberOfSlides, slideWidth, display_count); 3177 var m_left = slideWidth*(-currentPosition); 3178 $("#current_page"+name).html(currentPosition + 1); 3179 if(currentPosition > 0) 3180 { 3181 if(currentPosition + 3 == numberOfSlides && slideWidth<300) 3182 { 3183 m_left = m_left -6 * 2; 3184 } 3185 else 3186 { 3187 if(slideWidth > 300) 3188 { 3189 if(name.match(/bottom/)) 3190 { 3191 m_left = m_left -46 *(currentPosition); 3192 } 3193 else 3194 { 3195 3196 m_left = m_left -6 *(currentPosition); 3197 } 3198 } 3199 else 3200 { 3201 m_left = m_left -6; 3202 } 3203 3204 } 3205 } 3206 $('#slideInner'+name).animate({ 3207 'marginLeft' : m_left 3208 }); 3209 }); 3210 $('#start_over'+name) 3211 .bind('click', function(){ 3212 currentPosition = 0; 3213 manageControls(currentPosition, name, numberOfSlides, slideWidth, display_count); 3214 var m_left = slideWidth*(-currentPosition); 3215 $("#current_page"+name).html(currentPosition + 1); 3216 if(currentPosition > 0) 3217 { 3218 if(currentPosition + 3 == numberOfSlides && slideWidth<300) 3219 { 3220 m_left = m_left -6 * 2; 3221 } 3222 else 3223 { 3224 if(slideWidth > 300) 3225 { 3226 m_left = m_left -6 *(currentPosition); 3227 } 3228 else 3229 { 3230 m_left = m_left -6; 3231 } 3232 3233 } 3234 } 3235 $('#slideInner'+name).animate({ 3236 'marginLeft' : m_left 3237 }); 3238 }); 3239 3240 3241}); 3242} 3243 3244function manageControls(position, name, numberOfSlides, slideWidth, display_count) 3245{ 3246 if(slideWidth > 300) 3247 { 3248 if(numberOfSlides ==1) 3249 { 3250 $('#des_sortActiveL'+name).hide(); 3251 $('#des_sortActiveR'+name).hide(); 3252 $('#des_sortR'+name).hide(); 3253 $('#des_sortL'+name).hide(); 3254 } 3255 else 3256 { 3257 if(position + 1==numberOfSlides) 3258 { 3259 $('#des_sortActiveR'+name).hide(); 3260 $('#des_sortR'+name).show(); 3261 $('#des_sortActiveL'+name).show(); 3262 $('#des_sortL'+name).hide(); 3263 3264 } 3265 else 3266 {
3267 if(position==0) 3268 { 3269 $('#des_sortActiveL'+name).hide(); 3270 $('#des_sortL'+name).show(); 3271 3272 } 3273 else 3274 { 3275 $('#des_sortActiveL'+name).show(); 3276 $('#des_sortL'+name).hide(); 3277 } 3278 $('#des_sortActiveR'+name).show(); 3279 $('#des_sortR'+name).hide(); 3280 3281 } 3282 } 3283 } 3284 else 3285 { 3286 if(numberOfSlides <=display_count) 3287 { 3288 $('#des_sortActiveL'+name).hide(); 3289 $('#des_sortActiveR'+name).hide(); 3290 $('#des_sortR'+name).show(); 3291 $('#des_sortL'+name).show(); 3292 } 3293 else 3294 { 3295 if(position + display_count==numberOfSlides) 3296 { 3297 $('#des_sortActiveR'+name).hide(); 3298 $('#des_sortR'+name).show(); 3299 $('#des_sortActiveL'+name).show(); 3300 $('#des_sortL'+name).hide(); 3301 3302 } 3303 else 3304 { 3305 if(position==0) 3306 { 3307 $('#des_sortActiveL'+name).hide(); 3308 $('#des_sortL'+name).show(); 3309 3310 } 3311 else 3312 { 3313 $('#des_sortActiveL'+name).show(); 3314 $('#des_sortL'+name).hide(); 3315 } 3316 $('#des_sortActiveR'+name).show(); 3317 $('#des_sortR'+name).hide(); 3318 3319 } 3320 } 3321 } 3322 3323} 3324 3325/* old ac common_v1 end*/ 3326 3327function init_google_map_js(fun_name, is_mobile, need_places) 3328{ 3329 var google_map_url = google_map_api_url; 3330 if(need_places) 3331 { 3332 google_map_url += "&libraries=places"; 3333 }
3334 document.write('<' + 'script src="' + google_map_url + '"' + ' type="text/javascript"><' + '/script>'); 3335 if (fun_name == 'initialize_google_marker_label') 3336 { 3337 document.write('<' + 'script src="' + google_map_jquery_url + '"' + ' type="text/javascript"><' + '/script>'); 3338 document.write('<' + 'script src="' + google_map_market_label_url + '"' + ' type="text/javascript"><' + '/script>'); 3339 } 3340} 3341 3342function set_load_map_finish() 3343{ 3344 $("div[ivy_goto_google_map='1']").attr("load_finish", 1); 3345} 3346 3347function initialize_google_marker_label() 3348{ 3349 $.getScript(google_map_jquery_url, 3350 function() { 3351 $.getScript(google_map_market_label_url, 3352 function() { 3353 set_load_map_finish(); 3354 }); 3355 }); 3356} 3357 3358function check_google_map_load_finish(map_div_id) 3359{ 3360 var map_id = 'departure_map'; 3361 return true; 3362} 3363 3364function auto_select_credit_card_type(obj) 3365{ 3366 var card_number = $(obj).val(); 3367 if (card_number && card_number != "") 3368 { 3369 var first_num = card_number.substr(0, 1); 3370 if (first_num == 3 || first_num == 4 || first_num == 5) 3371 { 3372 var card_type = 3; 3373 if (first_num == 4) 3374 { 3375 card_type = 2; 3376 } 3377 else if (first_num == 5) 3378 { 3379 card_type = 1; 3380 } 3381 $("select[id='card_type']").val(card_type); 3382 } 3383 } 3384} 3385 3386function init_time_selector() 3387{ 3388 $(".TimeScopeC").each(function(){ 3389 var time_display = $(this).parent().find("#time_display").val(); 3390 $(this).html(time_display); 3391 var searchTimeValue = $(this).parent().find("#searchTimeValue").val(); 3392 var active_li = $(this).parent().find("span[seletor_tag='"+searchTimeValue+"']").parent(); 3393 var is_custom_time = $(this).parent().find("#is_custom_time").val(); 3394 if (is_custom_time == 1) 3395 { 3396 active_li = $(this).parent().find("span[seletor_tag='99']").parent(); 3397 } 3398 active_li.find(".n_checkActive").show(); 3399 active_li.siblings().find(".n_checkActive").hide(); 3400 }); 3401 $(".TimeScopeS").click(function(){ 3402 $(this).find(":input").click(function(event) { 3403 event.stopPropagation(); 3404 }); 3405 $(this).find(".standardDilogBox li").click(function(event) { 3406 event.stopPropagation(); 3407 }); 3408 var is_custom_time = $(this).find("#is_custom_time").val(); 3409 if (is_custom_time == 1) 3410 { 3411 $(this).find(".time_custom").find(".chooseTime").show(); 3412 } 3413 else 3414 { 3415 $(this).find(".time_custom").find(".chooseTime").hide(); 3416 } 3417 $(this).find(".standardDilogBox").show(function(){ 3418 $(document.body).append("<div class='ui-widget-overlay frame-daterange-overlay'></div>"); 3419 $(".frame-daterange-overlay").css("opacity", 0); 3420 $(".frame-daterange-overlay").click(function() { 3421 $(this).remove(); 3422 $(".standardDilogBox").hide('fast',function(){ 3423 if($(".n_checkActive:visible").parent().siblings().html() == "Custom") 3424 { 3425 $(".time_custom").find(".chooseTime").hide(); 3426 } 3427 }); 3428 }); 3429 }); 3430 }); 3431 $(".TimeScopeS .standardDilogBox li").click(function(){ 3432 $(this).find(".standardButton").click(function(event) { 3433 event.stopPropagation(); 3434 }); 3435 $(this).find(".standardBut_GrayLow").click(function(event) { 3436 event.stopPropagation(); 3437 }); 3438 if(!$(this).find(".n_checkActive").is(':visible') && $(this).attr("class") != "time_custom") 3439 { 3440 $(this).find(".n_checkActive").toggle(); 3441 $(this).siblings().find(".n_checkActive").hide(); 3442 } 3443 if($(this).attr("class") != "time_custom") 3444 { 3445 var innerhtml = $(this).closest(".TimeScopeS").find(".n_checkActive:visible").parent().siblings().html(); 3446 var seletor = $(this).closest(".TimeScopeS").find(".n_checkActive:visible").parent().siblings().attr("seletor_tag"); 3447 if(innerhtml == undefined) 3448 { 3449 innerhtml = ''; 3450 } 3451 $(this).parent().parent().parent().find(".TimeScopeC").html(innerhtml); 3452 $(this).parent().parent().parent().find("#time_display").val(innerhtml); 3453 $(this).parent().parent().parent().find("#searchTimeValue").val(seletor); 3454 $(this).parent().parent().parent().find("#is_custom_time").val(0); 3455 $(".standardDilogBox").hide('fast',function(){ 3456 $(".frame-daterange-overlay").remove(); 3457 }); 3458 } 3459 else 3460 { 3461 $(this).parent().parent().parent().find("#is_custom_time").val(1); 3462 } 3463 }); 3464 $(".time_custom").click(function(){ 3465 $(this).find(".chooseTime").show(); 3466 }); 3467 $(".TimeScopeS .standardButtonCustom").click(function(){ 3468 $(this).parent().parent().find(".n_checkActive").show(); 3469 $(this).parent().parent().siblings().find(".n_checkActive").hide(); 3470 var hour_value = $(this).parent().find("#time_hour_value").val(); 3471 var minute_value = $(this).parent().find("#time_min_value").val(); 3472 if (minute_value == '00' && hour_value == '00') 3473 { 3474 alert("Please select a valid departure time!"); 3475 return false;
3476 } 3477 var time_value = hour_value+":"+minute_value; 3478 var time_display = to_us_time(time_value); 3479 $(this).closest(".TimeScopeS").find(".TimeScopeC").html(time_display); 3480 $(this).closest(".TimeScopeS").find("#time_display").val(time_display); 3481 $(this).closest(".TimeScopeS").find("#searchTimeValue").val(time_value); 3482 $(".standardDilogBox").hide('fast',function(){ 3483 $(".frame-daterange-overlay").remove(); 3484 if($(this).closest(".TimeScopeS").find("#is_custom_time").val() != 1) 3485 { 3486 $(this).closest(".time_custom").find(".chooseTime").hide(); 3487 } 3488 }); 3489 }); 3490} 3491 3492function to_us_time(t) 3493{ 3494 var us_time = ''; 3495 if (t.match(/\:/)) 3496 { 3497 ts = t.split(':'); 3498 var hour = parseInt(ts[0]); 3499 var minute = ts[1]; 3500 var ampm = "am"; 3501 if (hour > 11) 3502 { 3503 ampm = "pm"; 3504 } 3505 if (hour == 12 || hour == 0) 3506 { 3507 us_time = "12:" + minute + ampm; 3508 } 3509 else 3510 { 3511 if (hour > 12) 3512 { 3513 hour = hour - 12; 3514 } 3515 us_time = hour + ":" + minute + ampm; 3516 } 3517 } 3518 return us_time; 3519} 3520 3521function common_attachment_delete(fieldId,obj) 3522{ 3523 var element_id=$(obj).parent().find("input[name='element_id']").val(); 3524 $("#removing_" + element_id).show(); 3525 $.get("/cgi-bin/ajax.fcgi", {type:'common_attachment_delete',field_id:fieldId,ts:new Date().toString()}, function(data){ 3526 if(data && data.indexOf("upload_error") != -1) 3527 { 3528 alert("Error: Please check your file name!"); 3529 }else { 3530 var oDatatables = $('#' + element_id).DataTable(); 3531 oDatatables 3532 .row($(obj).parents('tr')) 3533 .remove() 3534 .draw(); 3535 $("#removing_" + element_id).hide(); 3536 } 3537 }); 3538 return false; 3539} 3540function common_upload_attachment(obj) 3541{ 3542 var document_type = $(obj).attr("document_type"); 3543 var object_type = $(obj).attr("object_type"); 3544 var object_id = $(obj).attr("object_id"); 3545 var with_action=$(obj).attr("with_action"); 3546 var file_id = document_type + object_type + object_id; 3547 if($(obj).val() == "") 3548 { 3549 alert("Error: Please check your file!"); 3550 return false; 3551 } 3552 if(!validate_file_extension($(obj).val())) 3553 { 3554 alert("Error: Please check your file extension!"); 3555 return false; 3556 } 3557 $("#uploading_" + file_id).show(); 3558 var up_id = "file_upload_" + file_id; 3559 $.ajaxFileUpload 3560 ( 3561 { 3562 url: "/cgi-bin/ajax.fcgi", 3563 secureuri: false, 3564 fileElementId: up_id, 3565 dataType: 'text', 3566 data: {type:'upload_attachment', document_type:document_type, object_id: object_id,object_type:object_type}, 3567 success: function(r_data) 3568 { 3569 if(r_data && r_data.indexOf("upload_error") != -1) 3570 { 3571 alert("Error: Please check your file name!"); 3572 } 3573 else 3574 { 3575 r_data = r_data.replace(/"\\'/g, "'"); 3576 r_data = r_data.replace(/\\'"/g, "'"); 3577 var json_data = eval("("+r_data+")"); 3578 var table = $('#' + file_id).DataTable(); 3579 if(with_action) 3580 { 3581 table.row.add( [ 3582 json_data.download_link, 3583 json_data.uploader, 3584 json_data.datetime, 3585 json_data.remove_link 3586 ] ).draw(); 3587 } 3588 else 3589 { 3590 table.row.add( [ 3591 json_data.download_link, 3592 json_data.uploader, 3593 json_data.datetime 3594 ] ).draw(); 3595 } 3596 $("#uploading_" + file_id).hide(); 3597 } 3598 }, 3599 error: function() 3600 { 3601 alert("Error: Please check your file name!"); 3602 } 3603 } 3604 ) 3605 return false; 3606} 3607 3608function string_length(str) 3609{ 3610 var len = 0; 3611 for (var i=0; i<str.length; i++) { 3612 if (str.charCodeAt(i)>127 || str.charCodeAt(i)==94) 3613 { 3614 len += 2; 3615 } 3616 else 3617 { 3618 len ++; 3619 } 3620 } 3621 return len; 3622} 3623 3624$(function(){ 3625 $("#date_range_search_menu").click(function(event){ 3626 event.cancelBubble=true; 3627 event.stopPropagation(); 3628 }); 3629 $("#date_range_search_box").click(function(event){ 3630 event.cancelBubble=true; 3631 event.stopPropagation(); 3632 if(document.getElementById("date_range_search_menu").style.display=="none") 3633 { 3634 $("#date_range_search_menu").show(); 3635 } 3636 else 3637 { 3638 $("#date_range_search_menu").hide(); 3639 } 3640 }); 3641 $(document).click(function(event){ 3642 if(event.which == 1) 3643 { 3644 $("#date_range_search_menu").hide(); 3645 } 3646 }); 3647 $("#site-nav").find('a.dropdown-toggle').on("touchstart", function (e) { 3648 "use strict"; 3649 var link = $(this); 3650 if (link.hasClass('hover')) { 3651 return true; 3652 } else { 3653 link.addClass("hover"); 3654 $("#site-nav").find('a.dropdown-toggle').not(this).removeClass("hover"); 3655 e.preventDefault(); 3656 return false; 3657 } 3658 }); 3659}); 3660 3661function cancel_date_range_search_menu() 3662{ 3663 $("#date_range_search_menu").hide(); 3664} 3665 3666function show_station_map(bss_id, is_arrival, eid) 3667{ 3668 if (bridgeHasNativeMethod("mapViewShowAnnotations")) { 3669 var station_annotations = parse_station_map(bss_id); 3670 var is_main = station_annotations[0].is_main == 1; 3671 var native_annotations = $.map(is_main ? station_annotations.slice(1) : [station_annotations[0]], function(n, i) { 3672 var selected; 3673 var value; 3674 if (is_main) { 3675 if (eid) { 3676 if (is_arrival) { 3677 selected = n.value == $("#e" + eid + "drop_off_location").val() 3678 } else { 3679 selected = n.value == $("#e" + eid + "pickup_location").val(); 3680 } 3681 } 3682 value = n.value; 3683 } else { 3684 selected = true; 3685 } 3686 return {'title':n.fullText,'latitude':n.latitude,'longitude':n.longitude,selected,value}; 3687 }); 3688 bridgeCallNativeMethodWithJsHandler("mapViewShowAnnotations",native_annotations,is_main?"selectBusStopBySubStation":"",{is_arrival,eid}); 3689 return; 3690 } 3691 if ($("#mapImg").length > 0) { 3692 show_station_map_web(bss_id); 3693 return; 3694 } 3695 show_address_map(bss_id, "station-map", "location-map"); 3696} 3697function parse_station_map(bss_id) 3698{ 3699 var station_annotations = []; 3700 var obj = $("#" + bss_id); 3701 var latitude = $(obj).attr("latitude"); 3702 var longitude = $(obj).attr("longitude"); 3703 var fullText = $(obj).attr("full_text"); 3704 var is_main = $(obj).attr("is_main"); 3705 station_annotations.push({fullText,latitude,longitude,is_main,value:$(obj).val()}); 3706 var s_name = bss_id.replace('bss','sub_station'); 3707 $("." + s_name).each(function() { 3708 var s_latitude = $(this).attr("latitude"); 3709 var s_longitude = $(this).attr("longitude"); 3710 var s_full_text = $(this).attr("full_text"); 3711 station_annotations.push({'fullText':s_full_text,'latitude':s_latitude,'longitude':s_longitude,value:$(this).val()}); 3712 }); 3713 return station_annotations; 3714} 3715var smap; 3716function init_station_popu_map(bss_id,container_id) 3717{ 3718 var station_annotations = parse_station_map(bss_id); 3719 var obj = $("#" + bss_id); 3720 var latitude = station_annotations[0].latitude; 3721 var longitude = station_annotations[0].longitude; 3722 var fullText = station_annotations[0].fullText; 3723 var is_main = station_annotations[0].is_main; 3724 var myLatLng = latitude && longitude ? new google.maps.LatLng(latitude, longitude) : undefined; 3725 var mapCanvas = $("#" + (container_id ? container_id : "station-map")).get(0); 3726 var mapOptions = { 3727 zoom: 15, 3728 mapTypeId: google.maps.MapTypeId.ROADMAP 3729 }; 3730 if(myLatLng) 3731 { 3732 mapOptions.center = myLatLng; 3733 } 3734 smap = new google.maps.Map(mapCanvas, mapOptions); 3735 if(myLatLng && (!is_main || is_main == 0)) 3736 { 3737 var marker = showMarker(smap, myLatLng); 3738 var infowindow = showStationInfoMessage(fullText,smap,marker); 3739 infowindow.open(smap, marker); 3740 } 3741 //changeStationPan(latitude, longitude, smap); 3742 var latlngbounds = new google.maps.LatLngBounds(); 3743 $.each(station_annotations.slice(1), function(i, n) { 3744 var s_latitude = n.latitude; 3745 var s_longitude = n.longitude; 3746 var s_full_text = n.fullText; 3747 if(s_latitude && s_longitude) 3748 { 3749 var s_latlng = new google.maps.LatLng(s_latitude, s_longitude); 3750 latlngbounds.extend(s_latlng); 3751 var s_marker = showMarker(smap, s_latlng); 3752 showStationInfoMessage(s_full_text, smap, s_marker); 3753 } 3754 }); 3755 if(!latlngbounds.isEmpty()) 3756 { 3757 smap.fitBounds(latlngbounds, 30); 3758 google.maps.event.addListenerOnce(smap, "idle", function() { 3759 if(smap.getZoom() > 15) 3760 { 3761 smap.setZoom(15); 3762 } 3763 }); 3764 } 3765} 3766function showMarker(map, myLatLng) 3767{ 3768 var markerImage = "/images/system/pin-gtb.png"; 3769 var marker = new google.maps.Marker({ 3770 position: myLatLng, 3771 map: map, 3772 icon: markerImage 3773 }); 3774 return marker; 3775} 3776function changeStationPan(latitude, longitude, map) { 3777 var latlngbounds = new google.maps.LatLngBounds(); 3778 var point = new google.maps.LatLng(latitude, longitude); 3779 latlngbounds.extend(point); 3780 map.fitBounds(latlngbounds); 3781} 3782function showStationInfoMessage(fullText,map,marker,rawContent) { 3783 var contentString = rawContent ? fullText : '<div class="info-window">' + 3784 '<div class="info-content">' + 3785 '<p>' + 3786 fullText + 3787 '</p>' + 3788 '</div>' + 3789 '</div>'; 3790 var infowindow = new google.maps.InfoWindow({ 3791 content: contentString, 3792 maxWidth: 320 3793 }); 3794 marker.addListener('click', function () { 3795 infowindow.open(map, this); 3796 }); 3797 return infowindow; 3798} 3799 3800function load_google_map_js(need_places, methods, full_name) 3801{ 3802 var google_map_url = google_map_api_url; 3803 if(need_places) 3804 { 3805 google_map_url += "&libraries=places"; 3806 } 3807 if(typeof(google) == "undefined") 3808 { 3809 $.getScript(google_map_url, function() { 3810 if(full_name == 'initialize_google_marker_label' && typeof(MarkerWithLabel) == "undefined") 3811 { 3812 $.getScript(google_map_jquery_url,function() { 3813 $.getScript(google_map_market_label_url, function() { 3814 eval(methods); 3815 }); 3816 }); 3817 } 3818 else 3819 {
3820 eval(methods); 3821 } 3822 }); 3823 } 3824 else 3825 { 3826 if(full_name == 'initialize_google_marker_label' && typeof(MarkerWithLabel) == "undefined") 3827 { 3828 $.getScript(google_map_jquery_url,function() { 3829 $.getScript(google_map_market_label_url, function() { 3830 eval(methods); 3831 }); 3832 }); 3833 } 3834 else 3835 { 3836 eval(methods); 3837 } 3838 } 3839} 3840 3841function show_map_modal(map_id, modal_id, init_callback, show_callback) 3842{ 3843 if($("#" + modal_id).find(".modal-title").text() == "") 3844 { 3845 $("#" + modal_id).find(".modal-title").text("Map"); 3846 } 3847 show_callback = show_callback ? show_callback : "$('#" + modal_id + "').modal('show');"; 3848 if (typeof(google) == 'undefined' || typeof(google.maps) == 'undefined') 3849 { 3850 load_google_map_js("", init_callback + show_callback); 3851 } 3852 else 3853 { 3854 eval(show_callback); 3855 } 3856} 3857 3858function show_address_map(address_id, map_id, modal_id) 3859{ 3860 if($.trim($("#" + address_id).attr("alt")) != "") 3861 { 3862 $("#" + modal_id).find(".modal-title").text($("#" + address_id).attr("alt")); 3863 } 3864 else if($.trim($("#" + address_id).attr("title")) != "") 3865 { 3866 $("#" + modal_id).find(".modal-title").text($("#" + address_id).attr("title")); 3867 } 3868 var init_callback = "init_station_popu_map('" + address_id + "','" + map_id + "');"; 3869 show_map_modal(map_id, modal_id, init_callback); 3870} 3871 3872function show_station_map_web(bss_id) 3873{ 3874 init_station_image(bss_id); 3875 show_station_image(); 3876 $("#location-map").modal("show"); 3877} 3878 3879function init_station_image(bss_id) { 3880 $("#mapImg .map_img").attr("src", "https://res.gotobus.com/images/busstation/fluid/" + $("#" + bss_id).attr("aid") + ".png"); 3881 $("#infoWindow .info_label").text($("#" + bss_id).attr("full_text")); 3882 $("#mapImg").off("click"); 3883 $("#mapImg").click(function() { 3884 click_station_map(bss_id); 3885 }); 3886} 3887 3888function show_station_image() { 3889 $("#station-map").hide(); 3890 $("#mapImg").show(); 3891} 3892 3893function hide_station_image() { 3894 $("#station-map").show(); 3895 $("#mapImg").hide(); 3896} 3897 3898function click_station_map(bss_id) 3899{ 3900 var init_callback = "init_station_popu_map('" + bss_id + "','station-map');"; 3901 var show_callback = "hide_station_image();"; 3902 if (typeof(google) == 'undefined' || typeof(google.maps) == 'undefined') 3903 { 3904 load_google_map_js("", init_callback + show_callback); 3905 } 3906 else 3907 { 3908 eval(show_callback); 3909 } 3910} 3911 3912var add_time = 0; 3913var intervalobj = null; 3914function showRemainTime() 3915{ 3916 if($(".remain-time").length > 0) { 3917 $(".remain-time").hide(); 3918 $.ajax({ 3919 type: "GET", 3920 url: "/api/common/get-server-time", 3921 dataType: "json", 3922 success: function (data) { 3923 data = data.data; 3924 var dateTimeArr = data.split(' '); 3925 var dateArr = dateTimeArr[0].split('-'); 3926 var tmieArr = dateTimeArr[1].split(':'); 3927 var server_time = new Date(parseInt(dateArr[0],10),parseInt(dateArr[1],10)-1,parseInt(dateArr[2],10),parseInt(tmieArr[0],10),parseInt(tmieArr[1],10),parseInt(tmieArr[2],10)); 3928 $(".remain-time").each(function() { 3929 var pid = $(this).attr("pid"); 3930 var endDateStr = $("#end_date" + pid).val(); 3931 var endBeforeDateStr = $("#end_before_date" + pid).val(); 3932 var endDateArr = endDateStr.split('-'); 3933 var endBeforeDateArr = endBeforeDateStr.split('-'); 3934 var end_time = new Date(parseInt(endDateArr[0],10),parseInt(endDateArr[1],10)-1,parseInt(endDateArr[2],10)); 3935 intervalobj = window.setInterval(function(){ setremaintime(pid, end_time, server_time, endBeforeDateArr);}, 1000); 3936 $(this).show(); 3937 }); 3938 }, 3939 error: function () { 3940 alert("system error."); 3941 } 3942 }); 3943 } 3944} 3945 3946function setremaintime(pid, end_time, server_time, endBeforeDateArr){ 3947 add_time++; 3948 var rmms = end_time.getTime() - server_time.getTime() - 1000 * add_time; 3949 var rmdd = Math.floor(rmms/(1000 * 60 * 60 * 24)); 3950 var rmhh = Math.floor(rmms/(1000*60*60)) % 24; 3951 var rmmm = Math.floor(rmms/(1000*60)) % 60; 3952 var rmss = Math.floor(rmms/1000) % 60; 3953 if(rmdd >= 0) 3954 { 3955 if(rmdd != 0) 3956 { 3957 $("#remaintime" + pid).find(".remaind").html(endBeforeDateArr[1]+"/"+endBeforeDateArr[2]+"/"+endBeforeDateArr[0]); 3958 $("#remaintime" + pid).find(".clock_dms").html(""); 3959 } 3960 if(rmhh>=10) 3961 { 3962 $("#remaintime" + pid).find(".remainh").html(rmhh); 3963 } 3964 else 3965 { 3966 $("#remaintime" + pid).find(".remainh").html('0' + rmhh); 3967 } 3968 if(rmmm>=10) 3969 { 3970 $("#remaintime" + pid).find(".remainm").html(rmmm); 3971 } 3972 else 3973 { 3974 $("#remaintime" + pid).find(".remainm").html('0' + rmmm); 3975 } 3976 if(rmss>=10) 3977 { 3978 $("#remaintime" + pid).find(".remains").html(rmss); 3979 } 3980 else 3981 { 3982 $("#remaintime" + pid).find(".remains").html('0' + rmss); 3983 } 3984 } 3985 else 3986 { 3987 $("#remaintime" + pid).html("The deal is over!"); 3988 if(intervalobj != null) 3989 { 3990 window.clearInterval(intervalobj); 3991 } 3992 } 3993} 3994 3995function togglePrivateItineraryAttractions(obj) { 3996 var div = $(obj).closest(".privateItinerary").find(".itineraryAttractions"); 3997 if (div.is(":hidden")) { 3998 div.show(); 3999 $(obj).removeClass("icon-angle-down").addClass("icon-angle-up"); 4000 } else { 4001 div.hide(); 4002 $(obj).removeClass("icon-angle-up").addClass("icon-angle-down"); 4003 } 4004} 4005function togglePrivateTripMoreOrLess(obj) { 4006 if ($(obj).html().indexOf("Less") >= 0) { 4007 $(obj).html("More >>"); 4008 $(obj).closest(".privateTrip").find(".privateItinerary:gt(2)").hide(); 4009 } else { 4010 $(obj).html("<< Less"); 4011 $(obj).closest(".privateTrip").find(".privateItinerary:gt(2)").show(); 4012 } 4013} 4014 4015function update_wishlist_head() 4016{ 4017 var wishlist_pids = get_local_storage("MyProductWishlist"); 4018 $("#wishlist_head").find(".num").remove(); 4019 $("#wishlist_head_nav").find(".num").remove(); 4020 if(wishlist_pids != null && wishlist_pids.length > 0) 4021 { 4022 var num = wishlist_pids.length; 4023 $("#wishlist_head").append("<em class='num'>"+num+"</em>"); 4024 $("#wishlist_head_nav").append("<em class='num'>"+num+"</em>"); 4025 } 4026} 4027 4028function save_to_wishlist(pid) 4029{ 4030 var wishlist_pids = get_local_storage("MyProductWishlist"); 4031 if(wishlist_pids != null && wishlist_pids.length > 0 && weak_in_array(pid, wishlist_pids) >= 0) 4032 { 4033 update_top_seller_wishlist_button(pid, true); 4034 update_d_img_tours_wishlist_button(pid, true); 4035 return; 4036 } 4037 if(wishlist_pids == null) 4038 { 4039 wishlist_pids = []; 4040 } 4041 wishlist_pids.push(pid); 4042 if(wishlist_pids.length > 100) 4043 { 4044 wishlist_pids.shift(); 4045 } 4046 set_local_storage("MyProductWishlist", wishlist_pids); 4047 $.ajax({ 4048 url: "/cgi-bin/ajax.fcgi", 4049 data: { 4050 type: "save_to_wishlist", 4051 product_id: pid, 4052 }, 4053 beforeSend: function() { 4054 }, 4055 success: function(data) { 4056 if($(".wishlist-btn").length > 0) 4057 { 4058 update_top_seller_wishlist_button(pid, true); 4059 update_d_img_tours_wishlist_button(pid, true); 4060 } 4061 if($(".wishlist-div").length > 0) 4062 { 4063 var html = '<a title="Cancel Saving to Wishlist" href="javascript:void(0);" onclick="remove_from_wishlist(' + pid + ');"><i class="fa fa-lg icon-heart"></i></a>'; 4064 $(".wishlist-div").html(html); 4065 } 4066 else if($(".wishlist-btn").length == 0) 4067 { 4068 var html = '<a title="Cancel Saving to Wishlist" href="javascript:void(0);" onclick="remove_from_wishlist(' + pid + ');"><i class="fa fa-lg icon-heart cf60"></i></a>'; 4069 $("#wishlist_item" + pid).html(html); 4070 } 4071 update_wishlist_head(); 4072 }, 4073 }); 4074} 4075 4076function remove_from_wishlist(pid) 4077{ 4078 var wishlist_pids = get_local_storage("MyProductWishlist"); 4079 if(wishlist_pids != null && wishlist_pids.length > 0) 4080 { 4081 var index = weak_in_array(pid, wishlist_pids); 4082 if(index >= 0) 4083 { 4084 wishlist_pids.splice(index, 1); 4085 set_local_storage("MyProductWishlist", wishlist_pids); 4086 $.ajax({ 4087 url: "/cgi-bin/ajax.fcgi", 4088 data: { 4089 type: "remove_from_wishlist", 4090 product_id: pid, 4091 }, 4092 beforeSend: function() { 4093 }, 4094 success: function(data) { 4095 if($(".wishlist-btn").length > 0) 4096 { 4097 update_top_seller_wishlist_button(pid, false); 4098 update_d_img_tours_wishlist_button(pid, false); 4099 } 4100 if($(".wishlist-div").length > 0) 4101 { 4102 var html = '<a title="Save to Wishlist" href="javascript:void(0);" onclick="save_to_wishlist(' + pid + ');"><i class="fa fa-lg icon-heart-empty"></i></a>'; 4103 $(".wishlist-div").html(html); 4104 } 4105 else if($(".wishlist-btn").length == 0) 4106 { 4107 var html = '<a title="Save to Wishlist" href="javascript:void(0);" onclick="save_to_wishlist(' + pid + ');"><i class="fa fa-lg icon-heart-empty cf60"></i></a>'; 4108 $("#wishlist_item" + pid).html(html); 4109 } 4110 update_wishlist_head(); 4111 }, 4112 }); 4113 } 4114 } 4115} 4116 4117function show_deals() 4118{ 4119 $("#my_deals_banner").remove(); 4120 var role = get_cookie('IvyCustomer_role'); 4121 if(!role) 4122 { 4123 role="0"; 4124 } 4125 role = parseInt(role); 4126 //role < 3 4127 if(role < 3 && ($(".p-title-name").length > 0 || $(".tp-booking-price-line").length > 0)) 4128 {
4129 show_product_track_deals(); 4130 } 4131 var acknowledged = get_local_storage_ttl("acknowledged"); 4132 if(isUserLoggedIn()) 4133 { 4134 $(".guest-deals-banner").remove(); 4135 var datas = get_local_storage("MyDeals"); 4136 if(datas != null && datas != undefined && datas != "") 4137 { 4138 datas = eval("("+datas+")"); 4139 var html = ""; 4140 var num = 0; 4141 var will_expire_num = 0; 4142 var total_promotion_value = 0; 4143 var promotion_value_num = 0; 4144 for (let data of datas) 4145 { 4146 if(data.endDate != null && data.endDate != undefined && data.endDate != "") 4147 { 4148 var datearr = data.endDate.split("-"); 4149 var endDate = new Date(datearr[0], datearr[1] - 1, datearr[2], 23, 59, 59); 4150 var time_diff = endDate.getTime() - new Date().getTime(); 4151 if(time_diff < 0) 4152 { 4153 } 4154 else 4155 { 4156 if(parseInt(data.promotionValue) >= 1) 4157 { 4158 total_promotion_value += parseInt(data.promotionValue); 4159 promotion_value_num ++; 4160 } 4161 var days = Math.floor(time_diff / (1000 * 60 * 60 * 24)); 4162 num++; 4163 if(days < 4) 4164 { 4165 will_expire_num++; 4166 } 4167 } 4168 } 4169 else 4170 { 4171 num++; 4172 } 4173 } 4174 if(num > 0) 4175 { 4176 if($("#tt_responsive_head_login").closest(".new-header").length > 0) 4177 { 4178 $(".top-deals").html("<i class='fa fa-lg icon-gift'></i> My Deals<em class='num'>" + num + "</em>"); 4179 } 4180 else 4181 { 4182 $(".top-deals").html("My Deals<em>" + num + "</em>"); 4183 } 4184 } 4185 $("#dash_deals_avai_num").html(num); 4186 if((acknowledged != null && acknowledged != '' && acknowledged == 2) || $(".no_deals_banner").length > 0 || $(".couponDiv").length > 0 || $(".cart-wrapper").length > 0 || $(".product-track-deals-banner").length > 0 || $(".tp-title-line").length > 0) 4187 { 4188 } 4189 else 4190 { 4191 if(num > 0) 4192 { 4193 if($("#my_deals_banner").length == 0) 4194 { 4195 $("<div id='my_deals_banner' class='logged-deals-banner'></div>").appendTo(document.body); 4196 } 4197 var couponText = num > 1 ? `You have ${num} coupons` : `You have ${num} coupon`; 4198 html = `<div class="deals-content"><i class="fa fa-lg icon-cancel" onclick="close_deals(event, 2);"></i><div class="deals-main"><img src="/images/deals-gift-icon.png?t=20260924" class="deals-gift" alt="Coupon"/><div class="deals-copy"><div class="deals-title">${couponText}</div><div class="deals-subtitle">Ready to use on eligible tours</div></div></div><button type="button" class="deals-coupon-btn" onclick="go_my_deals(2);">View coupons <i class="fa icon-angle-right"></i></button></div>`; 4199 $("#my_deals_banner").empty().append(html); 4200 if(($("#app-banner").length > 0 && $("#app-banner").is(":visible")) || ($("#mobile-fixed-footer").length > 0 && $("#mobile-fixed-footer").is(":visible"))) { 4201 $("#my_deals_banner").addClass("deals-banner"); 4202 } 4203 $("#my_deals_banner").show(); 4204 if($("#compare_tours_banner").length > 0) 4205 { 4206 var bottom = 10 + parseInt($("#my_deals_banner").css("bottom")) + parseInt($('#my_deals_banner').outerHeight(true)); 4207 $("#compare_tours_banner").css("bottom", bottom + "px"); 4208 } 4209 } 4210 } 4211 if($(".deals_dt").length > 0) 4212 { 4213 $(".deals_dt").find(".a-deals-num").remove(); 4214 $(".deals_dt").find(".exp-deals-num").remove(); 4215 if(num > 0) 4216 { 4217 if($(".deals_dt").find(".a-deals-num").length == 0) 4218 { 4219 $(".deals_dt").append('<a href="/app/member/coupon" class="a-deals-num"></a>'); 4220 } 4221 if(num > 1) 4222 { 4223 $(".deals_dt").find(".a-deals-num").html('<span><em>' + num + '</em>' + ' promos available</span>'); 4224 } 4225 else 4226 { 4227 $(".deals_dt").find(".a-deals-num").html('<span><em>' + num + '</em>' + ' promo available</span>'); 4228 } 4229 } 4230 if(will_expire_num > 0) 4231 { 4232 if($(".deals_dt").find(".exp-deals-num").length == 0) 4233 { 4234 $(".deals_dt").append('<a href="/app/member/coupon" class="exp-deals-num"></a>'); 4235 } 4236 if(will_expire_num > 1) 4237 { 4238 $(".deals_dt").find(".exp-deals-num").html('<span>' + will_expire_num + ' promos are expiring</span>'); 4239 } 4240 else 4241 { 4242 $(".deals_dt").find(".exp-deals-num").html('<span>' + will_expire_num + ' promo is expiring</span>'); 4243 } 4244 } 4245 } 4246 } 4247 } 4248 else 4249 { 4250 $(".logged-deals-banner").remove(); 4251 if((acknowledged != null && acknowledged != '') || $(".no_deals_banner").length > 0 || $(".couponDiv").length > 0 || $(".cart-wrapper").length > 0 || $(".product-track-deals-banner").length > 0 || $(".tp-title-line").length > 0) 4252 { 4253 } 4254 else 4255 { 4256 if($("#my_deals_banner").length == 0) 4257 { 4258 $("<div id='my_deals_banner' class='guest-deals-banner'></div>").appendTo(document.body); 4259 } 4260 html = `<div class="deals-content"><i class="fa fa-lg icon-cancel" onclick="close_deals(event, 1);"></i><div class="deals-main"><img src="/images/deals-gift-icon.png?t=20260924" class="deals-gift" alt="Coupon"/><div class="deals-copy"><div class="deals-title">Save up to $100</div><div class="deals-subtitle">Create a free TakeTours account and unlock your offer.</div></div></div><button type="button" class="deals-coupon-btn" onclick="go_sign_in(1);">Unlock My Offer <i class="fa icon-angle-right"></i></button><div class="deals-note">Quick. Free. More travel for less.</div></div>`; 4261 $("#my_deals_banner").empty().append(html); 4262 if(($("#app-banner").length > 0 && $("#app-banner").is(":visible")) || ($("#mobile-fixed-footer").length > 0 && $("#mobile-fixed-footer").is(":visible")) || ($(".tp-mobile-booking-bar").length > 0 && $(".tp-mobile-booking-bar").is(":visible"))) { 4263 $("#my_deals_banner").addClass("deals-banner"); 4264 } 4265 $("#my_deals_banner").show(); 4266 if($("#compare_tours_banner").length > 0) 4267 { 4268 var bottom = 10 + parseInt($("#my_deals_banner").css("bottom")) + parseInt($('#my_deals_banner').outerHeight(true)); 4269 $("#compare_tours_banner").css("bottom", bottom + "px"); 4270 } 4271 } 4272 } 4273} 4274 4275function close_deals(event, acknowledged) 4276{ 4277 event.cancelBubble=true; 4278 event.stopPropagation(); 4279 if(acknowledged > 0) 4280 {
4281 set_local_storage_ttl("acknowledged", acknowledged, 86400); 4282 } 4283 $("#my_deals_banner").remove(); 4284} 4285 4286function go_sign_in(acknowledged) 4287{ 4288 if(acknowledged) 4289{ 4290 set_local_storage_ttl("acknowledged", acknowledged, 86400); 4291 $("#my_deals_banner").remove(); 4292 } 4293 window.location.href = "/app/user-register.htm"; 4294} 4295 4296function go_my_deals(acknowledged) 4297{ 4298 if(acknowledged) 4299{ 4300 set_local_storage_ttl("acknowledged", acknowledged, 86400); 4301 $("#my_deals_banner").remove(); 4302 } 4303 window.location.href = "/app/member/coupon"; 4304} 4305 4306function show_product_track_deals() 4307{ 4308 var live_test = 0; 4309 var pid = $(".product_options").find("input[name='pid']").val(); 4310 pid = pid ? pid : $("#tp-booking-form").find("input[name='pid']").val(); 4311 var url = window.location.href; 4312 var showPrice = $(".mb-3").find(".font30").find(".default_currency").length > 0 ? $(".mb-3").find(".font30").find(".default_currency").html() : $(".mb-3").find(".font30").html(); 4313 showPrice = $(".tp-booking-price-line").find("strong").find(".default_currency").length > 0 ? $(".tp-booking-price-line").find("strong").find(".default_currency").html() : showPrice; 4314 var price = showPrice.replace("US$", ""); 4315 price = price.replace("$", ""); 4316 var only_track = $(".add_to_cart:disabled").length > 0 || $('button.tp-btn.tp-btn-primary[data-action="notify-me"]').length > 0 ? 1 : 0; 4317 if(pid != null && pid != undefined && pid != "") 4318 { 4319 getApiPromise("POST", "/api/promotions/check-apply-track-promotions", {pid: pid, url: url, price: price, onlyTrack: only_track, liveTest: live_test}, 0, 1).done(function(data) { 4320 if(data.enableCreatePromotion == 1) { 4321 $("#my_deals_banner").remove(); 4322 if($("#my_deals_banner").length == 0) 4323 { 4324 $("<div id='my_deals_banner' class='product-track-deals-banner'></div>").appendTo(document.body); 4325 } 4326 var html = `<div class="deals-title">Still looking?</div><div>Get a mystery promo code to enjoy an extra discount.</div>`; 4327 html += `<div><input type="text" class="form-control" name="product_track_email" value="" placeholder="Enter your email"/></div>`; 4328 html += `<div><input type="button" value="Receive Code" onclick="apply_product_track_promotion();"/></div>`; 4329 html = `<div class="deals-content"><i class="fa fa-lg icon-cancel" onclick="close_deals(event, 0);"></i>` + html + `</div>`; 4330 $("#my_deals_banner").empty().append(html); 4331 if($("#compare_tours_banner").length > 0) 4332 { 4333 var bottom = 10 + parseInt($("#my_deals_banner").css("bottom")) + parseInt($('#my_deals_banner').outerHeight(true)); 4334 $("#compare_tours_banner").css("bottom", bottom + "px"); 4335 } 4336 } 4337 else if(data.enableCreatePromotion == 2) { 4338 $("#my_deals_banner").remove(); 4339 if($("#my_deals_banner").length == 0) 4340 { 4341 $("<div id='my_deals_banner' class='product-track-deals-banner'></div>").appendTo(document.body); 4342 } 4343 html = `<div class="deals-title">Congratulations!</div><div>You just got a mystery discount!</div><div>Check "My Deals" to see details.</div>`; 4344 html += `<div><input type="button" value="My Deals" onclick="go_my_deals();"/></div>`; 4345 html = `<div class="deals-content"><i class="fa fa-lg icon-cancel" onclick="close_deals(event, 0);"></i>` + html + `</div>`; 4346 $("#my_deals_banner").empty().append(html); 4347 if($("#compare_tours_banner").length > 0) 4348 { 4349 var bottom = 10 + parseInt($("#my_deals_banner").css("bottom")) + parseInt($('#my_deals_banner').outerHeight(true)); 4350 $("#compare_tours_banner").css("bottom", bottom + "px"); 4351 } 4352 } 4353 }); 4354} 4355} 4356 4357function apply_product_track_promotion() 4358{ 4359 var pid = $(".product_options").find("input[name='pid']").val(); 4360 pid = pid ? pid : $("#tp-booking-form").find("input[name='pid']").val(); 4361 var url = window.location.href; 4362 var showPrice = $(".mb-3").find(".font30").find(".default_currency").length > 0 ? $(".mb-3").find(".font30").find(".default_currency").html() : $(".mb-3").find(".font30").html(); 4363 showPrice = $(".tp-booking-price-line").find("strong").find(".default_currency").length > 0 ? $(".tp-booking-price-line").find("strong").find(".default_currency").html() : showPrice; 4364 var price = showPrice.replace("US$", ""); 4365 price = price.replace("$", ""); 4366 var email = $("input[name='product_track_email']").val(); 4367 if(pid != null && pid != undefined && pid != "") 4368 { 4369 if(email == "") 4370 { 4371 alert("Please enter your email address."); 4372 return false;
4373 } 4374 var validate_flag = validate_email_input(email); 4375 if(validate_flag != true) 4376 { 4377 alert("Please enter a valid email address."); 4378 return false; 4379 } 4380 var blocker = dispaly_sc_fade_block(); 4381 getApiPromise("POST", "/api/promotions/apply-track-promotions", {pid: pid, url: url, price: price, email: email}, 0, 1).done(function(data) { 4382 $(blocker).remove(); 4383 var html = ""; 4384 if(data.enableCreatePromotion == 1) 4385 { 4386 html = `<div class="deals-title">Congratulations!</div><div>You just got a mystery discount!</div><div>Check your email to see details.</div>`; 4387 } 4388 else if(data.enableCreatePromotion == 0) 4389 { 4390 html = `<div>You have already got a mystery discount!</div>`; 4391 } 4392 if(html != "") 4393 { 4394 html = `<div class="deals-content"><i class="fa fa-lg icon-cancel" onclick="close_deals(event, 0);"></i>` + html + `</div>`; 4395 $("#my_deals_banner").empty().append(html); 4396 if($("#compare_tours_banner").length > 0) 4397 { 4398 var bottom = 10 + parseInt($("#my_deals_banner").css("bottom")) + parseInt($('#my_deals_banner').outerHeight(true)); 4399 $("#compare_tours_banner").css("bottom", bottom + "px"); 4400 } 4401 } 4402 }); 4403} 4404} 4405 4406function show_link(pid) 4407{ 4408 var html = "<a href='javascript:changeChoose(" + pid + ")' pid='" + pid + "' class='compare-btn' id='select_compare_" + pid + "'><i class='icon-checkbox' id='compare_icon_" + pid + "'></i>Compare</a>"; 4409 $("#" + pid + "_a").html(html); 4410 var datas = get_local_storage_ttl("compareTours"); 4411 if(datas != null && datas != undefined && datas != "" && datas.length > 0) 4412 { 4413 for (let data of datas) 4414 { 4415 $("#compare_icon_"+ data.id).removeClass("icon-checkbox").addClass("icon-ok-squared"); 4416 } 4417 } 4418} 4419 4420function changeChoose(pid){ 4421 if($("#compare_icon_" + pid).hasClass("icon-ok-squared")) 4422 { 4423 remove_compare_product(pid); 4424 } 4425 else 4426 { 4427 add_compare_product(pid); 4428 } 4429} 4430 4431function add_compare_product(pid) 4432{ 4433 var datas = get_local_storage_ttl("compareTours"); 4434 var items_str = ""; 4435 var num = 0; 4436 if(datas != null && datas != undefined && datas != "" && datas.length > 0) 4437 { 4438 num = datas.length; 4439 if(num == 5) 4440 { 4441 return false; 4442 } 4443 for (let data of datas) 4444 { 4445 if(data.id != pid) 4446 { 4447 var str = '"id":' + data.id; 4448 if(data.img != null && data.img != undefined && data.img != "") 4449 { 4450 str += ',"img":"' + data.img + '"'; 4451 } 4452 if(data.code != null && data.code != undefined && data.code != "") 4453 { 4454 str += ',"code":"' + data.code + '"'; 4455 } 4456 str = '{' + str + '}'; 4457 if(items_str != "") 4458 { 4459 items_str += ',' + str; 4460 } 4461 else 4462 { 4463 items_str += str; 4464 } 4465 } 4466 } 4467 } 4468 var new_str = '"id":' + pid; 4469 var img = $("#" + pid + "_IMG").val(); 4470 if(img != null && img != undefined && img != "") 4471 { 4472 new_str += ',"img":"' + img + '"'; 4473 } 4474 var code = $("#" + pid + "_TOUR_CODE").val(); 4475 if(code != null && code != undefined && code != "") 4476 { 4477 new_str += ',"code":"' + code + '"'; 4478 } 4479 new_str = '{' + new_str + '}'; 4480 if(items_str != "") 4481 { 4482 items_str += ',' + new_str; 4483 } 4484 else 4485 { 4486 items_str += new_str; 4487 } 4488 items_str = '[' + items_str + ']'; 4489 var items_json = eval("("+items_str+")"); 4490 set_local_storage_ttl("compareTours", items_json, 2592000); 4491 $("#compare_icon_"+ pid).removeClass("icon-checkbox").addClass("icon-ok-squared"); 4492 show_compare_products(); 4493 $(".compare-tour-group").show(); 4494 $(".compare-tour-title").find("i").removeClass("icon-angle-down").addClass("icon-angle-up"); 4495 num = num + 1; 4496 if(num == 5) 4497 { 4498 $(".compare-btn:not(.disabled)").find(".icon-checkbox").parent().addClass("disabled"); 4499 } 4500} 4501 4502function remove_compare_product(pid) 4503{ 4504 var datas = get_local_storage_ttl("compareTours"); 4505 var items_str = ""; 4506 var num = 0; 4507 if(datas != null && datas != undefined && datas != "" && datas.length > 0) 4508 { 4509 num = datas.length; 4510 for (let data of datas) 4511 { 4512 if(data.id != pid) 4513 { 4514 var str = '"id":' + data.id; 4515 if(data.img != null && data.img != undefined && data.img != "") 4516 { 4517 str += ',"img":"' + data.img + '"'; 4518 } 4519 if(data.code != null && data.code != undefined && data.code != "") 4520 { 4521 str += ',"code":"' + data.code + '"'; 4522 } 4523 str = '{' + str + '}'; 4524 if(items_str != "") 4525 { 4526 items_str += ',' + str; 4527 } 4528 else 4529 { 4530 items_str += str; 4531 } 4532 } 4533 } 4534 } 4535 if(items_str != "") 4536 { 4537 items_str = '[' + items_str + ']'; 4538 var items_json = eval("("+items_str+")");
4539 set_local_storage_ttl("compareTours", items_json, 2592000); 4540 } 4541 else 4542 { 4543 set_local_storage_ttl("compareTours", {}, 2592000); 4544 } 4545 $("#compare_icon_"+ pid).removeClass("icon-ok-squared").addClass("icon-checkbox"); 4546 show_compare_products(); 4547 $(".compare-tour-group").show(); 4548 $(".compare-tour-title").find("i").removeClass("icon-angle-down").addClass("icon-angle-up"); 4549 num = num - 1; 4550 if(num < 5) 4551 { 4552 $(".compare-btn").find(".icon-checkbox").parent().removeClass("disabled"); 4553 } 4554} 4555 4556function show_compare_products() 4557{ 4558 $("#compare_tours_banner").remove(); 4559 if($(".search-compare-div").length > 0 || $(".product-compare-div").length > 0 || $(".compare-btn").length > 0) { 4560 var datas = get_local_storage_ttl("compareTours"); 4561 if(datas != null && datas != undefined && datas != "" && datas.length > 0) 4562 { 4563 var items_html = ""; 4564 var i = 0; 4565 for (let data of datas) 4566 { 4567 i++; 4568 $("#compare_icon_"+ data.id).removeClass("icon-checkbox").addClass("icon-ok-squared"); 4569 items_html += '<div class="compare-tour-item" pid="' + data.id + '">' + 4570 '<img src="' + data.img + '"/>' + 4571 '<div class="compare-tour-item-code">' + data.code + '</div>' + 4572 '<div class="compare-tour-item-cancel" onclick="remove_compare_product(' + data.id + ');"><i class="fa icon-cancel"></i></div>' + 4573 '</div>'; 4574 } 4575 for(var j=0;j<5-i;j++) 4576 { 4577 items_html += '<div class="compare-tour-item" pid="0">' + 4578 '</div>'; 4579 } 4580 var disabled_class = i > 1 ? "" : "disabled"; 4581 var html = '<div class="compare-tour-content"><i class="fa fa-lg icon-cancel" onclick="close_compare_products(event);"></i>' + 4582 '<div class="compare-tour-title" onclick="toggle_compare_tour_group();">' + 4583 '<i class="fa fa-lg icon-angle-down"></i>' + '<span>Selected items for comparison (' + i + '/5)</span>' + 4584 '</div>' + 4585 '<div class="compare-tour-group clearfix" style="display:none;">' + 4586 '<div class="compare-tour-item-div">' + items_html + '</div>' + 4587 '<input type="button" class="compare-tour-btn ' + disabled_class + '" value="Compare" onclick="compare_products();"/>' + 4588 '</div></div>'; 4589 if($("#compare_tours_banner").length == 0) 4590 { 4591 $("<div id='compare_tours_banner'></div>").appendTo(document.body); 4592 } 4593 $("#compare_tours_banner").empty().append(html); 4594 if($("#my_deals_banner").length > 0) 4595 { 4596 var bottom = 10 + parseInt($("#my_deals_banner").css("bottom")) + parseInt($('#my_deals_banner').outerHeight(true)); 4597 $("#compare_tours_banner").css("bottom", bottom + "px"); 4598 } 4599 else 4600 { 4601 if(($("#app-banner").length > 0 && $("#app-banner").is(":visible")) || ($("#mobile-fixed-footer").length > 0 && $("#mobile-fixed-footer").is(":visible"))) { 4602 $("#compare_tours_banner").css("bottom", "72px"); 4603 } 4604 } 4605 if(datas.length == 5) 4606 { 4607 $(".compare-btn:not(.disabled)").find(".icon-checkbox").parent().addClass("disabled"); 4608 } 4609 } 4610 } 4611} 4612 4613function compare_products() 4614{ 4615 if($(".compare-tour-btn").hasClass("disabled")) 4616 { 4617 return false; 4618 } 4619 var pids_arr = new Array(); 4620 $(".compare-tour-item").each(function(){ 4621 if($(this).attr("pid") != "0") 4622 { 4623 pids_arr.push(parseInt($(this).attr("pid"))); 4624 } 4625 }); 4626 if(pids_arr.length > 0) 4627 { 4628 var blocker; 4629 $.ajax({ 4630 url: "/cgi-bin/ajax.cgi", 4631 data: { 4632 type: "compare_products", 4633 pids: pids_arr.join(",") 4634 }, 4635 beforeSend: function() { 4636 blocker = dispaly_sc_fade_block(); 4637 }, 4638 success: function (data) { 4639 $(blocker).remove(); 4640 shownAsModal(data, "tour_compare", "Tours Compare"); 4641 show_compare_products(); 4642 $(".compare-tour-group").show(); 4643 switch_currency(); 4644 $(".compare-tour-title").find("i").removeClass("icon-angle-down").addClass("icon-angle-up"); 4645 $(".package-compare-table td").mouseover(function(){ 4646 if(!$(this).hasClass("title-td")) 4647 { 4648 $(this).parent().addClass("current-tr"); 4649 var index = $(this).index(); 4650 $('.package-compare-table').find('tr').find('td:eq(' + index + ')').addClass("current-td"); 4651 } 4652 }); 4653 $(".package-compare-table td").mouseout(function(){ 4654 if(!$(this).hasClass("title-td")) 4655 { 4656 $(this).parent().removeClass("current-tr"); 4657 var index = $(this).index(); 4658 $('.package-compare-table').find('tr').find('td:eq(' + index + ')').removeClass("current-td"); 4659 } 4660 }); 4661 }, 4662 error: function () { 4663 $(blocker).remove(); 4664 } 4665 }); 4666 } 4667} 4668 4669function toggle_compare_tour_group() 4670{ 4671 if($(".compare-tour-group").is(":visible")) { 4672 $(".compare-tour-group").hide(); 4673 $(".compare-tour-title").find("i").removeClass("icon-angle-up").addClass("icon-angle-down"); 4674 } else { 4675 $(".compare-tour-group").show(); 4676 $(".compare-tour-title").find("i").removeClass("icon-angle-down").addClass("icon-angle-up"); 4677 } 4678} 4679 4680function close_compare_products(event) 4681{ 4682 event.cancelBubble=true; 4683 event.stopPropagation(); 4684 $("#compare_tours_banner").remove(); 4685} 4686 4687function remove_compare_product_td(pid) 4688{ 4689 if($(".first-tr").find(".content-td").length > 2) 4690 { 4691 $("#dialog-tour_compare").find(".content-td[pid='" + pid + "']").remove(); 4692 } 4693 else 4694 { 4695 $("#tour_compare").dialog("close"); 4696 } 4697 remove_compare_product(pid); 4698} 4699 4700function init_tour_vacation_menu() 4701{ 4702 $(".tour-vacation-menu").find(".menu-item").mouseover(function(){ 4703 $(".tour-vacation-menu").find(".menu-item").removeClass("active"); 4704 $(".tour-vacation-menu").find(".sub-menu").removeClass("active"); 4705 $(this).addClass("active"); 4706 var region = $(this).attr("region"); 4707 $(".tour-vacation-menu").find(".sub-menu[region='" + region + "']").addClass("active"); 4708 }); 4709 $(".tour-vacation-menu").parent().find(".dropdown-toggle").mouseover(function(){ 4710 $(".tour-vacation-menu").find(".menu-item").removeClass("active"); 4711 $(".tour-vacation-menu").find(".sub-menu").removeClass("active"); 4712 $(".tour-vacation-menu").find(".default-menu").addClass("active"); 4713 }); 4714} 4715 4716function init_tour_vacation_menu_group() 4717{ 4718 var vacation_menu_group = $(".tt-vacation-menu-view"); 4719 if(vacation_menu_group.length == 0) 4720 { 4721 return; 4722 } 4723 vacation_menu_group.find(".tt-vacation-menu-region").click(function(e){ 4724 if($(e.target).closest(".tt-vacation-menu-actions").length > 0) 4725 { 4726 return; 4727 } 4728 var item = $(this).closest(".tt-vacation-menu-item"); 4729 var detail_box = item.find(".tt-vacation-menu-d-box"); 4730 var toggle_icon = $(this).find(".tt-vacation-menu-toggle-icon"); 4731 detail_box.slideToggle(180); 4732 toggle_icon.toggleClass("icon-angle-up icon-angle-down"); 4733 }); 4734}
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.