function validatenip(nip) { var nip_bez_kresek = nip.replace(/-/g,""); var reg = /^[0-9]{10}$/; if(reg.test(nip_bez_kresek) == false) { return false; } else { var dig = (""+nip_bez_kresek).split(""); var kontrola = (6*parseInt(dig[0]) + 5*parseInt(dig[1]) + 7*parseInt(dig[2]) + 2*parseInt(dig[3]) + 3*parseInt(dig[4]) + 4*parseInt(dig[5]) + 5*parseInt(dig[6]) + 6*parseInt(dig[7]) + 7*parseInt(dig[8]))%11; if(parseInt(dig[9])==kontrola) return true; else return false; } } function validatepesel(pesel) { var reg = /^[0-9]{11}$/; if(reg.test(pesel) == false) { return false; } else { var dig = (""+pesel).split(""); var kontrola = (1*parseInt(dig[0]) + 3*parseInt(dig[1]) + 7*parseInt(dig[2]) + 9*parseInt(dig[3]) + 1*parseInt(dig[4]) + 3*parseInt(dig[5]) + 7*parseInt(dig[6]) + 9*parseInt(dig[7]) + 1*parseInt(dig[8]) + 3*parseInt(dig[9]))%10; if(kontrola==0) kontrola = 10; kontrola = 10 - kontrola; if(parseInt(dig[10])==kontrola) return true; else return false; } } // ACTIVITY INDICATOR var activityIndicatorOn = function(){ $('
').appendTo('body'); }, activityIndicatorOff = function(){ $('#imagelightbox-loading').remove(); }, // OVERLAY overlayOn = function(){ $('
').appendTo('body'); }, overlayOff = function(){ $('#imagelightbox-overlay').remove(); }, // CLOSE BUTTON closeButtonOn = function(instance){ $('').appendTo('body').on('click touchend', function() { $(this).remove(); instance.quitImageLightbox(); return false; }); }, closeButtonOff = function(){ $('#imagelightbox-close').remove(); }, // CAPTION captionOn = function(){ var description = $('a[href="' + $('#imagelightbox').attr('src') + '"] img').attr('alt'); if (description != '' && description != undefined) $('
' + description + '
').appendTo('body'); }, captionOff = function(){ $('#imagelightbox-caption').remove(); }, // NAVIGATION navigationOn = function(instance, selector){ var images = $(selector); if (images.length) { var nav = $('
'); for (var i = 0; i < images.length; i++) nav.append(''); nav.appendTo('body'); nav.on('click touchend', function() { return false; }); var navItems = nav.find('button'); navItems.on('click touchend', function() { var $this = $(this); if (images.eq($this.index()).attr('href') != $('#imagelightbox').attr('src')) instance.switchImageLightbox($this.index()); navItems.removeClass('active'); navItems.eq($this.index()).addClass('active'); return false; }) .on('touchend', function() { return false; }); } }, navigationUpdate = function(selector) { var items = $('#imagelightbox-nav button'); items.removeClass('active'); items.eq($(selector).filter('[href="' + $('#imagelightbox').attr('src') + '"]').index(selector)).addClass('active'); }, navigationOff = function(){ $('#imagelightbox-nav').remove(); }, // ARROWS arrowsOn = function(instance, selector) { var $arrows = $(''); $arrows.appendTo('body'); $arrows.on('click touchend', function(e) { e.preventDefault(); var $this = $(this), $target = $(selector + '[href="' + $('#imagelightbox').attr('src') + '"]'), index = $target.index(selector); console.log(index + " / " + selector); if ($this.hasClass('imagelightbox-arrow-left')) { index = index - 1; if (!$(selector).eq(index).length) index = $(selector).length; } else { index = index + 1; if (!$(selector).eq(index).length) index = 0; } instance.switchImageLightbox(index); return false; }); }, arrowsOff = function() { $('.imagelightbox-arrow').remove(); }; var imageLighBoxSelector = 'a.fancybox', imageLightboxInstance = $(imageLighBoxSelector).imageLightbox({ onStart: function() { overlayOn(); closeButtonOn( imageLightboxInstance ); arrowsOn( imageLightboxInstance, imageLighBoxSelector ); }, onEnd: function() { overlayOff(); captionOff(); closeButtonOff(); arrowsOff(); activityIndicatorOff(); }, onLoadStart: function() { captionOff(); activityIndicatorOn(); }, onLoadEnd: function() { captionOn(); activityIndicatorOff(); $( '.imagelightbox-arrow' ).css( 'display', 'block' ); } }); $(document).ready(function(){ $('#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( $('[name="mail"]').val() ) == false ){ // $('[name="mail"]').addClass('error'); // good = false; // } if ( $(this).find('[name="phonemail"]').val().replace(/[^\d]/, '').length < 9 ){ $(this).find('[name="phonemail"]').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(); } }); $('#home-popup-form').on('submit', function(evt){ evt.preventDefault(); var k = [ 'popup-name', 'popup-mail', 'popup-organization' ], good = true, cb = [ 'popup-agree-1', 'popup-agree-1' ]; $(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( $('[name="popup-mail"]').val() ) == false ){ $('[name="popup-mail"]').addClass('error'); good = false; } /*if ( $(this).find('[name="phonemail"]').val().replace(/[^\d]/, '').length < 9 ){ $(this).find('[name="phonemail"]').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'); } } for ( var i = 0; i < cb.length; i++ ){ var obj = $(this).find('[name="'+ cb[i] +'"]'); if ( !obj.prop('checked') ){ good = false; obj.addClass('error'); } } if ( good ){ $(this).find('p.ajaxInfo.send').show(); $(this).find('button[type="submit"]').attr('disabled', true); $.post( $(this).attr('action'), $(this).serialize(), (function(response){ if (response.indexOf('false') === -1) { $(this).find('input, textarea').val(''); $(this).find('p.ajaxInfo').hide(); $(this).find('p.ajaxInfo.ok').show(); } else { $(this).find('p.ajaxInfo').hide(); $(this).find('p.ajaxInfo.error_send').show(); } $(this).find('button[type="submit"]').attr('disabled', false); }).bind(this)); } else { $(this).find('p.ajaxInfo').hide(); $(this).find('p.ajaxInfo.error').show(); $(this).find('button[type="submit"]').attr('disabled', false); } }); // Zabiegaj linkom # $('a[href=#]').click(function(e){ e.preventDefault(); }); }); $(document).ready(function() { $(".slider").owlCarousel({ items: 1, autoplay: true, autoplayTimeout: 10000, autoplaySpeed: 1500, loop: true }); $(".slider2").owlCarousel({ items: 1, autoplay: false, autoplayTimeout: 2000, dots: false, nav: true, onResize: function() { if ( $('.slider2_wrap').length > 0 ){ $('.slider2_wrap').css('width', Math.floor($(window).width()/2) +'px'); } }, onInitialize: function() { if ( $('.slider2_wrap').length > 0 ){ $('.slider2_wrap').css('width', Math.floor($(window).width()/2) +'px'); } $('.inline-news').on('mouseenter', function() { $(".slider2").trigger('to.owl.carousel', [$(this).index(), 500, true]); }); } }); $('.course-form').on('submit', function(evt){ evt.preventDefault(); var k = [ 'name', 'term' ], k2 = [ 'amount1', 'amount2' ], 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="email"]').val() ) == false ){ $(this).find('[name="email"]').addClass('error'); good = false; } if ( $(this).find('[name="phone"]').val().replace(/[^\d]/, '').length < 9 ){ $(this).find('[name="phone"]').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'); } } for ( var i = 0; i < k2.length; i++ ){ var obj = $(this).find('[name="'+ k2[i] +'"]'); if ( isNaN(parseInt(obj.val())) || parseInt(obj.val()) < 0 ){ 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(); } }); $('.course-form-indyw').on('submit', function(evt){ evt.preventDefault(); var k = [ 'name' ], k2 = [], 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="email"]').val() ) == false ){ $(this).find('[name="email"]').addClass('error'); good = false; } if ( $(this).find('[name="phone"]').val().replace(/[^\d]/, '').length < 9 ){ $(this).find('[name="phone"]').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'); } } for ( var i = 0; i < k2.length; i++ ){ var obj = $(this).find('[name="'+ k2[i] +'"]'); if ( isNaN(parseInt(obj.val())) || parseInt(obj.val()) < 0 ){ 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(); } }); $('.course-order-form').on('submit', function(evt){ evt.preventDefault(); var k = [ 'name', 'birth', 'town', 'street', 'voivodeship', 'company', 'company_town', 'company_street' ], // k2 = [ 'amount' ], 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="email"]').val() ) === false ){ $(this).find('[name="email"]').addClass('error'); good = false; } if ( $(this).find('[name="phone"]').val().replace(/[^\d]/, '').length < 9 ){ $(this).find('[name="phone"]').addClass('error'); good = false; } if ( $(this).find('[name="phone_home"]').val().replace(/[^\d]/, '').length < 9 ){ $(this).find('[name="phone_home"]').addClass('error'); good = false; } if ( validatepesel($(this).find('[name="pesel"]').val()) === false ){ $(this).find('[name="pesel"]').addClass('error'); good = false; } if ( validatenip($(this).find('[name="nip"]').val()) === false ){ $(this).find('[name="nip"]').addClass('error'); good = false; } if ( validatenip($(this).find('[name="company_nip"]').val()) === false ){ $(this).find('[name="company_nip"]').addClass('error'); good = false; } if ( /^[\d]{2}-[\d]{3}$/.test( $(this).find('[name="zipcode"]').val() ) === false ){ $(this).find('[name="zipcode"]').addClass('error'); good = false; } if ( /^[\d]{2}-[\d]{3}$/.test( $(this).find('[name="company_zipcode"]').val() ) === false ){ $(this).find('[name="company_zipcode"]').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'); } } // for ( var i = 0; i < k2.length; i++ ){ // var obj = $(this).find('[name="'+ k2[i] +'"]'); // // if ( !parseInt(obj.val()) || parseInt(obj.val()) <= 0 ){ // 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(); } $('html, body').animate({ scrollTop: $(this).find('.ajaxInfo:visible').eq(0).offset().top }, 300); }).bind(this)); } else { $('html, body').animate({ scrollTop: $(this).find('[name].error').eq(0).offset().top }, 300); $(this).find('p.ajaxInfo.error').show(); } }); }); $(document).on('click', '.mobile-nav-toggle', function(evt){ evt.preventDefault(); evt.stopPropagation(); $('.mobile-nav nav').toggleClass('show'); }); $.fn.widgetFloat = function () { if ($(this).length === 0) { return false; } var that = $(this); var startPosition = that.offset(); var startWidth = that.outerWidth(); var margin = 15; var container = that.closest('.container'); var bottom = container.innerHeight() + container.offset().top - that.outerHeight(); var onScroll = function () { var windowTop = $(window).scrollTop(); if ( that.closest('.row').width() === that.parent().outerWidth() || that.parent().prev().height() <= that.parent().height() ) { that.removeClass('float'); return false; } if (windowTop >= startPosition.top - margin) { that.outerWidth(startWidth); that.addClass('float'); if (windowTop >= bottom - 3*margin) { that.css({ top: bottom - windowTop - 2*margin }); } else { that.css({ top: margin }); } } else { that.removeClass('float'); } }; $(window).on('scroll', onScroll); $(window).on('resize', function () { startWidth = that.parent().width(); that.outerWidth(startWidth); startPosition = that.parent().offset(); bottom = container.innerHeight() + container.offset().top - that.outerHeight(); onScroll(); }); onScroll(); }; $('.widget').widgetFloat(); $(document).ready(function() { if( $('#homeModal.start-modal').length > 0 ){ setTimeout(function(){ $(document).ready(function(){ $('#homeModal').modal(500); }); }, 2500); $('#homeModal.start-modal').on('hidden.bs.modal', function (event) { $('#preloadedImages').load( __URL__ + 'accepthomemodal.php').remove(); }) } });