function noweOkno(url,nazwaokna,param)
  {
	window.open(url,nazwaokna,param)
	}

function getObjectRef(name) {
  if(document.getElementById) return document.getElementById(name);
  else if(document.all) return document.all[name];
  else return null;
}

function select_w(ids)
    {
     var x=getObjectRef(ids);
     //alert (x.id);
     if(x.selectedIndex<0)
        {
        this.err='error: '+x.selectedIndex;
        }
        else
        {
        this.err='';
        this.wart=x.options[x.selectedIndex].value;     //wartosc opcji (value)
        this.txt=x.options[x.selectedIndex].text;       // opis opcji (tekst miedzy znacznikami option)
        this.label=x.options[x.selectedIndex].label;    // label opcji (label) - nie działa w IE
        this.title=x.options[x.selectedIndex].title     // tytuł opcji - działa wszędzie
        this.s_index=x.selectedIndex;                   // indeks zaznaczonej opcji
        }
     return this;
    }

function radio_w(idr)
    {
     var x=document.getElementsByName(idr);
     //alert (x.id);
     this.err='error: ';
     for(i=0;i<x.length;i++)
        {
         if(x[i].checked)
            {
            this.err='';
            this.wart=x[i].value;     //wartosc opcji (value)
            this.alt=x[i].alt;     //opis pola (value)
            this.tytul=x[i].title;     //opis pola (value)
            }
         }
     return this;
    }

function req()
    {
     x=true;
     for (var i=0; i<arguments.length; i++)
     {
        typ=getObjectRef(arguments[i]).type;
        if(typ=='select'){
            s=new select_w(arguments[i]);
            if(s.err!='')x=false;
            }
        if(typ=='radio'){
            r=new radio_w(arguments[i]);
            if(r.err!='')x=false;
        }
        else{
          if(getObjectRef(arguments[i]).value=='')
          {
          x=false;
          }
        }
      if(!x) break;
     }
     return x;
    }

function valiDate(pid)
    {
     x=$(pid).value;
     arr=x.split('-');
     //alert($(pid).id+' | '+arr.length);
     if(arr.length==3)
        {
        if(arr[0].length==4 && !isNaN(arr[0]) && arr[0]>1990 && arr[0]<2050) //sprawdzam rok
            {
             if(arr[1].length==2 && !isNaN(arr[1]) && arr[1]>0 && arr[1]<13) //sprawdzam miesiąc
                {
                   if(arr[2].length==2 && !isNaN(arr[2]) && arr[2]>0 && arr[2]<32) //sprawdzam dzień
                    {
                    tr=true;
                    }
                    else
                    {
                    tr=false;
                    $(pid).activate();
                    alert ("Dzień ma zły zapis. Sposób zapisu: RRRR-MM-DD");
                    }
                }
                else
                {
                tr=false;
                $(pid).activate();
                alert ("Miesiąc ma zły zapis. Sposób zapisu: RRRR-MM-DD");
                }
            }
            else
            {
            tr=false;
            $(pid).activate();
            alert ("Rok ma zły zapis. Sposób zapisu: RRRR-MM-DD");
            }
         }
         else
         {
          tr=false;
          $(pid).activate();
          alert('Niepoprawny format daty!');
         }
     return (tr);
    }

function validEmail(pole)
    {
     var error = '';
     mail = getObjectRef(pole).value;
    // sprawdzenie poprawności adresu email
    var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
    var odp = regex.test(mail);
    if (!odp) {
     //this.error = 'Nie poprawny adres email';
     return false;
     }
     else return true;
    }
