function fill_domeniu(forma)
{
 if (window.document.getElementById('iddomeniu').selectedIndex > 0 )
//	idDomSel   = parseInt(window.document.forms[forma].iddomeniu.options[window.document.forms[forma].iddomeniu.selectedIndex].value);
	 idDomSel   = parseInt(window.document.getElementById('iddomeniu').options[window.document.getElementById('iddomeniu').selectedIndex].value);
 else
   idDomSel = -1;		 	 

	for (i = domeniu.length - 1; i >= 0  ;i--)
		  window.document.getElementById('iddomeniu').options[i]=null;
 
//	  window.document.forms[forma].iddomeniu.options[i]=null;
//  window.document.forms[forma].iddomeniu.options[window.document.forms[forma].iddomeniu.length] = new Option(domeniu[0].dendomeniu,String(domeniu[0].iddomeniu));
  window.document.getElementById('iddomeniu').options[window.document.getElementById('iddomeniu').length] = new Option(domeniu[0].dendomeniu,String(domeniu[0].iddomeniu));
	for ( i = 1; i < domeniu.length; i++)
	{
//				window.document.forms[forma].iddomeniu.options[window.document.forms[forma].iddomeniu.length] = new Option(domeniu[i].dendomeniu,String(domeniu[i].iddomeniu));
				window.document.getElementById('iddomeniu').options[window.document.getElementById('iddomeniu').length] = new Option(domeniu[i].dendomeniu,String(domeniu[i].iddomeniu));
	}	
//	selecteazaElementListaLocala(window.document.forms[forma].iddomeniu, idDomSel);
	selecteazaElementListaLocala(window.document.getElementById('iddomeniu'), idDomSel);
	if (window.document.getElementById('idsubdomeniu'))
	{ 
	  fill_subDomeniu(forma);
	}	
}


function fill_subDomeniu(forma)
{
//alert(window.document.getElementById('idcategorie').selectedIndex);
 if (window.document.getElementById('iddomeniu').selectedIndex > 0 )
//	idDomSel   = parseInt(window.document.forms[forma].iddomeniu.options[window.document.forms[forma].iddomeniu.selectedIndex].value);
	idDomSel   = parseInt(window.document.getElementById('iddomeniu').options[window.document.getElementById('iddomeniu').selectedIndex].value);
 else
   idDomSel = -1;		 	 

 if (window.document.getElementById('idsubdomeniu').selectedIndex > 0 )
 	idSubDomSel   = parseInt(window.document.getElementById('idsubdomeniu').options[window.document.getElementById('idsubdomeniu').selectedIndex].value);
//	idSubDomSel   = parseInt(window.document.forms[forma].idsubcategorie.options[window.document.forms[forma].idsubcategorie.selectedIndex].value);
 else
   idSubDomSel = -1;		 	 

	for (i = subDomeniu.length - 1; i >= 0  ;i--)
	 window.document.getElementById('idsubdomeniu').options[i]=null;	
//	 window.document.forms[forma].idsubdomeniu.options[i]=null;

//  window.document.forms[forma].idsubdomeniu.options[window.document.forms[forma].idsubdomeniu.length] = new Option(subDomeniu[0].dendomeniu,String(subDomeniu[0].iddomeniu));
  window.document.getElementById('idsubdomeniu').options[window.document.getElementById('idsubdomeniu').length] = new Option(subDomeniu[0].dendomeniu,String(subDomeniu[0].iddomeniu));
	for (i=1;i<subDomeniu.length;i++)
	{
	  if (idDomSel < 0)
		  break;
      if ( (subDomeniu[i].i_iddomeniu == idDomSel || idDomSel < 0) )
	  {
	    window.document.getElementById('idsubdomeniu').options[window.document.getElementById('idsubdomeniu').length] = new Option(subDomeniu[i].dendomeniu,String(subDomeniu[i].iddomeniu));
//	    window.document.forms[forma].idsubdomeniu.options[window.document.forms[forma].idsubdomeniu.length] = new Option(subDomeniu[i].dendomeniu,String(subDomeniu[i].iddomeniu));
				}	
	}	
//	selecteazaElementListaLocala(window.document.forms[forma].idsubdomeniu, idSubDomSel);
	selecteazaElementListaLocala(window.document.getElementById('idsubdomeniu'), idSubDomSel);
}


function selecteazaElementListaLocala(lista, value)
{
  for (var i = 0; i<lista.length; i++)
  {
    if (lista.options[i].value == value)
	  {
      lista.options[i].selected = true;
		  break;
	  }	
  }
}

