$(function(){

  //animacja menu dla glownych dzialow
  $('.menu_header').click(function(){
    if( $(this).next('div').is(':hidden') ) {
      $('.menu_header').not(this).next('div').slideUp('slow');
      $(this).next('div').slideDown('slow');
    }
  });

  //animacja menu dla dzialow podrzednych
  $(".menu_items a[href='#']").click(function(){
    $(this).next('div').slideToggle('slow');
    return false;
  });

  if( $('.active').length > 0 ) {
    $('.menu_header').next('div').hide();
    if( $('.active').parent().parent().hasClass('menu_items') ){
      $('.active').parent().parent().show();
    }
    $('.active').parent().show();
  }

  $('.lightbox').lightBox({
    imageBtnClose: './images/lightbox-btn-close-pl.gif',
    imageBtnPrev: './images/lightbox-btn-prev-pl.gif',
    imageBtnNext: './images/lightbox-btn-next-pl.gif',
    fixedNavigation: true
  });

  var content_height = $("#content").outerHeight();
  var menu_height = $("#menu").outerHeight();
  if( content_height < menu_height ) {
    $("#content").css('height',menu_height+'px');
  }

});

var email_pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/

function send_check() {
  errors = '';
  if( $('#imie_nazwisko').val() == '' ) {
    errors += "Podaj imię i nazwisko!\n";
  }
  if( !email_pattern.test($('#email').val()) ) {
    errors += "Niepoprawny adres e-mail!\n";
  }
  if( $('#msg').val().length < 10 ) {
    errors += "Wiadomość musi zawierać co najmniej 10 znaków!\n";
  }
  if( !$('#zgoda').is(':checked') ) {
    errors += "Musisz wyrazić zgodę na przetwarzanie danych!\n";
  }
  if( errors != '' ) {
    alert(errors);
    return false;
  } else {
    return true;
  }
}


