function nuevoAjax(){
var xmlhttp=false;
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

function enviarMail(){
	c = document.getElementById('resultados');
	
	//variable=documenet.nombre_del_form.nombre_del_control.value
	nom=document.test.field1.value;
	emp=document.test.field2.value;
	correo=document.test.field4.value;
	tel=document.test.field5.value;
	com=document.test.field6.value;
	
	ajax=nuevoAjax();
	if ((nom=="") || (correo=="") || (tel=="") || (com=="")){
		alert("Complete los campos por favor...");
	}else {
	c.innerHTML = '<p style="text-align:center;"><img src="esperando.gif"/></p>'; 
	ajax.open("POST", "email.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			c.innerHTML = ajax.responseText
		}
		borrarCampos()
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("nombre="+nom+"&empresa="+emp+"&email="+correo+"&telefono="+tel+"&comentario="+com);
	}
	
}

function borrarCampos(){
	nom=document.test.field1.value="";
	emp=document.test.field2.value="";
	correo=document.test.field4.value="";
	tel=document.test.field5.value="";
	com=document.test.field6.value="";
	valid.reset();
}