function addFloc() {
	
	
	var ogranichenie = document.getElementById('ogranichenie').innerHTML;
	var izbrani = document.getElementById('izbrani').innerHTML;
	
	if(ogranichenie==izbrani)
	{
		alert('Избрали сте '+izbrani+' от '+ogranichenie+' подкатегории.');
	}else{
		
		asd=document.forms['forma']['sl'];
		bsd=document.forms['forma']['lolist'];
	
		i=0;
		while (i<asd.options.length) {
			if (asd.options[i].selected && asd.options[i].value>0) {
				j=0; skipins=0;
				while (j<bsd.options.length) {
					if (bsd.options[j].value==asd.options[i].value) skipins=1;
					j++;
				}
				
				if (!skipins) {
				var elOptNew = document.createElement('option');
					elOptNew.text = asd.options[i].text
					elOptNew.value = asd.options[i].value
	
					try {
						bsd.add(elOptNew, null);
					}
					catch(ex) {
						bsd.add(elOptNew);
					}
				}
			}
			i++
		}
	}
	countFloc();
}



function remFloc() {
	bsd=document.forms['forma']['lolist'];
	i=0;
	len=bsd.options.length;
	while (i<len) {
		if (bsd.options[i].selected && bsd.options[i].value>0) {
			bsd.remove(i);
			len--;
		} else {
			i++;
		}
	}
	countFloc();
}

function countFloc() {
	bsd=document.forms['forma']['lolist'];
	i=0;
	len=bsd.options.length;
	document.getElementById('izbrani').innerHTML = len;
}

function fillHidden() {
	if (document.forms['forma']['lolist']) {
		bsd=document.forms['forma']['lolist'];
		i=0;
		hstr='';
		while (i<bsd.options.length) {
			if (hstr) hstr+=',';
			hstr+=bsd.options[i].value;
			i++;
		}
		document.forms['forma']['categories'].value=hstr;
	}

	if (document.forms['forma']['tylist']) {
		tsd = document.forms['forma']['tylist'];
		i = 0;
		addedPar = false;

		while (i < tsd.length && addedPar == false) {
			if (tsd[i].checked == true)
			{
				document.getElementById('parent').value = tsd[i].value;
				addedPar = true;
			}
			i++;
		}
	}
	
	document.forms['forma'].submit();
	
}
