var TOGO_FRAMEWORK=TOGO_FRAMEWORK||{};(function($){"use strict";TOGO_FRAMEWORK.ready_element={init:function(){},};TOGO_FRAMEWORK.load_element={init:function(){TOGO_FRAMEWORK.load_element.general();TOGO_FRAMEWORK.load_element.custom_select();TOGO_FRAMEWORK.load_element.mega_menu();TOGO_FRAMEWORK.load_element.price_range();TOGO_FRAMEWORK.load_element.trip_filter();TOGO_FRAMEWORK.load_element.trip_card();TOGO_FRAMEWORK.load_element.trip_map();TOGO_FRAMEWORK.load_element.calendar();TOGO_FRAMEWORK.load_element.my_account();TOGO_FRAMEWORK.load_element.validate_form();TOGO_FRAMEWORK.load_element.forget_password();TOGO_FRAMEWORK.load_element.handlePopState();},tour_maps_intinerary:function(){const $mapElement=$("#togo-st-tour-maps-map");if(!$mapElement.length)return;let coordinatesData=$mapElement.data("coordinates");const lineColor=$mapElement.data("line-color")||"#ff5722";const arrowColor=$mapElement.data("arrow-color")||"#ff5722";const arrowSpeed=parseInt($mapElement.data("arrow-speed"),10)||50;const mapZoom=parseInt($mapElement.data("map-zoom"),10)||12;const mapProvider=String($mapElement.data("map-provider")||"google_map").toLowerCase();const mapboxToken=$mapElement.data("mapbox-token")||"";let mapboxStyle=$mapElement.data("mapbox-style")||"mapbox/streets-v12";if(mapboxStyle&&!String(mapboxStyle).includes("/")){mapboxStyle="mapbox/"+mapboxStyle;}
function normalizeCoords(coords){try{if(typeof coords==="string")coords=JSON.parse(coords);}catch(e){console.error("Invalid data-coordinates JSON",e);coords=[];}
if(!Array.isArray(coords))return[];return coords.map((c)=>{if(typeof c==="string"){const parts=c.split(",").map(Number);return{lat:parts[0],lng:parts[1]};}
if(Array.isArray(c)){return{lat:Number(c[0]),lng:Number(c[1])};}
if(c&&typeof c==="object"&&"lat"in c&&"lng"in c){return{lat:Number(c.lat),lng:Number(c.lng)};}
return null;}).filter(Boolean);}
const pathCoordinates=normalizeCoords(coordinatesData);if(!pathCoordinates.length)return;function initGoogle(){if(!(window.google&&google.maps)){console.error("Google Maps JS API not loaded.");return;}
function CustomMarker(position,map,iconClass,index){this.position=new google.maps.LatLng(position.lat,position.lng);this.map=map;this.index=index;this.div=$("<div>").addClass(`custom-marker ${iconClass}`).css("position","absolute").html(`<span class="marker-index">${index}</span>`)[0];this.setMap(map);}
CustomMarker.prototype=new google.maps.OverlayView();CustomMarker.prototype.onAdd=function(){const panes=this.getPanes();$(panes.overlayMouseTarget).append(this.div);};CustomMarker.prototype.draw=function(){const proj=this.getProjection();const pos=proj.fromLatLngToDivPixel(this.position);$(this.div).css({left:`${pos.x - 8}px`,top:`${pos.y - 9}px`});};CustomMarker.prototype.onRemove=function(){$(this.div).remove();};const map=new google.maps.Map($mapElement[0],{center:pathCoordinates[0],zoom:mapZoom,mapTypeId:"terrain",});const lineSymbol={path:google.maps.SymbolPath.FORWARD_CLOSED_ARROW,scale:3,strokeColor:arrowColor,};const line=new google.maps.Polyline({path:pathCoordinates,icons:[{icon:lineSymbol,offset:"100%"}],geodesic:true,strokeColor:lineColor,strokeOpacity:1.0,strokeWeight:3,map:map,});$.each(pathCoordinates,(i,pos)=>{new CustomMarker(pos,map,"custom-marker-icon",i+1);});(function animateCircle(polyline){let count=0;setInterval(()=>{count=(count+1)%200;const icons=polyline.get("icons");icons[0].offset=count/2+"%";polyline.set("icons",icons);},arrowSpeed);})(line);}
function initLeaflet(){if(typeof L==="undefined"){console.error("Leaflet not loaded.");return;}
const latlngs=pathCoordinates.map((p)=>[p.lat,p.lng]);const map=L.map($mapElement[0],{center:latlngs[0],zoom:mapZoom,scrollWheelZoom:false,});L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{maxZoom:19,attribution:"&copy; OpenStreetMap contributors",}).addTo(map);const polyline=L.polyline(latlngs,{color:lineColor,weight:4,opacity:1,}).addTo(map);latlngs.forEach((pt,idx)=>{const divIcon=L.divIcon({className:"custom-marker custom-marker-icon",html:`<span class="marker-index">${idx + 1}</span>`,iconSize:[0,0],});L.marker(pt,{icon:divIcon,interactive:false}).addTo(map);});const movingArrowIcon=L.divIcon({className:"moving-arrow",html:`<div class="moving-arrow-inner" style="border-top-color:${arrowColor}"></div>`,iconSize:[0,0],});const movingMarker=L.marker(latlngs[0],{icon:movingArrowIcon,interactive:false,}).addTo(map);const toRad=(d)=>(d*Math.PI)/180;function haversine(a,b){const R=6371000;const dLat=toRad(b[0]-a[0]);const dLng=toRad(b[1]-a[1]);const s=Math.sin(dLat/2)**2+
Math.cos(toRad(a[0]))*Math.cos(toRad(b[0]))*Math.sin(dLng/2)**2;return 2*R*Math.asin(Math.sqrt(s));}
function bearing(a,b){const φ1=toRad(a[0]),φ2=toRad(b[0]);const λ1=toRad(a[1]),λ2=toRad(b[1]);const y=Math.sin(λ2-λ1)*Math.cos(φ2);const x=Math.cos(φ1)*Math.sin(φ2)-
Math.sin(φ1)*Math.cos(φ2)*Math.cos(λ2-λ1);return((Math.atan2(y,x)*180)/Math.PI+360)%360;}
function lerp(a,b,t){return[a[0]+(b[0]-a[0])*t,a[1]+(b[1]-a[1])*t];}
const segs=[];let totalLen=0;for(let i=0;i<latlngs.length-1;i++){const len=haversine(latlngs[i],latlngs[i+1]);segs.push({a:latlngs[i],b:latlngs[i+1],len});totalLen+=len;}
if(!segs.length)return;let dist=0;const stepMeters=Math.max(totalLen/200,1);setInterval(()=>{dist=(dist+stepMeters)%totalLen;let acc=0,si=0;while(si<segs.length&&acc+segs[si].len<dist){acc+=segs[si].len;si++;}
const seg=segs[Math.min(si,segs.length-1)];const t=(dist-acc)/(seg.len||1);const pos=lerp(seg.a,seg.b,t);movingMarker.setLatLng(pos);const deg=bearing(seg.a,seg.b);const el=movingMarker.getElement();if(el&&el.firstChild){el.firstChild.style.transform=`translate(-50%, -50%) rotate(${deg}deg)`;}},arrowSpeed);}
function initMapbox(){if(typeof mapboxgl==="undefined"){console.error("Mapbox GL JS not loaded.");return;}
if(!mapboxToken){console.error("Missing data-mapbox-token on #togo-st-tour-maps-map.");return;}
mapboxgl.accessToken=mapboxToken;const map=new mapboxgl.Map({container:$mapElement[0],style:"m
Math.cos(toRad(a[0]))*Math.cos(toRad(b[0]))*Math.sin(dLng/2)**2;return 2*R*Math.asin(Math.sqrt(s));}
function bearing(a,b){const φ1=toRad(a[0]),φ2=toRad(b[0]);const λ1=toRad(a[1]),λ2=toRad(b[1]);const y=Math.sin(λ2-λ1)*Math.cos(φ2);const x=Math.cos(φ1)*Math.sin(φ2)-
Math.sin(φ1)*Math.cos(φ2)*Math.cos(λ2-λ1);return((Math.atan2(y,x)*180)/Math.PI+360)%360;}
function lerp(a,b,t){return[a[0]+(b[0]-a[0])*t,a[1]+(b[1]-a[1])*t];}
const segs=[];let totalLen=0;for(let i=0;i<latlngs.length-1;i++){const len=haversine(latlngs[i],latlngs[i+1]);segs.push({a:latlngs[i],b:latlngs[i+1],len});totalLen+=len;}
if(!segs.length)return;let dist=0;const stepMeters=Math.max(totalLen/200,1);setInterval(()=>{dist=(dist+stepMeters)%totalLen;let acc=0,si=0;while(si<segs.length&&acc+segs[si].len<dist){acc+=segs[si].len;si++;}
const seg=segs[Math.min(si,segs.length-1)];const t=(dist-acc)/(seg.len||1);const pos=lerp(seg.a,seg.b,t);const deg=bearing(seg.a,seg.b);movingMarker.setLngLat([pos[1],pos[0]]);const inner=arrowEl.firstChild;if(inner){inner.style.transform=`translate(-50%, -50%) rotate(${deg}deg)`;}},arrowSpeed);});}
if(mapProvider==="google_map"){initGoogle();}else if(mapProvider==="openstreetmap"){initLeaflet();}else if(mapProvider==="mapbox"){initMapbox();}else{console.warn("Unknown map provider:",mapProvider);}
$(".togo-st-itinerary-item-title").on("click",function(e){e.preventDefault();$(this).parent().find(".togo-st-itinerary-item-content").slideToggle();$(this).toggleClass("is-active");});},hide_element_on_click_outside:function(elementSelector,elementHide){$(document).on("click",function(event){if(!$(event.target).closest(elementSelector).length){if(elementHide){$(elementHide).hide();}else{$(elementSelector).hide();}}});},general:function(){TOGO_FRAMEWORK.load_element.hide_element_on_click_outside(".togo-select",".togo-select__content");},custom_select:function(){$("body").off("click.customSelect",".togo-select__label").on("click.customSelect",".togo-select__label",function(e){e.preventDefault();$(".togo-select__label").not(this).parent().find(".togo-select__content").fadeOut(0);$(this).parent().find(".togo-select__content").fadeToggle(0);});},mega_menu:function(){$(".desktop-menu .sub-menu.mega-menu").each(function(){var $simpleMenu=$(".desktop-menu .sub-menu.simple-menu");if($simpleMenu.length>0){var top=$simpleMenu.offset().top;$(this).css({top:top-10+"px",});}else{var top=$(this).parent().offset().top+$(this).parent().outerHeight();$(this).css({top:top+"px",});}});},price_range:function(){$(document).off("mouseup mousedown input touchend touchstart",'.filter-price input[type="range"]');window.sliderBeingDragged=false;window.sliderUpdateTimeout=null;function updateView(){var $this=$(this);var $range_one=$('.filter-price input[name="min_price"]');var $range_two=$('.filter-price input[name="max_price"]');var $min_price=$(".filter-price .show-min-price");var $max_price=$(".filter-price .show-max-price");var $incl_range=$(".incl-range");if($range_one.length===0||$range_two.length===0){return;}
var maxVal=parseInt($this.attr("max"),10),rangeOneVal=parseInt($range_one.val(),10),rangeTwoVal=parseInt($range_two.val(),10),price=TOGO_FRAMEWORK.load_element.formatPrice($this.val());if($this.attr("name")==="min_price"){$min_price.text(price);}else{$max_price.text(price);}
if(rangeOneVal>rangeTwoVal){$incl_range.css({width:((rangeOneVal-rangeTwoVal)/maxVal)*100+"%",left:(rangeTwoVal/maxVal)*100+"%",});}else{$incl_range.css({width:((rangeTwoVal-rangeOneVal)/maxVal)*100+"%",left:(rangeOneVal/maxVal)*100+"%",});}}
var $existingSliders=$('.filter-price input[type="range"]');if($existingSliders.length>0){updateView.call($existingSliders.filter('[name="min_price"]')[0]);updateView.call($existingSliders.filter('[name="max_price"]')[0]);}
$(document).on("mousedown touchstart",'.filter-price input[type="range"]',function(){window.sliderBeingDragged=true;if(window.sliderUpdateTimeout){clearTimeout(window.sliderUpdateTimeout);window.sliderUpdateTimeout=null;}}).on("input",'.filter-price input[type="range"]',function(){var $this=$(this);updateView.call(this);var currentValue=$this.val();$this.attr("value",currentValue);$this.prop("value",currentValue);}).on("mouseup touchend",'.filter-price input[type="range"]',function(){var $this=$(this);var currentValue=$this.val();var inputName=$this.attr("name");window.sliderBeingDragged=false;$this.attr("value",currentValue);$this.prop("value",currentValue);if(window.sliderUpdateTimeout){clearTimeout(window.sliderUpdateTimeout);}
window.sliderUpdateTimeout=setTimeout(function(){updateURLWithCurrentSliderValues();window.sliderUpdateTimeout=null;},300);$this.blur();});function updateURLWithCurrentSliderValues(){var $minPriceInput=$('.filter-price input[name="min_price"]');var $maxPriceInput=$('.filter-price input[name="max_price"]');var minPrice=null;var maxPrice=null;if($minPriceInput.length){minPrice=$minPriceInput.val()||$minPriceInput.attr("value")||$minPriceInput.prop("value");}
if($maxPriceInput.length){maxPrice=$maxPriceInput.val()||$maxPriceInput.attr("value")||$maxPriceInput.prop("value");}
if(window.sliderBeingDragged||(!minPrice&&!maxPrice)){return;}
var currentUrl=new URL(window.location);var params=currentUrl.searchParams;params.delete("min_price");params.delete("max_price");if(minPrice!==undefined&&minPrice!==null&&minPrice!==""){params.set("min_price",minPrice);}
if(maxPrice!==undefined&&maxPrice!==null&&maxPrice!==""){params.set("max_price",maxPrice);}
var pathname=currentUrl.pathname;pathname=pathname.replace(/\/page\/\d+\/?/,"");if(!pathname.endsWith("/")){pathname+="/";}
var newUrl=pathname+(params.toString()?"?"+params.toString():"");var fullNewUrl=currentUrl.origin+newUrl;if(window.location.href!==fullNewUrl){window.history.pushState({},"",newUrl);triggerFilterAjax(newUrl);}else{console.log("URLs are the same, no update needed");}}
function triggerFilterAjax(url){TOGO_FRAMEWORK.load_element.performFilterRequestByURL(url,false);}},updateSliderView:function(sliderElement){if(!sliderElement)return;var $this=$(sliderElement);var $range_one=$('.filter-price input[name="min_price"]');var $range_two=$('.filter-price input[name="max_price"]');var $min_price=$(".filter-price .show-min-price");var $max_price=$(".filter-price .show-max-price");var $incl_range=$(".incl-range");if($range_one.length===0||$range_two.length===0){return;}
var maxVal=parseInt($this.attr("max"),10),rangeOneVal=parseInt($range_one.val(),10),rangeTwoVal=parseInt($range_two.val(),10),price=TOGO_FRAMEWORK.load_element.formatPrice($this.val());if($this.attr("name")==="min_price"){$min_price.text(price);}else{$max_price.text(price);}
if(rangeOneVal>rangeTwoVal){$incl_range.css({width:((rangeOneVal-rangeTwoVal)/maxVal)*100+"%",left:(rangeTwoVal/maxVal)*100+"%",});}else{$incl_range.css({width:((rangeTwoVal-rangeOneVal)/maxVal)*100+"%",left:(rangeOneVal/maxVal)*100+"%",});}},number_format:function(number,decimals,dec_point,thousands_sep){number=(number+"").replace(/[^0-9+\-Ee.]/g,"");const n=!isFinite(+number)?0:+number;const prec=!isFinite(+decimals)?0:Math.abs(decimals);const sep=thousands_sep===undefined?",":thousands_sep;const dec=dec_point===undefined?".":dec_point;let s="";const toFixedFix=function(n,prec){const k=Math.pow(10,prec);return""+Math.round(n*k)/k;};s=(prec?toFixedFix(n,prec):""+Math.round(n)).split(".");if(s[0].length>3){s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,sep);}
if((s[1]||"").length<prec){s[1]=s[1]||"";s[1]+=new Array(prec-s[1].length+1).join("0");}
return s.join(dec);},formatPrice:function(number){var symbol=theme_vars.symbol;var currency_position=theme_vars.currency_position;var currency_thousand_separator=theme_vars.currency_thousand_separator;var currency_decimal_separator=theme_vars.currency_decimal_separator;var currency_number_of_decimals=theme_vars.currency_number_of_decimals;if(currency_position=="right"){return(TOGO_FRAMEWORK.load_element.number_format(number,currency_number_of_decimals,currency_decimal_separator,currency_thousand_separator)+symbol);}else if(currency_position=="right_space"){return(TOGO_FRAMEWORK.load_element.number_format(number,currency_number_of_decimals,currency_decimal_separator,currency_thousand_separator)+" "+
symbol);}else if(currency_position=="left"){return(symbol+
TOGO_FRAMEWORK.load_element.number_format(number,currency_number_of_decimals,currency_decimal_separator,currency_thousand_separator));}else if(currency_position=="left_space"){return(symbol+" "+
TOGO_FRAMEWORK.load_element.number_format(number,currency_number_of_decimals,currency_decimal_separator,currency_thousand_separator));}},trip_filter:function(){$("body").off("click.filterToggle change.tripFilter submit.tripFilter");$("body").on("click.filterToggle",".filter-item__top",function(e){e.preventDefault();$(this).closest(".filter-item").toggleClass("active");$(this).closest(".filter-item").find(".filter-item__content").slideToggle();});$("body").on("click.showMore",".show-more a",function(e){e.preventDefault();$(this).closest(".show-more").toggleClass("active");$(this).closest(".filter-item__content").find(".filter-checkbox.hide").toggleClass("show");});$("body").on("change.tripFilter",".togo-trip-filter input",function(e){var $input=$(this);var name=$input.attr("name");var value=$input.val();var isChecked=$input.is(":checked");var type=$input.attr("type");window.togoFilterProcessing=true;if(type==="checkbox"){var checkboxName=$input.attr("name");var checkboxValue=$input.val();var shouldBeChecked=isChecked;$('input[type="checkbox"][name="'+
checkboxName+'"][value="'+
checkboxValue+'"]').each(function(){var $otherCheckbox=$(this);var wasChecked=$otherCheckbox.prop("checked");if(wasChecked!==shouldBeChecked){$otherCheckbox.prop("checked",shouldBeChecked);if(shouldBeChecked){$otherCheckbox.closest(".filter-checkbox").addClass("checked");}else{$otherCheckbox.closest(".filter-checkbox").removeClass("checked");}}});if(isChecked){$input.closest(".filter-checkbox").addClass("checked");}else{$input.closest(".filter-checkbox").removeClass("checked");}}
TOGO_FRAMEWORK.load_element.performFilterRequest($input.closest(".togo-trip-filter"));});$("body").on("submit.tripFilter",".togo-trip-filter",function(e){e.preventDefault();TOGO_FRAMEWORK.load_element.performFilterRequest($(this));});$("body").on("click",".trip-list-header__sort-list a",function(e){e.preventDefault();var url=$(this).attr("href");TOGO_FRAMEWORK.load_element.performFilterRequestByURL(url,false);});$("body").on("click",".pagination a, .togo-pagination a",function(e){e.preventDefault();var originalUrl=$(this).attr("href");var $clickedLink=$(this);var url=originalUrl.replace(/&amp;/g,"&").replace(/&#038;/g,"&").replace(/#038;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/types%5B0%5D/g,"types[]").replace(/types%5B1%5D/g,"types[]").replace(/types%5B\d+%5D/g,"types[]");if($clickedLink.hasClass("loading-pagination")){return;}
$clickedLink.addClass("loading-pagination");window.history.pushState({},"",url);TOGO_FRAMEWORK.load_element.performFilterRequestByURL(url,true);});$("body").on("click",".trip-list-header__clear-filter",function(e){e.preventDefault();var url=$(this).attr("href");TOGO_FRAMEWORK.load_element.resetAllFilters();TOGO_FRAMEWORK.load_element.performFilterRequestByURL(url,false);});$("body").on("click",".open-filter-canvas",function(e){e.preventDefault();$(".filter-canvas-wrapper").addClass("open");$("body").addClass("no-scroll");});$("body").on("click",".filter-canvas-overlay",function(e){e.preventDefault();$(this).parent().removeClass("open");$("body").removeClass("no-scroll");});$("body").on("change",".filter-canvas-wrapper input[type='checkbox'], .filter-canvas-wrapper input[type='radio'], .filter-canvas-wrapper select",function(e){setTimeout(function(){$(".filter-canvas-wrapper").removeClass("open");$("body").removeClass("no-scroll");},100);});$("input[name='location']").focus(function(){$(this).closest(".trip-search-form").find(".field-location__result").fadeIn(0);$(this).closest(".trip-search-form").find(".field-dates .calendar-wrapper").fadeOut(0);});$("input[name='guests']").focus(function(){$(this).closest(".trip-search-form").find(".field-location__result").fadeOut(0);$(this).closest(".trip-search-form").find(".field-dates .calendar-wrapper").fadeOut(0);});$(".near-me").on("click",function(e){e.preventDefault();var _this=$(this);var apiKey=theme_vars.google_map_api;if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){var lat=position.coords.latitude;var lng=position.coords.longitude;var geocodeURL=`https://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${lng}&key=${apiKey}`;$.get(geocodeURL,function(data){if(data.status==="OK"){var results=data.results[0];var city="";results.address_components.forEach(function(component){if(component.types.includes("locality")){city=component.long_name;}});_this.closest(".trip-search-form").find("input[name='location']").val(city);}else{alert("Unable to fetch location details.");}});},function(error){alert("Error getting location: "+error.message);});}else{alert("Geolocation is not supported by your browser.");}
var text=$(this).find(".near-me__text").text();$(this).closest(".trip-search-form").find("input[name='location']").val(text);$(this).closest(".trip-search-form").find(".field-location__result").fadeOut(0);$(this).closest(".trip-search-form").find(".field-location__remove").css("display","flex");});$("input[name='location']").on("keyup",function(){var value=$(this).val();var found=false;$(".location-list").find("li").each(function(){var text=$(this).text();if(text.toLowerCase().indexOf(value.toLowerCase())>-1){$(this).show();found=true;}else{$(this).hide();}});if(!found){$(".location-list").find(".no-result").removeClass("hide");}else{$(".location-list").find(".no-result").addClass("hide");}
$(this).closest(".trip-search-form").find(".field-location__remove").css("display","flex");});$("body").on("click",".location-list li a",function(e){e.preventDefault();var value=$(this).text();$(this).closest(".trip-search-form").find("input[name='location']").val(value);$(this).closest(".trip-search-form").find(".field-location__result").fadeOut(0);$(this).closest(".trip-search-form").find(".field-location__remove").css("display","flex");});$("body").on("click",".field-location__remove",function(e){e.preventDefault();$(this).closest(".trip-search-form").find('input[name="location"]').val("");$(this).closest(".trip-search-form").find(".field-location__result").fadeOut(0);$(this).closest(".trip-search-form").find(".location-list").find(".no-result").addClass("hide");$(this).closest(".trip-search-form").find(".location-list li").show();$(this).css("display","none");});$("body").on("click",".field-dates__remove",function(e){e.preventDefault();$(this).closest(".trip-search-form").find('input[name="dates"]').val("");$(this).css("display","none");});},resetAllFilters:function(){$('.togo-trip-filter input[type="checkbox"]').each(function(){$(this).prop("checked",false);$(this).closest(".filter-checkbox").removeClass("checked");});$('.togo-trip-filter input[type="radio"]').each(function(){$(this).prop("checked",false);});$(".togo-trip-filter select").each(function(){$(this).val("");var $customSelect=$(this).closest(".togo-select");if($customSelect.length){var firstOptionText=$(this).find("option:first").text();$customSelect.find(".togo-select__label span").text(firstOptionText||"Select...");}});$('.filter-price input[type="range"]').each(function(){var $slider=$(this);var defaultVal=$slider.attr("min")||"0";if($slider.attr("name")==="max_price"){defaultVal=$slider.attr("max")||$slider.val();}
$slider.val(defaultVal);$slider.attr("value",defaultVal);$slider.prop("value",defaultVal);if($slider.length){TOGO_FRAMEWORK.load_element.updateSliderView($slider[0]);}});$('.trip-search-form input[type="text"]').each(function(){$(this).val("");});$('.trip-search-form input[name="dates"], .trip-search-form input[name="date_default"]').each(function(){$(this).val("");});$(".field-location__remove, .field-dates__remove, .field-date-default__remove").hide();$(".location-list li").show();$(".location-list .no-result").addClass("hide");$(".field-location__result, .calendar-wrapper").fadeOut(0);},collectAllActiveFilters:function(){var allFilters={};var checkboxGroups={};$(".togo-trip-filter, .trip-search-form").each(function(){var $form=$(this);$form.find('input[type="checkbox"]').each(function(){var name=$(this).attr("name");if(name&&!checkboxGroups[name]){checkboxGroups[name]=true;allFilters[name]=[];}});});$(".togo-trip-filter, .trip-search-form").each(function(formIndex){var $form=$(this);var formType=$form.hasClass("trip-search-form")?"search":"filter";$form.find("input, select").each(function(inputIndex){var $input=$(this);var name=$input.attr("name");var value=$input.val();var type=$input.attr("type");var isChecked=$input.is(":checked");if(!name){return;}
if(formType==="search"){if(value&&value!==""){allFilters[name]=value;}}else{if(type==="checkbox"||type==="radio"){if(isChecked&&value){if(allFilters[name]&&Array.isArray(allFilters[name])){if(!allFilters[name].includes(value)){allFilters[name].push(value);}}else{allFilters[name]=[value];}}}else if(type==="range"){if(name==="min_price"||name==="max_price"){allFilters[name]=value;}else{if(value){allFilters[name]=value;}}}else if(type==="text"||type==="hidden"){if(value&&value!==""){allFilters[name]=value;}}else if($input.is("select")){if(value&&value!==""){allFilters[name]=value;}}}});});Object.keys(allFilters).forEach(function(name){var value=allFilters[name];if(Array.isArray(value)&&value.length===0){delete allFilters[name];}});Object.keys(allFilters).forEach(function(name){var value=allFilters[name];if(Array.isArray(value)){}});return allFilters;},performFilterRequest:function($form){var activeFilters=TOGO_FRAMEWORK.load_element.collectAllActiveFilters();var urlParams=new URLSearchParams();var hasActiveFilters=Object.keys(activeFilters).length>0;if(hasActiveFilters){Object.keys(activeFilters).forEach(function(name){var value=activeFilters[name];if(Array.isArray(value)){value.forEach(function(v){urlParams.append(name,v);});}else{urlParams.append(name,value);}});}else{console.log("No active filters found - will create clean URL");}
var currentURL=window.location.pathname;currentURL=currentURL.replace(/\/page\/\d+\/?/,"");if(!currentURL.endsWith("/")){currentURL+="/";}
var fullURL=currentURL;var urlParamsString=urlParams.toString();if(urlParamsString){fullURL+="?"+urlParamsString;}
TOGO_FRAMEWORK.load_element.performFilterRequestByURL(fullURL,false);},performFilterRequestByURL:function(url,skipUrlUpdate=false){var urlObj=new URL(url,window.location.origin);var hasQueryParams=urlObj.search.length>1;if(!hasQueryParams){TOGO_FRAMEWORK.load_element.resetAllFilters();}
$(".type-trip.togo-column").addClass("skeleton-loading");fetch(url,{method:"GET",headers:{"X-Requested-With":"XMLHttpRequest",},}).then((response)=>{if(!response.ok){throw new Error("Network response was not ok");}
return response.text();}).then((html)=>{var $tempDiv=$("<div>").html(html);var $newTripList=$tempDiv.find(".trip-list");if($newTripList.length){$(".trip-list").replaceWith($newTripList);}
var tripItemsCount=0;if($newTripList.length){tripItemsCount=$newTripList.find("article.type-trip").length||$newTripList.find(".type-trip").length||$newTripList.find('article[class*="trip"]').length||$newTripList.find("article").length||$newTripList.children("div").length;}
var $newPagination=$tempDiv.find(".pagination, .togo-pagination");if($newPagination.length){$(".pagination, .togo-pagination").replaceWith($newPagination);}else{$(".pagination, .togo-pagination").hide();}
var $newPaginationInfo=$tempDiv.find(".tour-pagination-info");if($newPaginationInfo.length){$(".tour-pagination-info").replaceWith($newPaginationInfo);}else{$(".tour-pagination-info").hide();}
$(".filter-canvas-wrapper").removeClass("open");$("body").removeClass("no-scroll");var $newTripCount=$tempDiv.find(".trip-list-header__count");if($newTripCount.length){$(".trip-list-header__count").html($newTripCount.html());}
var $newTripHeader=$tempDiv.find(".trip-list-header");if($newTripHeader.length){$(".trip-list-header").replaceWith($newTripHeader);}
TOGO_FRAMEWORK.load_element.updateFilterCounts($tempDiv);var $newMapContainer=$tempDiv.find("#togo-map");if($newMapContainer.length){var newMarkerData=$newMapContainer.attr("data-marker");if(newMarkerData){var $currentMap=$("#togo-map");if($currentMap.length){$currentMap.attr("data-marker",newMarkerData);var parsedMarkerData=JSON.parse(newMarkerData);window.currentMarkerData=parsedMarkerData;TOGO_FRAMEWORK.load_element.updateMapMarkersFromCurrentPage();}}}
var shouldPreserveSliders=!window.sliderBeingDragged;var currentMinPrice,currentMaxPrice;if(shouldPreserveSliders){currentMinPrice=$('.filter-price input[name="min_price"]').val();currentMaxPrice=$('.filter-price input[name="max_price"]').val();}else{console.log("Skipping slider preservation - slider is being dragged");}
TOGO_FRAMEWORK.load_element.price_range();if(shouldPreserveSliders&&(currentMinPrice!==undefined||currentMaxPrice!==undefined)){if(currentMinPrice!==undefined&&currentMinPrice!==null){var $minSlider=$('.filter-price input[name="min_price"]');$minSlider.val(currentMinPrice).attr("value",currentMinPrice);if($minSlider.length){TOGO_FRAMEWORK.load_element.updateSliderView($minSlider[0]);}}
if(currentMaxPrice!==undefined&&currentMaxPrice!==null){var $maxSlider=$('.filter-price input[name="max_price"]');$maxSlider.val(currentMaxPrice).attr("value",currentMaxPrice);if($maxSlider.length){TOGO_FRAMEWORK.load_element.updateSliderView($maxSlider[0]);}}}
if(!skipUrlUpdate&&window.location.href!==url){window.history.pushState({},"",url);}
TOGO_FRAMEWORK.load_element.trip_card();TOGO_FRAMEWORK.load_element.custom_select();if(typeof TOGO_FRAMEWORK.load_element.trip_map==="function"){TOGO_FRAMEWORK.load_element.trip_map();}
TOGO_FRAMEWORK.load_element.updateMapMarkersFromCurrentPage();var $siteContent=$(".site-content");if($siteContent.length){var scrollDuration=skipUrlUpdate?200:300;$("html, body").animate({scrollTop:$siteContent.offset().top-100,},scrollDuration);}
$(".type-trip.togo-column").removeClass("skeleton-loading");}).catch((error)=>{$(".type-trip.togo-column").removeClass("skeleton-loading");window.location.href=url;}).finally(()=>{$(".loading-pagination").removeClass("loading-pagination");window.togoFilterProcessing=false;});},updateFilterCounts:function($responseDiv){return;},handlePopState:function(){window.addEventListener("popstate",function(e){if($(".togo-trip-filter, .trip-search-form").length>0){TOGO_FRAMEWORK.load_element.performFilterRequestByURL(window.location.href,false);}});},trip_card:function(){$(".trip-list .type-trip .trip-video, .togo-trip-grid .type-trip .trip-video").each(function(){const $videoBox=$(this);const iframe=$videoBox.find("iframe").get(0);const video=$videoBox.find("video").get(0);if(iframe){const src=iframe.getAttribute("src");if(src.includes("vimeo.com")){const player=new Vimeo.Player(iframe);let isHovering=false;$videoBox.on("mouseenter",function(){isHovering=true;$videoBox.addClass("playing");player.setMuted(true).then(()=>{if(isHovering){return player.play();}}).catch((e)=>{console.warn("Vimeo play error:",e);});});$videoBox.on("mouseleave",function(){isHovering=false;$videoBox.removeClass("playing");setTimeout(()=>{player.pause().catch((e)=>{console.warn("Vimeo pause error:",e);});},100);});}else if(src.includes("youtube.com")||src.includes("youtu.be")){$videoBox.on("mouseenter",function(){$videoBox.addClass("playing");iframe.contentWindow.postMessage(JSON.stringify({event:"command",func:"playVideo",args:[],}),"*");});$videoBox.on("mouseleave",function(){$videoBox.removeClass("playing");iframe.contentWindow.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:[],}),"*");});}}
if(video){$videoBox.on("mouseenter",function(){$videoBox.addClass("playing");video.muted=true;video.play().catch(()=>{});});$videoBox.on("mouseleave",function(){$videoBox.removeClass("playing");video.pause();video.currentTime=0;});}});$(".trip-list.togo-row .trip-inner").each(function(){var width=$(this).width();$(this).find(".trip-gallery").css("width",width+"px");});if($(window).width()<=767){$(".trip-list .type-trip-list .trip-inner").each(function(){var width=$(this).width();$(this).find(".trip-gallery").css("width",width+"px");});}
$(".trip-gallery-slider").TogoSwiper();var svgPrevIcon=`
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.75 5.5L8.25 11L13.75 16.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`;var svgNextIcon=`
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.25 16.5L13.75 11L8.25 5.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`;var $prevButton=$(".trip-gallery-slider").find(".swiper-button-prev");if(!$prevButton.find("svg").length){$prevButton.append(svgPrevIcon);}
var $nextButton=$(".trip-gallery-slider").find(".swiper-button-next");if(!$nextButton.find("svg").length){$nextButton.append(svgNextIcon);}
$("body").on("click",".add-to-wishlist, .togo-add-wishlist",function(e){e.preventDefault();var _this=$(this);var trip_id=_this.data("trip-id");$.ajax({url:theme_vars.ajax_url,type:"POST",data:{action:"togo_add_to_wishlist",trip_id:trip_id,nonce:theme_vars.togo_add_to_wishlist_nonce,},beforeSend:function(){_this.addClass("loading");_this.removeClass("added");},success:function(response){_this.removeClass("loading");_this.closest(".trip-wishlist").find(".togo-tooltip-content p").text(response.message);if(response.success==true&&response.data.add==true){_this.addClass("added");}},});});$("body").on("click",".show-map",function(e){e.preventDefault();var _this=$(this);var trip_id=_this.data("trip-id");$.ajax({url:theme_vars.ajax_url,type:"POST",data:{action:"togo_get_itinerary",trip_id:trip_id,security:theme_vars.get_itinerary_nonce,},beforeSend:function(){$(".itinerary-popup").first().html("");_this.find(".togo-svg-icon").addClass("loading");},success:function(response){$(".itinerary-popup").first().html(response.data.html);TOGO_FRAMEWORK.load_element.tour_maps_intinerary();_this.find(".togo-svg-icon").removeClass("loading");},});});},trip_map:function(){$("body").on("click",".view-full-map",function(e){e.preventDefault();$(this).closest(".with-maps").toggleClass("full-maps");});},updateMapMarkers:function(){if(typeof google==="undefined"||!window.togoMap){return;}
var visibleTripIds=[];$(".trip-list .type-trip").each(function(){var tripId=$(this).data("trip-id");if(tripId){visibleTripIds.push(tripId.toString());}});var mapElement=document.getElementById("togo-map");if(!mapElement)return;var originalMarkerData=JSON.parse(mapElement.getAttribute("data-marker")||"[]");var visibleMarkers=[];originalMarkerData.forEach(function(marker){if(marker.trip_id&&visibleTripIds.includes(marker.trip_id.toString())){visibleMarkers.push(marker);}});if(window.togoMapMarkers&&window.togoMapPopups){window.togoMapMarkers.forEach(function(marker){if(marker&&marker.setMap){marker.setMap(null);}});window.togoMapMarkers=[];window.togoMapPopups=[];if(visibleMarkers.length>0){TOGO_FRAMEWORK.load_element.createMapMarkers(visibleMarkers);var bounds=new google.maps.LatLngBounds();visibleMarkers.forEach(function(marker){bounds.extend(new google.maps.LatLng(marker.lat,marker.lng));});window.togoMap.fitBounds(bounds);}else{window.currentMarkerData=[];}}},updateMapMarkersFromCurrentPage:function(){if(typeof google==="undefined"||!window.togoMap){return;}
var currentTripIds=[];$(".trip-list .type-trip").each(function(){var tripId=$(this).data("trip-id");if(tripId){currentTripIds.push(tripId.toString());}});var currentMarkerData=window.currentMarkerData||[];var pageMarkers=[];currentMarkerData.forEach(function(marker){if(marker.trip_id&&currentTripIds.includes(marker.trip_id.toString())){pageMarkers.push(marker);}});if(window.togoMapMarkers&&window.togoMapPopups){window.togoMapMarkers.forEach(function(marker){if(marker&&marker.setMap){marker.setMap(null);}});window.togoMapMarkers=[];window.togoMapPopups=[];if(pageMarkers.length>0){TOGO_FRAMEWORK.load_element.createMapMarkers(pageMarkers);var bounds=new google.maps.LatLngBounds();pageMarkers.forEach(function(marker){bounds.extend(new google.maps.LatLng(marker.lat,marker.lng));});window.togoMap.fitBounds(bounds);}else{window.currentMarkerData=[];}}},createMapMarkers:function(markerData){if(!window.togoMap||!markerData.length)return;window.togoMapMarkers=[];window.togoMapPopups=[];window.currentMarkerData=markerData;markerData.forEach(function(marker,index){var CustomMarker=function(position,map,title){this.position=position;this.map=map;var div=document.createElement("div");div.className="custom-marker";div.textContent=(index+1).toString();var popup=document.createElement("div");popup.className="marker-popup";popup.innerHTML=title;this.div=div;this.popup=popup;this.setMap(map);};CustomMarker.prototype=new google.maps.OverlayView();CustomMarker.prototype.onAdd=function(){var panes=this.getPanes();panes.overlayMouseTarget.appendChild(this.div);panes.overlayMouseTarget.appendChild(this.popup);};CustomMarker.prototype.draw=function(){var point=this.getProjection().fromLatLngToDivPixel(this.position);if(point){this.div.style.left=point.x+"px";this.div.style.top=point.y+"px";var pointHeight=this.div.offsetHeight;var pointHeightRequired=pointHeight*2;var pointHeightIndex=pointHeight*(index+1);var popupWidth=this.popup.offsetWidth;var popupHeight=this.popup.offsetHeight;this.popup.style.left=point.x-popupWidth/2+"px";this.popup.style.top=point.y-
popupHeight-
pointHeightRequired+
pointHeightIndex+"px";}};CustomMarker.prototype.onRemove=function(){if(this.div){this.div.parentNode.removeChild(this.div);this.div=null;}
if(this.popup){this.popup.parentNode.removeChild(this.popup);this.popup=null;}};var customMarker=new CustomMarker(new google.maps.LatLng(marker.lat,marker.lng),window.togoMap,marker.title);window.togoMapMarkers.push(customMarker);window.togoMapPopups.push(customMarker.popup);customMarker.div.addEventListener("click",function(){window.togoMapPopups.forEach(function(popup){if(popup)popup.style.display="none";});window.togoMapMarkers.forEach(function(m){if(m&&m.div&&m.div.classList){m.div.classList.remove("clicked");}});window.togoMap.panTo(new google.maps.LatLng(marker.lat,marker.lng));if(customMarker.popup)customMarker.popup.style.display="block";if(customMarker.div&&customMarker.div.classList){customMarker.div.classList.add("clicked");}});});},calendar:function(){$('.trip-search-form input[name="dates"]').on("focus",function(){$(this).closest(".trip-search-form").find(".calendar-wrapper.full-date").fadeIn(0);$(this).closest(".trip-search-form").find(".field-location .field-location__result").fadeOut(0);});$(document).on("click",function(event){if(!$(event.target).closest(".field-dates").length){$(".trip-search-form .calendar-wrapper.full-date").fadeOut(0);}
if(!$(event.target).closest(".field-date-default").length){$(".trip-search-form .field-date-default .calendar-wrapper:not(.full-date)").fadeOut(0);}
if(!$(event.target).closest(".field-location").length){$(".trip-search-form .field-location .field-location__result").fadeOut(0);}});$(".calendar-close").on("click",function(event){$(".calendar-wrapper").fadeOut(0);});let currentDate=new Date();currentDate.setHours(0,0,0,0);let displayDate=new Date(currentDate.getFullYear(),currentDate.getMonth(),1);let pricingData=[];let monthNames=["January","February","March","April","May","June","July","August","September","October","November","December",];if($(".calendar-wrapper.full-date").length>0){pricingData=JSON.parse($(".calendar-wrapper.full-date").attr("data-dates")||"[]");}
if($(".calendar-wrapper.full-date").attr("data-months-name")){monthNames=JSON.parse($(".calendar-wrapper.full-date").attr("data-months-name"));}
let startDate=null;let endDate=null;function renderCalendar(date,calendarId,monthYearId){const month=date.getMonth();const year=date.getFullYear();const today=new Date();today.setHours(0,0,0,0);$(`.calendar-wrapper.full-date #${monthYearId}`).text(`${monthNames[month]} ${year}`);$(`.calendar-wrapper.full-date #${calendarId}`).empty();const firstDay=new Date(year,month,1).getDay();const daysInMonth=new Date(year,month+1,0).getDate();for(let i=0;i<(firstDay||7)-1;i++){$(`.calendar-wrapper.full-date #${calendarId}`).append("<div></div>");}
for(let day=1;day<=daysInMonth;day++){const dayDate=new Date(year,month,day);const formattedDate=`${dayDate.getFullYear()}-${String(
dayDate.getMonth() + 1
).padStart(2, "0")}-${String(dayDate.getDate()).padStart(2, "0")}`;const dateDiv=$(`<div class="date" data-date="${formattedDate}">
<span>${day}</span>
</div>`);if(day===currentDate.getDate()&&month===currentDate.getMonth()&&year===currentDate.getFullYear()){dateDiv.addClass("today");}
if(startDate&&endDate&&new Date(formattedDate)>=new Date(startDate)&&new Date(formattedDate)<=new Date(endDate)){dateDiv.addClass("in-range");if(formattedDate===startDate){dateDiv.addClass("first-range");}
if(formattedDate===endDate){dateDiv.addClass("last-range");}}else if(formattedDate===startDate||formattedDate===endDate){dateDiv.addClass("is-selected");}
if(dayDate<=today){dateDiv.addClass("disabled").attr("aria-disabled","true");}
$(`.calendar-wrapper.full-date #${calendarId}`).append(dateDiv);}}
function updateCalendars(){renderCalendar(displayDate,"calendar-dates-prev","month-year-prev");if(window.innerWidth>=992){const nextMonthDate=new Date(displayDate.getFullYear(),displayDate.getMonth()+1,1);renderCalendar(nextMonthDate,"calendar-dates-next","month-year-next");$("#calendar-next").show();}else{$("#calendar-next").hide();}}
function updateInputField(){const inputField=$(".trip-search-form .field-dates__input input[name='dates']");if(startDate&&endDate){inputField.val(`${startDate}, ${endDate}`);}else if(startDate){inputField.val(startDate);}else{inputField.val("");}}
$(".calendar-wrapper.full-date .prev-month").on("click",function(e){e.preventDefault();displayDate.setMonth(displayDate.getMonth()-1);updateCalendars();});$(".calendar-wrapper.full-date .next-month").on("click",function(e){e.preventDefault();displayDate.setMonth(displayDate.getMonth()+1);updateCalendars();});$("body").on("click",".calendar-check",function(e){e.preventDefault();$(this).closest(".calendar-wrapper").fadeOut(0);});$("body").on("click",".calendar-wrapper.full-date .calendar .date:not(.disabled)",function(e){e.preventDefault();e.stopPropagation();const selectedDate=$(this).data("date");if(!startDate||(startDate&&endDate)){startDate=selectedDate;endDate=null;}else if(!endDate){if(new Date(selectedDate)>=new Date(startDate)){endDate=selectedDate;}else{startDate=selectedDate;endDate=null;}}
$(".field-dates__remove").css("display","flex");updateCalendars();updateInputField();});$(document).ready(function(){updateCalendars();});function openSingleDateCalendar($input){$input.closest(".trip-search-form").find(".field-date-default .calendar-wrapper:not(.full-date)").fadeIn(0);$input.closest(".trip-search-form").find(".field-location .field-location__result").fadeOut(0);}
$('.trip-search-form input[name="date_default"]').on("focus",function(){$(this).each(function(){openSingleDateCalendar($(this));});});$('.trip-search-form input[name="date_default"]').on("click",function(e){openSingleDateCalendar($(this));});$(".trip-search-form .field-date-default__input").on("click",function(e){const $input=$(this).find('input[name="date_default"]');if($input.length){$input.trigger("focus");openSingleDateCalendar($input);}});function renderSingleCalendar($wrapper,date){const month=date.getMonth();const year=date.getFullYear();const today=new Date();today.setHours(0,0,0,0);let localMonthNames=monthNames;if($wrapper.attr("data-months-name")){try{localMonthNames=JSON.parse($wrapper.attr("data-months-name"));}catch(e){}}
$wrapper.find("#calendar-next").hide();$wrapper.find("#calendar-prev .next-month").css("display","inline-flex");$wrapper.find("#month-year-prev").text(`${localMonthNames[month]} ${year}`);const $dates=$wrapper.find("#calendar-dates-prev");$dates.empty();const firstDay=new Date(year,month,1).getDay();const daysInMonth=new Date(year,month+1,0).getDate();for(let i=0;i<(firstDay||7)-1;i++){$dates.append("<div></div>");}
for(let day=1;day<=daysInMonth;day++){const dayDate=new Date(year,month,day);const formattedDate=`${dayDate.getFullYear()}-${String(
dayDate.getMonth() + 1
).padStart(2, "0")}-${String(dayDate.getDate()).padStart(2, "0")}`;const $dateDiv=$(`<div class="date" data-date="${formattedDate}"><span>${day}</span></div>`);if(day===currentDate.getDate()&&month===currentDate.getMonth()&&year===currentDate.getFullYear()){$dateDiv.addClass("today");}
if(dayDate<=today){$dateDiv.addClass("disabled").attr("aria-disabled","true");}
$dates.append($dateDiv);}}
$(".field-date-default .calendar-wrapper:not(.full-date)").each(function(){const $wrapper=$(this);const initDate=new Date(currentDate.getFullYear(),currentDate.getMonth(),1);$wrapper.data("singleDisplayDate",initDate);renderSingleCalendar($wrapper,initDate);});$("body").on("click",".field-date-default .calendar-wrapper .prev-month",function(e){e.preventDefault();const $wrapper=$(this).closest(".calendar-wrapper");if($wrapper.hasClass("full-date"))return;let date=$wrapper.data("singleDisplayDate")||new Date(currentDate.getFullYear(),currentDate.getMonth(),1);date=new Date(date.getFullYear(),date.getMonth()-1,1);$wrapper.data("singleDisplayDate",date);renderSingleCalendar($wrapper,date);});$("body").on("click",".field-date-default .calendar-wrapper .next-month",function(e){e.preventDefault();const $wrapper=$(this).closest(".calendar-wrapper");if($wrapper.hasClass("full-date"))return;let date=$wrapper.data("singleDisplayDate")||new Date(currentDate.getFullYear(),currentDate.getMonth(),1);date=new Date(date.getFullYear(),date.getMonth()+1,1);$wrapper.data("singleDisplayDate",date);renderSingleCalendar($wrapper,date);});$("body").on("click",".calendar-wrapper:not(.full-date) .calendar .date:not(.disabled)",function(){const selectedDate=$(this).data("date");const $form=$(this).closest(".trip-search-form");$form.find('input[name="date_default"]').val(selectedDate);$form.find(".field-date-default__remove, .field-dates__remove").css("display","flex");$(this).closest(".calendar-wrapper").fadeOut(0);});$("body").on("click",".field-date-default__remove",function(e){e.preventDefault();$(this).closest(".trip-search-form").find('input[name="date_default"]').val("");$(this).css("display","none");});$("body").on("click",".field-date-default .field-dates__remove",function(e){e.preventDefault();$(this).closest(".trip-search-form").find('input[name="date_default"]').val("");$(this).css("display","none");});},my_account:function(){$(".dashboard-nav-close").on("click",function(e){e.preventDefault();$(this).closest("body").toggleClass("hide-dashboard");});},validate_form:function(){$("#togo-login").validate({rules:{email:{required:true,},password:{required:true,minlength:5,maxlength:30,},},submitHandler:function(form){$.ajax({url:ajax_url,type:"POST",cache:false,dataType:"json",data:{email:$("#ip_email").val(),password:$("#ip_password").val(),action:"get_login_user",security:theme_vars.login_nonce,},beforeSend:function(){$(".form-account p.msg").removeClass("text-error text-success text-warning");$(".form-account p.msg").text(theme_vars.send_user_info);$("#togo-login p.msg").show();$(".form-account .loading-effect").fadeIn();},success:function(data){$(".form-account p.msg").text(data.messages);if(data.success!=true){$("#togo-login p.msg").addClass(data.class);}
$(".form-account .loading-effect").fadeOut();if(data.redirect!=""){window.location.href=data.redirect;}},});},});$("#togo-register").validate({rules:{reg_firstname:{required:true,},reg_lastname:{required:true,},reg_email:{required:true,email:true,},reg_password:{required:true,minlength:5,maxlength:20,},accept_account:{required:true,},},submitHandler:function(form){$.ajax({url:ajax_url,type:"POST",cache:false,dataType:"json",data:{account_type:$('input[name="account_type"]:checked').val(),firstname:$("#ip_reg_firstname").val(),lastname:$("#ip_reg_lastname").val(),email:$("#ip_reg_email").val(),password:$("#ip_reg_password").val(),action:"get_register_user",security:theme_vars.register_nonce,},beforeSend:function(){$(".form-account p.msg").removeClass("text-error text-success text-warning");$(".form-account p.msg").text(theme_vars.send_user_info);$("#togo-register p.msg").show();$(".form-account .loading-effect").fadeIn();},success:function(data){$(".form-account p.msg").text(data.messages);if(data.success!=true){$("#togo-register p.msg").addClass(data.class);}else{if(data.redirect!=""){window.location.href=data.redirect;}}
$(".form-account .loading-effect").fadeOut();},});},});jQuery.extend(jQuery.validator.messages,{required:"This field is required",remote:"Please fix this field",email:"A valid email address is required",url:"Please enter a valid URL",date:"Please enter a valid date",dateISO:"Please enter a valid date (ISO)",number:"Please enter a valid number.",digits:"Please enter only digits",creditcard:"Please enter a valid credit card number",equalTo:"Please enter the same value again",accept:"Please enter a value with a valid extension",maxlength:jQuery.validator.format("Please enter no more than {0} characters"),minlength:jQuery.validator.format("Please enter at least {0} characters"),rangelength:jQuery.validator.format("Please enter a value between {0} and {1} characters long"),range:jQuery.validator.format("Please enter a value between {0} and {1}"),max:jQuery.validator.format("Please enter a value less than or equal to {0}"),min:jQuery.validator.format("Please enter a value greater than or equal to {0}"),});},forget_password:function($this){$("#togo_forgetpass").on("click",function(e){e.preventDefault();var $form=$(this).parents("form");$.ajax({type:"post",url:ajax_url,dataType:"json",data:$form.serialize(),beforeSend:function(){$(".forgot-form p.msg").removeClass("text-error text-success text-warning");$(".forgot-form p.msg").text(theme_vars.forget_password);$(".forgot-form p.msg").show();$(".forgot-form .loading-effect").fadeIn();},success:function(data){$(".forgot-form p.msg").text(data.message);$(".forgot-form p.msg").addClass(data.class);$(".forgot-form .loading-effect").fadeOut();},});});},};TOGO_FRAMEWORK.onReady={init:function(){TOGO_FRAMEWORK.ready_element.init();},};TOGO_FRAMEWORK.onLoad={init:function(){TOGO_FRAMEWORK.load_element.init();},};TOGO_FRAMEWORK.onScroll={init:function(){},};TOGO_FRAMEWORK.onResize={init:function(){TOGO_FRAMEWORK.onResize.trip_card();},trip_card:function(){$(".trip-list.togo-row .trip-inner").each(function(){var width=$(this).width();$(this).find(".trip-gallery").css("width",width+"px");});if($(window).width()<=767){$(".trip-list .type-trip-list .trip-inner").each(function(){var width=$(this).width();$(this).find(".trip-gallery").css("width",width+"px");});}},};TOGO_FRAMEWORK.onMouseMove={init:function(e){},};$(document).on("ready",TOGO_FRAMEWORK.onReady.init);$(window).on("scroll",TOGO_FRAMEWORK.onScroll.init);$(window).on("resize",TOGO_FRAMEWORK.onResize.init);$(window).on("load",TOGO_FRAMEWORK.onLoad.init);$(window).on("mousemove",TOGO_FRAMEWORK.onMouseMove.init);})(jQuery);