function newwindow(url)
{
  window.open(url,'','scrollbars=yes, location=no, status=no, width=630, height=500, resizable');
}

function newhint(url)
{
  window.open(url,'','scrollbars=yes, location=no, status=no, width=450, height=300, resizable,menubar=no');
}

function radios_enable(formname, name, enable)
{
  radios=window.document.getElementById(formname).elements[name];
  if(radios)
    for(i=0; i<radios.length; i++)
    {
      radios[i].disabled = !enable;
      if(!enable)
        radios[i].checked = false;
    };
}

// coll - kolekcja, robimy nadajac wszystkim checkboxom ta samo name, np. "idp[]"
//        a potem pobieramy przez document.getElementsByName('idp[]')
function set_check(coll, checked)
{
  var len=coll.length;
  for(var i=0; i<len; i++)
    coll.item(i).checked=checked;
}

function check_pesel(pesel)
{
  wagi = new Array(1, 3, 7, 9, 1, 3, 7, 9, 1, 3);

  if(!pesel.match(new RegExp('^[0-9]{11}$')))
    return 0;
  var n=0;
  for(var i=0; i<10; i++)
    n+=pesel.substr(i, 1) * wagi[i];
  n=10-(n%10);
  if(n==10) n=0;
  if(pesel.substr(10, 1) != n)
    return 0;
  return 1;
}

function checkdate(ddd)
{
  var m=ddd.match(/^([0-9]{4})\-([0-9]{2})\-([0-9]{2})$/);
  if(m)
    return m[2]>0 && m[2]<13 && m[1]>0 && m[1]<32768 && m[3]>0 && m[3]<=(new Date(m[1], m[2], 0)).getDate();
  else
    return false;
}


