function SetAllCB(nval)
	{
	re = new RegExp("cb_\\d*$") 
	for(i = 0; i < document.forms[0].elements.length; i++) {
			elm = document.forms[0].elements[i]
		if (elm.type == 'checkbox') {
				if (re.test(elm.name)) {
					if (nval == true)
							elm.checked = true;
					else
					if (nval == false)
						elm.checked = false;
					else
					if (nval == "not")
						elm.checked =! elm.checked;  
				}
			}
		}
	}
  function PL_licz(n,t1,t2,tn )
	{
        if(n == 1)
          return t1;
        else if (n> 1 && n<5)
          return t2;
        else  if (n>4)
          return tn;
	}
  function HideById(Id)
	{
        var Obj=document.getElementById(Id);
        Obj.style.display='none';
	}
	 function ShowById(Id)
	{
        var Obj=document.getElementById(Id);
        //Obj.style.display='table-row';
        //alert(Obj.tagName);
        if(Obj.tagName.toUpperCase()=='TR')
          ShowById_tr(Id);
        else
          Obj.style.display='inline';
	}
	function ShowById_tr(Id)
	{
        var Obj=document.getElementById(Id);
        try
        {
             Obj.style.display='table-row';
        }
       catch (e)
        {
            Obj.style.display='inline';
        }
	}
function ajaxSub(Req)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
/*  For debug
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
            alert(xmlHttp.responseText);
        }
      }
    xmlHttp.open("GET","index.php5?act=ajax&actajax=" + Req,true); */
    xmlHttp.open("GET","index.php5?act=ajax&actajax=" + Req,false);
    xmlHttp.send(null);
  }

function clearForm(formName)
{
  var form, elements, i, elm;
    form = document.forms[formName];
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			if (elm.type == "text")
			{
				elm.value ='';
			}
			if (elm.type == "radio")
			{
				elm.checked =false;
			}
		}
}
function ShowNonEmpty(formName,elId)
{
  var form, elements, i, elm,Show;
    Show=false;
    form = document.forms[formName];
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			if (elm.type == "text" | elm.type == "hidden"  )
			{
				if(elm.value !='')
				{
          Show=true;
        }
      }
  	}
		if(Show)
       ShowById(elId);
}

