function sendForm(id_form, id_hidden_action, action)
{
	var hidden_action = document.getElementById(id_hidden_action);
	var form = document.getElementById(id_form);
	hidden_action.value=action;
	form.submit();
	
}


// Funzioni per la modellazione DOM dei campi select (option)

function insertOptionBefore(id, num, text, value)
{
  var elSel = document.getElementById(id);
  if (elSel.options[num] >= 0) {
    var elOptNew = document.createElement('option');
    elOptNew.text = text;
    elOptNew.value = value;
    var elOptOld = elSel.options[num];  
    try {
      elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
    }
    catch(ex) {
      elSel.add(elOptNew, elSel.options[num]); // IE only
    }
  }
}

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

function appendOptionLast(id, text, value, selected)
{
  var elOptNew = document.createElement('option');
  elOptNew.text = text;
  elOptNew.value = value;
  if(selected)
  	elOptNew.selected = true;
  var elSel = document.getElementById(id);

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

function removeOptionLast(id)
{
  var elSel = document.getElementById(id);
  if (elSel.length > 0)
  {
    elSel.remove(elSel.length - 1);
  }
}

