function tab(){var e=root.find("tab","control");if(e){var t=root.find("tab","item");if(t){for(var a=0;a<t.length;a++){var n=document.createElement("div"),o=document.createElement("a");o.innerHTML=t[a].attribute.caption,n.appendChild(o),e[0].node.appendChild(n),setEvent=function(e,t,a){o.onclick=function(){for(var n=0;n<e[0].node.children.length;n++)e[0].node.children[n].children[0].className=n===a?"selected":"";for(var o=0;o<t.length;o++)t[o].node.style.display=o===a?"block":"none"}},setEvent(e,t,a)}e[0].node.children[0].children[0].className="selected",t[0].node.style.display="block"}}}function insereClickbus(){var e=document,t="script",a="widget-clickbus";e.getElementById(a+t)&&e.getElementById(a+t).parentNode.removeChild(e.getElementById(a+t)),e.getElementById(a+"-css")&&e.getElementById(a+"-css").parentNode.removeChild(e.getElementById(a+"-css")),e.getElementById(a+"-css")&&e.getElementById(a+"-css").parentNode.removeChild(e.getElementById(a+"-css")),e.getElementById(a+"-css")&&e.getElementById(a+"-css").parentNode.removeChild(e.getElementById(a+"-css")),e.getElementById(a+"-vendor")&&e.getElementById(a+"-vendor").parentNode.removeChild(e.getElementById(a+"-vendor"));var n=e.createElement(t),o=e.getElementsByTagName(t)[0];return n.id=a+t,n.src="https://s3-sa-east-1.amazonaws.com/static2.clickbus.com.br/widget/global/js/wg-clickbus-requests.js",o.parentNode.insertBefore(n,o),!0}!function(e,t,a,n){serviceFlytour={validaMotor:function(){var t,a,n=e("#flytour_motor").find("select");e.each(n,function(n,o){if(""===(t=e(o)).val())return a=e('[for="'+t.attr("id")+'"]').html().replace(":",""),tsGeral.alerta("aviso","<h1>Aviso:</h1><p>A busca não pode ser realizada sem <b>"+a+"</b>.</p>",!0),!1})},validaIdades:function(){var t=e(".flytour_room");if(spanErro=t.find("span.tip_erro:first"),count=spanErro.length,0===count){var a=e("<span></span>").addClass("tip_erro").html("favor preencher a idade.");t.prepend(a),a.fadeOut(2800,function(){e(this).remove()})}},aplicaLoading:function(t,a){var n=e(t.node),o=n.parent();if(0==o.find("span.carregando").length)switch(a){case"Options":var r=e("<span></span>").addClass("carregando");n.find("option:not(:first-child)").remove().end().find("option:first").html("Carregando...").val(""),o.append(r);break;case"Destaques":r=e("<span></span>").addClass("carregando");n.prepend(r);break;case"Motor":r=e("<div>&nbsp;</div>").addClass("big_loading");e("#fly_motor").prepend(r)}},removeLoading:function(t,a){var n=e(t.node),o=n.parent();switch(a){case"Options":case"Destaques":o.find("span.carregando").length>=1&&(n.find("option:first").html("Selecione"),o.find("span.carregando").fadeOut("fast",function(){e(this).remove()}));break;case"Motor":e("#fly_motor").find("div.big_loading")&&e("div.big_loading").fadeOut("fast",function(){e(this).remove()})}},organizaTexto:function(e,t,a){var n="";switch(t){case"tituloDestaque":e&&(n=(e=e.match(/[ a-zA-ZÁ-ü0-9]+/g)[0].replace(/ $/g,"")).toLowerCase().replace(/^.|\s\S/g,function(e){return e.toUpperCase()}));break;case"fotoDestaque":""==e&&(e="https://resources.tursites.com.br/images/sem_foto.jpg");break;case"titulo":n=e.toLowerCase().replace(/^.|\s\S/g,function(e){return e.toUpperCase()});break;case"permalink":n=e.toLowerCase().replace(/[á|à|â|ã]/gi,"a").replace(/[é|è|ê]/gi,"e").replace(/[é|è|ê]/gi,"i").replace(/[ó|ò|ô|õ]/gi,"o").replace(/[ú|ù|û]/gi,"u").replace(/[ç]/gi,"c").replace(/[ñ]/gi,"n").replace(/[í|ì|ï]/gi,"a").replace(/\W/gi,"_");break;case"valor":n=tsGeral.replaceAll(e,".",",");break;case"meses":var o=e.match(/^[0-9]+\//g)[0],r=parseFloat(e.match(/^[0-9]+/g)[0])-1;n=e.replace(o,["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"][r]+" ");break;case"cortar":n=e.substr(0,a);/^\S/.test(e.substr(a))&&(n=n.replace(/\,\s+\S*$/,"")),n+="..";break;case"texto":default:n=tsGeral.replaceAll(e,"* ","</p><p>")}return n},organizaSaida:function(t){var a,n,o=e(t.node);e.each(o.find("option:not(:first)"),function(t,o){a=e(o),n=a[0].label,n=serviceFlytour.organizaTexto(n,"meses"),a[0].label=n,a.text(n)})},organizaDestaque:function(t){var a=e(t.node),n=a.find(".valor").html(),o=a.find(".titulo").html();t.node.innerHTML=t.node.innerHTML.replace(n,serviceFlytour.organizaTexto(n,"valor")),t.node.innerHTML=t.node.innerHTML.replace(o,serviceFlytour.organizaTexto(o,"tituloDestaque")),t.node.innerHTML=t.node.innerHTML.replace("(em 0x)","")},organizaInfoHotel:function(t){var a,n,o,r=e(t.node),i=r.find(".hotel_interno");e.each(i,function(t,r){a=e(r).find("span.categoria"),n=parseInt(a.html(),10),n++,a.html("");for(var i=1;i<n;i++)a.append('<img src="https://www.resources.tursites.com.br/images/icone_estrela.gif" width="15" height="14">');a=e(r).find("p.descr"),o=a.html(),o=serviceFlytour.organizaTexto(o,"cortar",320),a.html(o)}),e.each(r.find("a.btIcon"),function(t,a){e(a).off().on("click",function(t){t.preventDefault();var a=e(this),n=a.parents(".hotel_interno"),o=a.data("destino"),r=n.find("."+o).clone();r.removeClass("hide"),tsGeral.alerta("livre",r,!0,function(){var t=e("."+o+":visible");t.on("click",function(e){e.stopPropagation()}),t.find("a.close").on("click",function(e){e.preventDefault(),tsGeral.removeAlerta()})})})});var s=e("#saida_src").find("option:selected").text();"Selecione"!==s?e("#saida").datepicker("setDate",s).val(s):e("#saida").val(""),tsGeral.removeAlerta()},eventoPax:function(t){e(t.node).find("a[data-destino]").on("click",function(t){t.preventDefault();var n=e(this),o=n.parents(".acomodacao"),r=n.data("destino"),i=o.find("."+r),s=n.position(),c=parseInt(s.top,10)-i.height()-22;e("."+r);"1"!==i.css("opacity")&&(i.css({"z-index":-100}).stop(!0,!0).animate({opacity:0},1,function(){i.css({"z-index":900,top:c,left:parseInt(s.left,10)}).animate({opacity:1},100)}),i.on("click",function(e){e.stopPropagation()}),e(a).on("click",function(){e("."+r).css({"z-index":-100}).animate({opacity:0},60)}))})}}}(jQuery,window,document);