function requestSubmit(){
  
  var color         = "#FF0000";

  var l             = document.getElementById("l");
  var azienda       = document.getElementById("azienda");
  var riferimento   = document.getElementById("riferimento");
  var telefono      = document.getElementById("telefono");
  var email         = document.getElementById("email");
  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 (azienda.value == ""){
    
    document.getElementById("azienda_required").style.visibility = "visible";
    azienda.style.backgroundColor = color;
    azienda.focus();
  
  }
  else if (riferimento.value == ""){
    
    document.getElementById("riferimento_required").style.visibility = "visible";
    riferimento.style.backgroundColor = color;
    riferimento.focus();
  
  }
  else if (email.value == ""){
  
    document.getElementById("email_required").style.visibility = "visible";
    email.style.backgroundColor = color;
    email.focus();
  
  }
  else if (email.value != "" && !email_reg_exp.test(email.value)){
  
    document.getElementById("email_required").style.visibility = "visible";
    email.style.backgroundColor = color;  
		email.value = '';
		email.focus();
			
	}

  else if (privacy.checked == false){
    
    document.getElementById("privacy_required").style.visibility = "visible";
    document.getElementById("privacy_required_2").style.color = color;
    
    document.getElementById("a_agenti").style.color = color;
    
    privacy.style.backgroundColor = color;
    privacy.focus();
  
  }
  else{

    document.getElementById("agenti_form").innerHTML = '<div style="margin: 0 auto; height: 150px; text-align:center; font-size: 10px;"><br/><br/><br/><br/><br/><img src="images/loading.gif" /><br/><br/>Invio richiesta in corso...</div>';
    
    var url 	   = 'xml/xmlContatti.php';
  	
  	var params 	 = 'l='+l.value+'&azienda='+azienda.value+'&riferimento='+riferimento.value+'&telefono='+telefono.value+'&email='+email.value+'&richieste='+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("agenti_form").innerHTML = esito;
		
	}
	else{
	}
}


function colorOK(field){

  var color = "#FFFFFF";
  document.getElementById(field).style.backgroundColor = color;
  document.getElementById(field+"_required").style.visibility = "hidden";
  
}

function focusOn(field){
  
  var color1 = "#7F9DB9 1px solid";

  document.getElementById("azienda").style.border = color1;
  document.getElementById("riferimento").style.border = color1;
  document.getElementById("telefono").style.border = color1;
  document.getElementById("email").style.border = color1;
  document.getElementById("richieste").style.border = color1;
  document.getElementById("privacy").style.border = color1;

  var color2 = "#000000 1px solid";
  document.getElementById(field).style.border = color2;

}







function aa(id){

  document.getElementById("img_mondo").style.display = "none";
  document.getElementById("img_italia").style.display = "none";
  document.getElementById("img_europa").style.display = "none";
  document.getElementById("img_extra").style.display = "none";
  
  document.getElementById("lista_italia").style.display = "none";
  document.getElementById("lista_europa").style.display = "none";
  document.getElementById("lista_extra").style.display = "none";


  if (id == "italia"){
      document.getElementById("lista_italia").style.display = "block";
      document.getElementById("img_italia").style.display = "block";
  }
  else if (id == "europa"){
      document.getElementById("lista_europa").style.display = "block";
      document.getElementById("img_europa").style.display = "block";
  }
  else if (id == "extra"){
      document.getElementById("lista_extra").style.display = "block";
      document.getElementById("img_extra").style.display = "block";
  }
}



function bb(id){

	document.getElementById("img_italia").src = "modules/Agenti/images/"+id+".jpg";

	if (id == "cartina-italia-1")
		document.getElementById("lista_italia").innerHTML = "PIEMONTE - LOMBARDIA";
	else if (id == "cartina-italia-2")
		document.getElementById("lista_italia").innerHTML = "VENETO";
	else if (id == "cartina-italia-3")
		document.getElementById("lista_italia").innerHTML = "MARCHE - UMBRIA";
	else if (id == "cartina-italia-4")
		document.getElementById("lista_italia").innerHTML = "LAZIO";	
	else if (id == "cartina-italia-5")
		document.getElementById("lista_italia").innerHTML = "";

}


function cc(){

  document.getElementById("img_italia").src = "modules/Agenti/images/cartina-italia-0.jpg";
	
}
