/* Walidacja formularza */


function form_check(form)
{
  var komunikat = '';                
  niewysylaj=0;
  $("form."+form+" .wymagane").each(function(){  
    if((this.value == this.defaultValue) || ($(this).val() == '')) { $(this).addClass('warning'); niewysylaj='1'; }       
    });                                                                                                             
  if(niewysylaj == 1) { komunikat += 'Proszę wypełnić wszystkie pola.'; }
  var wzorMaila = /^[0-9a-z_.-]+@+[0-9a-z.-]+\.[a-z]{2,3}$/i;
  var mail = $("form."+form).find(".input_mail").val();
  if (wzorMaila.test(mail)) { /* poprawny mail */ } else { if(komunikat != '') { komunikat += ' '; } komunikat += 'Prosze podac poprawny adres e-mail.'; $("form."+form+" .input_mail").addClass('warning'); niewysylaj='1'; }
  if (niewysylaj == '1') { alert(komunikat); return false; } else { return true; }  
}


function prev() { window.history.back() }

/* Obliczanie rozmiarow okna przegladarki */
function testo(rozer) {
         var roz = new Array(0,0);
         if( typeof( window.innerWidth ) == 'number' ) {
           //Non-IE
           roz[0] = window.innerWidth;
           roz[1] = window.innerHeight;
         } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
           //IE 6+ in 'standards compliant mode'
           roz[0] = document.documentElement.clientWidth;
           roz[1] = document.documentElement.clientHeight;
         } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
           //IE 4 compatible
           roz[0] = document.body.clientWidth;
           roz[1] = document.body.clientHeight;
         };
         if (rozer=="wys") { return roz[1]; } else { return roz[0]; }
 }


$(document).ready(function() {

  $(".wymagane").focus(function(){ if(this.value != this.defaultValue){ this.select(); } else { this.value = ''; } });
  $(".wymagane").blur(function(){ if(this.value == ''){ this.value = this.defaultValue;  }   });

  $(".wymagane").focus(function(){  $(this).removeClass('warning');  });

  $('.galeria a.fancy').fancybox(
    {
    'showNavArrows':'false',
    'titleShow':true,
    'titlePosition':'outside',
    'transitionIn':'fade',
    'transitionOut':'fade',
    'cyclic':'false',
    'overlayColor':'#000000',
    'overlayOpacity':'0.8',
    'scrolling':'no',
    'hideOnOverlayClick':'true'
    }
  );

  $(".tooltip").tooltip({ showURL: false, track: true });

  /* Polec */  
  var polec_top = testo('wys') * 0.5 - 45;
  var polec_left = testo('szer') * 0.5 - 165; 
  $('.polec_box').css('marginTop', polec_top+'px');
  $('.polec_box').css('marginLeft', polec_left+'px');
  $(window).resize(function() {
     var polec_top = testo('wys') * 0.5 - 45;
     var polec_left = testo('szer') * 0.5 - 165; 
     $('.polec_box').css('marginTop', polec_top+'px');
     $('.polec_box').css('marginLeft', polec_left+'px');
     $('.polec_zaslona').css('height', '100%');
  });
  
  $('.btn_polec').click(function() {  
    $('div.polec_box').show();
    $('div.polec_zaslona').fadeIn(100);
  });
  $('div.polec_box_close').click(function() {
    $('div.polec_zaslona').fadeOut(100);
  });    
  /* Polec - END */ 

  
})
