function checkScroll() {
var _scroll = $(window).scrollTop();
//var _wheight = $(window).height();
//var _menuheight = _wheight - $('header.header').outerHeight();
var _menuheight = 50;
if( $('body.page-start').length == 1 ) {
if( _scroll > _menuheight && $(window).width() > 767 ){
$('header.header').addClass("moved");
} else {
$('header.header').removeClass("moved");
}
} else {
}
var ob = '.content-wrap';
$('body').find(ob).each(function(){
if( isOnScreen( $(this) ) ) {
$(this).addClass("shown");
}
});
var ob = '.tiles-wrap';
$('body').find(ob).each(function(){
if( isOnScreen( $(this) ) ) {
$(this).addClass("shown");
}
});
}
function isOnScreen(elem)
{
var $elem = $(elem);
var $window = $(window);
var docViewTop = $window.scrollTop();
var docViewBottom = docViewTop + $window.height();
var elemTop = $elem.offset().top;
var elemBottom = elemTop + $elem.height();
//return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
return (elemTop <= docViewTop + $(window).height() * .6);
}
function recaptchaCallback() {
$('.g-recaptcha').addClass('confirmed');
}
function lightboxTitle( src ) {
newSrc = src;
console.log("Szukam: " + newSrc );
name = '';
$('.strip').each(function(){
if( $(this).attr("href") == newSrc ) {
name = $(this).attr("title");
console.log("Found");
return 0;
}
});
console.log("Name: " + name);
return name;
}
function lightboxShow( ) {
newSrc = $('.lightmybox-item-current .lightmybox-image img').attr("src");
name = lightboxTitle( newSrc );
if( !$('#lightdesc').length ) {
$('body').append('
');
}
$('#lightdesc').show();
$('#lightdesc .text').html( name );
}
$(function () {
// Lightbox widget
$(".strip").lightmybox({
callbacks: {
afterShow: function(e) {
lightboxShow();
},
afterClose: function() {
//lightboxShow();
$('#lightdesc').remove();
},
afterNext: function() {
lightboxShow();
},
afterPrevious: function() {
lightboxShow();
}
}
});
$('.tabs > ul li a').click(function(e){
e.preventDefault();
$('.tabs > ul li a').removeClass("active");
$(this).addClass("active");
_trg = $(this).attr("href");
$(".tab").removeClass("active");
$(_trg).addClass("active");
});
$(".acc-title").click(function(e){
$(this).parent().toggleClass("active");
});
$('#contactFormSend').one('submit', function(evt){
evt.preventDefault();
var k = [ 'mail','question' ],
good = true;
$(this).find('[name]').removeClass('error');
$(this).find('p.ajaxInfo').hide();
if ( /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test( $(this).find('[name="mail"]').val() ) == false ){
$(this).find('[name="mail"]').addClass('error');
good = false;
}
for ( var i = 0; i < k.length; i++ ){
var obj = $(this).find('[name="'+ k[i] +'"]');
console.log(obj.val());
if ( obj.val().length <= 1 ){
good = false;
obj.parents('.form__item').addClass('error');
obj.parents('#rodoagree').addClass('error');
}
}
if ( $('.g-recaptcha').hasClass('confirmed') ) {
$('.recaptcha_error').hide(300).addClass('hide');
good = true;
} else {
$('.g-recaptcha').addClass('error');
$('.recaptcha_error').show(300).removeClass('hide');
good = false;
}
if ( good ){
$.post( $(this).attr('action'), $(this).serialize(), (function(response){
if (response.indexOf('false') === -1) {
$(this).find('input, textarea').val('');
$(this).find('p.ajaxInfo.ok').show();
} else {
$(this).find('p.ajaxInfo.error_send').show();
}
}).bind(this));
} else {
$(this).find('p.ajaxInfo.error').show();
}
console.log(good);
});
var startSlider = $('.start-slider').owlCarousel({
items: 1,
autoplayHoverPause: false,
autoplay: true,
autoplayTimeout: 4500,
smartSpeed: 2000,
drag: false,
mouseDrag: false,
loop: true,
nav: false,
dots: true,
navText: ['','']
}).addClass("owl-carousel");
var carouselGal = $('.carousel-gallery').owlCarousel({
items: 3,
responsive: {
0: {
items: 1
},
800: {
items: 2
},
1200: {
items: 4
},
1440: {
items: 5
}
},
autoplayHoverPause: true,
autoplay: true,
autoplayTimeout: 3500,
smartSpeed: 1000,
animateIn: "fadeIn",
animateOut: "fadeOut",
drag: false,
mouseDrag: false,
center: true,
loop: true,
nav: true,
dots: true,
navText: ['','']
}).addClass("owl-carousel");
var singleCarousel = $('.carousel').owlCarousel({
items: 1,
autoplayHoverPause: false,
autoplay: true,
autoplayTimeout: 3500,
drag: false,
mouseDrag: false,
loop: true,
nav: true,
dots: true,
navText: ['','']
}).addClass("owl-carousel");
$('.slider-nav .nav-right').click(function() {
carouselGal.trigger('next.owl.carousel');
})
$('.slider-nav .nav-left').click(function() {
carouselGal.trigger('prev.owl.carousel');
})
$('.menu-call').click(function(e){
e.preventDefault();
$('.side-nav').toggleClass("on");
setTimeout(function(){
$('.side-nav').click(function(e){
e.stopPropagation();
});
$('body').click(function(ev){
ev.preventDefault();
$('.side-nav').removeClass("on");
$(this).unbind("click");
});
}, 100);
});
$('.form-mask .close-btn').click(function(e){
e.preventDefault();
$('.form-mask').removeClass("on");
});
$('.reservation').click(function(e){
e.preventDefault();
$('.form-mask').addClass("on");
});
$('.reservation form').submit(function(ev){
ev.preventDefault();
$('.form-mask').removeClass("on");
});
$('.side-nav a.close-btn').click(function(e){
e.preventDefault();
$('.side-nav').removeClass("on");
});
$(window).scroll(function(e){
checkScroll();
});
});
// init
checkScroll();