function checkcampiobbligatori(form, testoallert) {

  var risultato = true;
  var vuotieobbligatori = new Array();
  $$('input[class^=obbligatorio]', 'select[class^=obbligatorio]',
      'textarea[class^=obbligatorio]', 'checkbox[class^=obbligatorio]',
      'radio[class^=obbligatorio]').each( function(el) {
    if (($(el).type == "text") && ($(el).value == "")) {
      vuotieobbligatori.push($(el).name);
    }
    if (($(el).type == "textarea") && ($(el).value == "")) {
      vuotieobbligatori.push($(el).name);
    }
    if (($(el).type == "select-one") && ($(el).value == "")) {
      vuotieobbligatori.push($(el).name);
    }
    if ($(el).type == "radio") {
      if (!(controlcheckbox($(el).name))) {
        vuotieobbligatori.push($(el).name);
      }
    }
    if ($(el).type == "checkbox") {
      if (!(controlcheckbox($(el).name))) {
        vuotieobbligatori.push($(el).name);
      }
    }
  })

  if (vuotieobbligatori.length > 0) {
    var msg = testoallert;
    for (i = 0; i <= vuotieobbligatori.length; i++) {
      msg = msg + "-" + vuotieobbligatori[i];
    }
    alert(testoallert);
    return false;
  } else {
    return true;
  }
}

function controlcheckbox(x) {
  var ok = false;
  $$('input[name=' + x + ']').each( function(ck) {
    if (ck.checked == true)
      ok = true;
    ;
  })
  return ok;
}

function checkOrdina(sAlert) {

  var nome = document.getElementById("field_nome").value;
  var cognome = document.getElementById("field_cognome").value;
  var nazione = document.getElementById("field_nazione").value;
  var regioneProvincia = document.getElementById("field_regioneprovincia").value;
  var citta = document.getElementById("field_citta").value;
  var email = document.getElementById("field_email").value;
  var cell = document.getElementById("field_cellulare").value;
  var tel = document.getElementById("field_telefono").value;
  var who = controlcheckbox("radiochi");
  var privacy = controlcheckbox("field_privacy");

  if (nome == '' || cognome == '' || nazione == '' || regioneProvincia == '' || citta == ''
      || email == '' || cell == '' || tel == '' || who == false || privacy == false) {
    alert(sAlert);
    return false;
  }


  var atleastonerim = false;
  $$('.checkfororder').each( function(ck) {
    if (ck.checked) {
      atleastonerim = true;
    }
  })

  if (!atleastonerim){
    alert(sAlert);
    return false;
  }


}
