function requestSubmit(path, l){
  
  var app             = document.getElementById("app");
  var nome            = document.getElementById("nome");
  var cognome         = document.getElementById("cognome");
  var indirizzo       = document.getElementById("indirizzo");
  var cap             = document.getElementById("cap");
  var citta           = document.getElementById("citta");
  var nazione         = document.getElementById("nazione");
  var telefono        = document.getElementById("telefono");
  var email           = document.getElementById("email");
  var tipo_richiesta  = document.getElementById("tipo_richiesta");
  var richieste       = document.getElementById("richieste");
  var privacy         = document.getElementById("privacy");

  var phone_reg_exp = /^([0-9_\.\-\+\ \/])+$/;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

  if (nome.value == ""){
    if (l == "IT")
      alert("ERRORE: IL CAMPO NOME NON E' STATO COMPILATO");
    else if (l == "EN" || l == "FR" || l == "DE" || l == "ES")
      alert("ERROR: FIELD NAME IS REQUIRED");
    nome.style.backgroundColor = "#FF0000";
    nome.focus();
  }
  else if (email.value == ""){
    if (l == "IT")
      alert("ERRORE: IL CAMPO EMAIL NON E' STATO COMPILATO");
    else if (l == "EN" || l == "FR" || l == "DE" || l == "ES")
      alert("ERROR: FIELD EMAIL IS REQUIRED");  
    email.style.backgroundColor = "#FF0000";
    email.focus();
  }
  else if (email.value != "" && !email_reg_exp.test(email.value)){
    if (l == "IT")
      alert("ERRORE: CAMPO EMAIL NON CORRETTO");
    else if (l == "EN" || l == "FR" || l == "DE" || l == "ES")
      alert("ERROR: FIELD EMAIL IS NOT CORRECT");
		email.value = '';
		email.focus();
	}
	else if (telefono.value != "" && !phone_reg_exp.test(telefono.value)){
    if (l == "IT")
      alert("ERRORE: CAMPO TELEFONO NON CORRETTO. SONO CONSENTITI SOLO NUMERI E I SIMBOLI . - + /");
    else if (l == "EN" || l == "FR" || l == "DE" || l == "ES")
      alert("ERROR: FIELD PHONE IS NOT CORRECT");		
  	telefono.value = '';
		telefono.focus();
	}
  else if (privacy.checked == false){
    if (l == "IT")
      alert("ERRORE: MANCA AUTORIZZAZIONE PRIVACY");
    else if (l == "EN" || l == "FR" || l == "DE" || l == "ES")
      alert("ERROR: YOU HAVE TO AGREE PRIVACY NOTICE");  
    privacy.style.backgroundColor = "#FF0000";
    privacy.focus();
  }
  else{
    if (l == "IT")
      var sending = 'Invio richiesta in corso...';
    else if (l == "EN" || l == "FR" || l == "DE" || l == "ES")
      var sending = 'Sending request...';
    
    document.getElementById("contact_form").innerHTML = '<div style="margin: 0 auto; height: 150px; text-align:center;"><img src="../'+path+'/modules/Contatti/images/loading.gif" /><br/>'+sending+'</div>';
    
    var url 	   = '../'+path+'/modules/Contatti/xml/xmlContatti.php';
  	var params 	 = 'l='+parseParam(l)+'&app='+parseParam(app.value)+'&nome='+parseParam(nome.value)+'&cognome='+parseParam(cognome.value)+'&indirizzo='+parseParam(indirizzo.value)+'&cap='+parseParam(cap.value)+'&citta='+parseParam(citta.value)+'&nazione='+parseParam(nazione.value)+'&telefono='+parseParam(telefono.value)+'&email='+parseParam(email.value)+'&tipo_richiesta='+parseParam(tipo_richiesta.value)+'&richieste='+parseParam(richieste.value);
    var method 	 = 'POST';
  	
    myXMLHTTPRequest(method, url, params, responseSubmit);

  }

}


function responseSubmit(httpRequest){
	if (myXMLHTTPResponse(httpRequest, "text/xml")){
		var xmldoc = myXMLHTTPResponse(httpRequest, "text/xml");
		var esito = xmldoc.getElementsByTagName('esito').item(0).firstChild.data;		
		document.getElementById("contact_form").innerHTML = esito;
	}
	else{
	}
}


function colorOK(field){
  var color = "#FFFFFF";
  document.getElementById(field).style.backgroundColor = color;
}

