function GetElement(name)
{
	if(document.getElementById)
		return document.getElementById(name);
	else if(document.all)
		return document.all[name];
	else if(document.layers)
		return document.layers[name];
}

function Vloz(p,t)
{
	if(document.all||document.getElementById)
		p.innerHTML=t;
	else if(document.layers)
	{
		p.document.write(t);
		p.document.close();
	}
}

function cnt2(p,max,max2,hl,hl2)
{
	var delka=p.value.length;
	if(delka>max)
	{
		alert(hl);
		p.value=p.value.substr(0,max);
		delka=max;

		if(p.value.substr(max,1)=='\n')
		{
			p.value=p.value.substr(0,max-1);
			delka=max-1;
		}
	}

	var t=p.value,n=0,nLast=0,pocet=0;
	while((n=t.indexOf("\n",n))>-1)
	{
		pocet++;
		nLast=n;
		n++;
	}
	if(pocet>max2)
	{
		alert(hl2);
		p.value=t.substring(0,nLast-1)+t.substr(nLast+1);
		pocet=max2;
		delka=p.value.length;
	}

	var nap=GetElement(p.name+'_nap');
	var zb=GetElement(p.name+'_zb');
	var nap2=GetElement(p.name+'_nap2');
	var zb2=GetElement(p.name+'_zb2');

	Vloz(nap,delka);
	Vloz(zb,max-delka);
	Vloz(nap2,pocet);
	Vloz(zb2,((max2-pocet)>0)?(max2-pocet):0);
}

