var wtarget = window.location.hash; // delete hash so the page won't scroll to it window.location.hash = ""; 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)); } startSections = ['','#uslugi','#personel','#ogiery-2','#aktualnosci']; currSect = 1; totSect = 5; $(document).keyup(function(e) { if (e.keyCode == 27) { $('.personel-modal, .personel-tab.on').removeClass("on"); $('personel-modal a.close').unbind("click"); $('.uslugi-modal, .uslugi-tab.on').removeClass("on"); $('uslugi-modal a.close').unbind("click"); $('body').removeClass("blocked"); } }); $(function () { $('.next-scroll').click(function(e){ e.preventDefault(); if ($(this).hasClass("turned") ) { currSect = 0; $('body,html').stop().animate({ scrollTop: 0 },1000); $(this).removeClass("turned"); } else { //$('header a[href="#uslugi"]').click(); $('header a[href="' + startSections[currSect] + '"').click(); currSect++; if(currSect == totSect) { $(this).addClass("turned"); } } }); $('html, body').animate({scrollTop:0}); if( wtarget != '' ) { var ob = $( wtarget ); var offset = ob.offset().top - $('header').outerHeight() + 25; $('body, html').stop().animate({ scrollTop: offset }, 1000); } $('a[href*="#"]:not(.close)').click(function(e) { var url = top.location.href.split("#"); //if( !$(this).hasClass("close") ) { console.log("K"); e.preventDefault(); console.log( url[0] ); if( url[0] == __URL__) { var ob = $( $(this).attr("href") ); var offset = ob.offset().top - $('header').outerHeight() + 25; console.log(offset); $('body, html').stop().animate({ scrollTop: offset }, 1000); } else { // Redir to home page top.location.href = __URL__ + $(this).attr('href'); } //} }); $('.peoples-list .item').click(function(e){ e.preventDefault(); $('body').addClass("blocked"); $('.personel-' + $(this).data("id")).addClass("on"); $('.personel-modal').addClass("on"); $('.personel-modal a.close').click(function(ev){ ev.preventDefault(); $('.personel-modal, .personel-tab.on').removeClass("on"); $('personel-modal a.close').unbind("click"); $('body').removeClass("blocked"); }); }); $('.service-list .item, .uslugi-item').click(function(e){ if( $(this).attr("href") == "javascript:void(0);" ) { e.preventDefault(); //alert("klik " + $(this).data("id")); $('body').addClass("blocked"); $('.uslugi-tab').removeClass("on"); $('.uslugi-' + $(this).data("id")).addClass("on"); $('.uslugi-modal').addClass("on"); $('.uslugi-modal a.close').click(function(ev){ ev.preventDefault(); $('.uslugi-modal, .uslugi-tab.on').removeClass("on"); $('uslugi-modal a.close').unbind("click"); $('body').removeClass("blocked"); }); } }); $('.gallery').Chocolat({ imageSize : 'contain', fullScreen: false, imageSelector: '.fancybox', loop: true }) $('.product-images').Chocolat({ imageSize : 'contain', fullScreen: false, imageSelector: '.choco', loop: true }) $('.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').on('submit', function(evt){ evt.preventDefault(); var k = [ 'name', '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] +'"]'); if ( obj.val().length <= 1 ){ good = false; obj.addClass('error'); } } 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(); } }); $('#modalInForm').on('submit', function(evt){ evt.preventDefault(); good = true; 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(); } }); $('.checkPass').click(function(e){ var pass_ = $('input[name=passDownload]').val(); $.post( __URL__ + 'ajax/responses.php?what=files', { password: pass_ }, function(r){ if ( r != 'error') { $('.logFiles').remove(); $('.text-password').html('