function removeAllOptions(el)
{
  var elSel = document.getElementById(el);
  var i;
  var l = elSel.length - 1;
  for (i = l; i>=0; i--) {
      elSel.remove(i);
  }
}

function appendOptionLast(el, text, val)
{
  var elOptNew = document.createElement('option');
  elOptNew.text = text;
  elOptNew.value = val;
  var elSel = document.getElementById(el);

  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
}

function removeOptionSelected()
{
  var elSel = document.getElementById('selectX');
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
    if (elSel.options[i].selected) {
      elSel.remove(i);
    }
  }
}

function alege_subcategorie (id_cat){
	removeAllOptions("subcategorie");
	for (i = 1; i <= nr_subcat[id_cat]; i++) {
		appendOptionLast("subcategorie", subcat[id_cat][i][1], subcat[id_cat][i][0]);
	}
}

function alege_oras (id_judet){
	removeAllOptions("id_oras");
	for (i = 1; i <= nr_judet[id_judet]; i++) {
		appendOptionLast("id_oras", judet[id_judet][i][1], judet[id_judet][i][0]);
	}
}



