(function($){
"use strict";
var theLanguage=$('html').attr('lang');
/* $(document).ready(function(){
$('.card-exp').hover(function(){
$(this).addClass("active").siblings().removeClass("active");
});
});*/
$('.booking__check').on('click', function(){
let [tfrhn_code, tfvnb_code, tfvqn_code, tfsll_code, tfhev_code, room, adults, children, lang, currency]=['12DB21', 'D50927', '23DB23', '5G3892', 'EWCFA7', '1' , '2', '0', 'en', 'USD'];
if(theLanguage=='vi'){ currency='VND'; lang='vi'; }
let destination=$('#select-destinations').find(":selected").val();
let dest_code='';
if(destination!=null){
switch (destination){
case 'tfr_hanoi':
dest_code=tfrhn_code;
break;
case 'tfs_lilas':
dest_code=tfsll_code;
break;
case 'tfv_ninhbinh':
dest_code=tfvnb_code;
break;
case 'tfv_quangnam':
dest_code=tfvqn_code;
break;
case 'tfh_evara':
dest_code=tfhev_code;
break;
default:
break;
}}
if(dest_code==''){ validateInput('code');return false;}
let checkin=$("input[name='check_in']").val();
if(checkin==''){ validateInput('checkin'); return false;}
let checkout=$("input[name='check_out']").val();
if(checkout==''){ validateInput('checkout');return false;}
let build_url='https://booking.thefive.vn/hotel/BeDetailHotel?hotel_code=' + dest_code + '&check_in=' + checkin + '&check_out=' + checkout + '&num_of_rooms=' + room + '&num_of_adults=' + adults + '&num_of_children=' + children + '&lang=' + lang + '&currency=' + currency;
window.open(build_url,'_blank');
});
function validateInput(callAlert){
let message_vi='';
let message_en='';
switch (callAlert){
case 'code':
message_vi='Vui lòng lựa chọn địa điểm!';
message_en='Select destination please!';
break;
case 'checkin':
message_vi='Hãy chọn ngày Check-in.';
message_en='Select your check-in date';
break;
case 'checkout':
message_vi='Hãy chọn ngày Check-out.';
message_en='Select your check-out date';
break;
default:
break;
}
if(theLanguage=='vi') alert(message_vi);
if(theLanguage=='en-GB') alert(message_en);
}
var $slider=$('#slider-destinations');
var bgSectionDesti=$('.perfect-destinations').find('.section-bg');
$slider.on('change.flickity', function(event, index){
let item=$(this).find('.is-selected');
let bgitem=item.attr('data-background');
setTimeout(()=> {
$(bgSectionDesti).css('background-image', 'url(' + bgitem + ')');
}, 300);
});
})(jQuery);