

<!--

(function(jQuery){
 jQuery.fn.alphanumeric = function(p) { 
  p = jQuery.extend({
   ichars: "!@#$%^&*()+=[]\\\';,/{}|\":<>?~`.- ",
   nchars: "",
   allow: ""
    }, p); 
  return this.each
   (
    function() 
    {
     if (p.nocaps) p.nchars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
     if (p.allcaps) p.nchars += "abcdefghijklmnopqrstuvwxyz";
     
     s = p.allow.split('');
     for ( i=0;i<s.length;i++) if (p.ichars.indexOf(s[i]) != -1) s[i] = "\\" + s[i];
     p.allow = s.join('|');
     
     var reg = new RegExp(p.allow,'gi');
     var ch = p.ichars + p.nchars;
     ch = ch.replace(reg,'');
     jQuery(this).keypress
      (
       function (e)
        {
        
         if (!e.charCode) k = String.fromCharCode(e.which);
          else k = String.fromCharCode(e.charCode);
          
         if (ch.indexOf(k) != -1) e.preventDefault();
         if (e.ctrlKey&&k=='v') e.preventDefault();
         
        }
        
      );
      
     jQuery(this).bind('contextmenu',function () {return false});
         
    }
   );
 };
 jQuery.fn.numeric = function(p) {
 
  var az = "abcdefghijklmnopqrstuvwxyz";
  az += az.toUpperCase();
  p = jQuery.extend({
   nchars: az
    }, p); 
     
  return this.each (function()
   {
    jQuery(this).alphanumeric(p);
   }
  );
   
 };
 
 jQuery.fn.alpha = function(p) {
  var nm = "1234567890";
  p = jQuery.extend({
   nchars: nm
    }, p); 
  return this.each (function()
   {
    jQuery(this).alphanumeric(p);
   }
  );
   
 }; 
})(jQuery);

jQuery(document).ready(function(){
 
 var id = location.search;
 if(id != ""){
  id = decodeURI(id );
  id = id.substr(4,1);
  if(id == "0"){
   jQuery(".msg").html("Formularz zawierał niepoprawne dane!");
   jQuery(".msg").show();
  }
  if(id == "1"){
    jQuery(".msg").html("Formularz został wysłany");
    jQuery(".msg").show();
  }
 }
    jQuery("#name").alpha({allow:"- "});
    jQuery("#phone").numeric();
    
    jQuery("#phone").blur(function(){
        var telephon = jQuery("#phone").val();
        telephon = telephon.replace(/\s+/gi,'')
        jQuery("#phone").val(telephon);
    });
  
});


function walidacja()
{
   jQuery(".msg").hide();
  var brakuje_danych=false;
  var formularz=document.forms[0];
  var napis="";
  var reg;
  var wyn;
  reg = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/; 
  var imie =  jQuery("#name").attr("value");

wyn = jQuery("#email").attr("value").match(reg);
 
if (jQuery("#name").attr("value") == ""){
    napis += "Podaj Imię i nazwisko\n";
    brakuje_danych=true;
  } 
else{
    if(imie.length < 5){
         napis += "Za krótkie Imię i nazwisko\n";
         brakuje_danych=true;

    }
}

if (jQuery("#phone").val() == ""){
    napis += "Podaj Telefon\n";
    brakuje_danych=true;
  }
else{
       var telephon = jQuery("#phone").val();
        
       if (telephon.length<13 && telephon.length>8){
        
        }
        else{
        napis += "Podaj prawidłowy numer telefonu\n";
        brakuje_danych=true;
        } 
}

 if (wyn == null) { 
  napis += "Podaj adres E-mail\n";
 brakuje_danych=true; 
  }
    
  if (jQuery('.check').is(':checked')){
  }
  else{
  napis += "Musisz wyrazić zgodę\n";
    brakuje_danych=true;
 }
 if (!brakuje_danych){
    return true;
  }
  else{
    alert (napis);
    return false;
  }
}

function show(id){
    if(id == 3){
        jQuery("#box1").hide();
        jQuery("#box2").hide();
        jQuery("#box4").hide();
        jQuery("#box3").show();        
    }    
    if(id == 1){
        jQuery("#box2").hide();
        jQuery("#box3").hide();
        jQuery("#box4").hide();
        jQuery("#box1").show();        
    }    
    if(id == 2){
        jQuery("#box1").hide();
        jQuery("#box3").hide();
        jQuery("#box4").hide();
       jQuery("#box2").show();        
    }    
    if(id == 4){
        jQuery("#box1").hide();
        jQuery("#box2").hide();
        jQuery("#box3").hide();
        jQuery("#box4").show();        
    }    
}

//-->
