var _TH_widgetGallery_loading = false;
var ratesWrapper = $("#TH_gallery_1bda17688a40fd576db2085292a534a5");
function _TH_widgetGallery_loadScript(aScript, aSync, aCallback) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = aSync;
script.src = aScript;
if (typeof aCallback !== 'undefined') {
script.onload = aCallback;
}
document.body.appendChild(script);
}
if (!window.jQuery) {
_TH_widgetGallery_loadScript("https://partner.tophotels.ru/js/lib/jquery.js", false, _TH_widgetGallery_init);
} else {
_TH_widgetGallery_init();
}
_TH_widgetGallery_loadScript("https://partner.tophotels.ru/js/lib/slick.min.js", true, _TH_widgetGallery_initGallery);
function _TH_widgetGallery_markCurrent(i) {
$('.hotel-profile-photos-desc-i[data-slick-index="'+i+'"]', ratesWrapper).addClass('slick-current').siblings().removeClass('slick-current');
}
function _TH_widgetGallery_initScrollbar() {
if ($('.filter-form-field-dd', ratesWrapper).not('.full-size').length > 0) {
$('.filter-form-field-dd', ratesWrapper).not('.full-size').mCustomScrollbar({
mouseWheel:{scrollAmount: 50},
advanced:{
updateOnContentResize: true
}
});
}
}
function _TH_widgetGallery_initGallery() {
$('.slider-for', ratesWrapper).slick({
dots: false,
lazyLoad: 'ondemand',
infinite: false,
slidesToShow: 1,
slidesToScroll: 1,
asNavFor: '.slider-nav',
focusOnSelect: true
});
$('.slider-nav', ratesWrapper).slick({
dots: false,
lazyLoad: 'ondemand',
infinite: false,
slidesToShow: 5,
slidesToScroll: 1,
slide: 'a',
asNavFor: '.slider-for',
focusOnSelect: true
});
$('.slider-nav', ratesWrapper).on('beforeChange', function(e, slick, currentSlide, nextSlide){
_TH_widgetGallery_markCurrent(nextSlide);
});
$('.hotel-profile-photos-desc-i', ratesWrapper).on('click', function(e){
_TH_widgetGallery_markCurrent($(this).data('slick-index'));
});
$('.slider-for', ratesWrapper).on('beforeChange', function(e, slick, currentSlide, nextSlide){
_TH_widgetGallery_markCurrent(nextSlide);
});
}
function _TH_widgetGallery_loadCss(cssUrl) {
var link = document.createElement("link");
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
link.setAttribute("href", cssUrl);
document.getElementsByTagName("head")[0].appendChild(link);
}
function _TH_widgetGallery_toggleFilter(el) {
var $this = $(el);
$this.toggleClass('ls-chooser-dropdown-button_act');
$this.next().slideToggle();
return false;
}
function _TH_widgetGallery_loadGallery(aMobileForm) {
if (_TH_widgetGallery_loading) {
return;
}
_TH_widgetGallery_loading = true;
$('.hotel-profile-body', ratesWrapper).append('
');
var loader_ml = 0, loadet_mt = 0;
if ($('.hotel-profile-content-cell-filter:visible', ratesWrapper).length) {
loader_ml += -parseInt(($('.hotel-profile-content-cell-filter:visible', ratesWrapper).width()||0)/2);
} else {
loader_ml = 0;
loadet_mt = 35;
}
if ($('.slider-nav:visible', ratesWrapper).length) {
loadet_mt += -parseInt(($('.slider-nav:visible', ratesWrapper).height()||0)/2);
loadet_mt += -$('.hotel-profile-content-cell-filter-mobile:visible', ratesWrapper).height()||0;
}
$('.gallery_loading .loading').css({
"margin-left": loader_ml + 'px',
"margin-top": loadet_mt + 'px'
}).show();
var url = "https://partner.tophotels.ru/widgetsHotel/galleryData?uid=1bda17688a40fd576db2085292a534a5&alId=52089&sec=1&";
if ((typeof aMobileForm !== 'undefined') && aMobileForm) {
url = url + $('.filter-form-mobile', ratesWrapper).serialize();
} else {
url = url + $('.filter-form-desktop', ratesWrapper).serialize();
}
_TH_widgetGallery_loadScript(url, true, _TH_widgetGallery_updateGallery);
}
function _TH_widgetGallery_updateGallery() {
_TH_widgetGallery_initGallery();
_TH_widgetGallery_loading = false;
$('.hotel-profile-body .gallery_loading', ratesWrapper).remove();
}
function _TH_widgetGallery_setVal(elId, val) {
$('#' + elId, ratesWrapper).val(val);
_TH_widgetGallery_loadGallery(true);
}
function _TH_widgetGallery_init() {
ratesWrapper.delegate('.ls-chooser-checkbox-group-photo-type .ls-chooser-radio', 'change', function(){
if ($('.ls-chooser-checkbox-group-photo-type .ls-chooser-radio:checked', ratesWrapper).length) {
if ($('#type_0', ratesWrapper).prop('checked')) {
$('#type_0', ratesWrapper).removeAttr('checked');
}
}
_TH_widgetGallery_loadGallery();
}).delegate('.ls-chooser-checkbox-group-user-type .ls-chooser-radio', 'change', function(){
if ($('.ls-chooser-checkbox-group-user-type .ls-chooser-radio:checked', ratesWrapper).length) {
if ($('#user_type_0', ratesWrapper).prop('checked')) {
$('#user_type_0', ratesWrapper).removeAttr('checked');
}
}
_TH_widgetGallery_loadGallery();
}).delegate('#type_0', 'click', function(){
$('.ls-chooser-checkbox-group-photo-type .ls-chooser-radio', ratesWrapper).removeAttr('checked');
_TH_widgetGallery_loadGallery();
}).delegate('#user_type_0', 'click', function(){
$('.ls-chooser-checkbox-group-user-type .ls-chooser-radio', ratesWrapper).removeAttr('checked');
_TH_widgetGallery_loadGallery();
}).delegate('.filter-form-mobile-btn', 'click', function(){
_TH_widgetGallery_loadGallery(true);
}).delegate('.ls-chooser-select-reset-all', 'click', function(){
$('#type_0, #user_type_0', ratesWrapper).attr('checked', 'checked');
$('.ls-chooser-checkbox-group-photo-type .ls-chooser-radio', ratesWrapper).removeAttr('checked');
$('.ls-chooser-checkbox-group-user-type .ls-chooser-radio', ratesWrapper).removeAttr('checked');
_TH_widgetGallery_loadGallery();
});
}
(function(){
var html = [];
_TH_widgetGallery_loadCss("https://partner.tophotels.ru/css/partners/fonts.css");
_TH_widgetGallery_loadCss("https://partner.tophotels.ru/css/partners/widgetsHotelGallery.css");
_TH_widgetGallery_loadCss("https://partner.tophotels.ru/css/partners/filter-form.mCustomScrollbar.css");
_TH_widgetGallery_loadScript("https://partner.tophotels.ru/js/lib/jquery.mCustomScrollbar.min.js", true, _TH_widgetGallery_initScrollbar);
_TH_widgetGallery_loadScript("https://partner.tophotels.ru/js/partners/gallery.js", true);
html.push(
''
);
ratesWrapper.html(html.join(''));
delete html;
})();