function grabar()
{
 variables = $("#Formu").serialize();
 //alert(variables);
$.ajax({
        type: "POST",
        url: "Proceso_guardaface.php",
        data: variables,
        success: function(datos){
       alert(datos);
      }
	  });
}

function grabar_usu()
{
 	val = document.getElementById("val1").value;
	n = document.getElementById("Nombre").value;
	m = document.getElementById("Mail").value;
	ms1=document.getElementById("mensje3").style.display;
	ms2=document.getElementById("mensje2").style.display;
	ms3=document.getElementById("mensje1").style.display;
	ms4=document.getElementById("sex_val").style.display;
	ms5=document.getElementById("comuna_val").style.display;
	m1 = document.getElementById("masculino").checked;
        f = document.getElementById("Femenino").checked;
	
	if( document.Formu_user.Comuna.selectedIndex==0)
	{
            document.getElementById("comuna_val").style.display="inline"; 
        }
          else
        {
            document.getElementById("comuna_val").style.display="none";    
        }
	
	       if((m1)||(f))
           {
                 document.getElementById("sex_val").style.display="none";     
           }
      else
            {
                document.getElementById("sex_val").style.display="inline";
                
            }
            
	if (n=="Nombre y Apellido")
	{
		alert("No ha superado alguna validacion, favor de revisar su Informacion");
		document.getElementById("Nombre").focus();
		return false;
	}
	
     
	if (m=="Email")
	{
		alert("No ha superado alguna validacion, favor de revisar su Informacion");
		document.getElementById("Mail").focus();
		return false;
	}
	if (document.getElementById("dia")==0){alert("Favor de Ingresar correctamente su Fecha de Nacimiento"); return false;}
	if (document.getElementById("mes")==0){alert("Favor de Ingresar correctamente su Fecha de Nacimiento"); return false;}
	if (document.getElementById("anio")==0){alert("Favor de Ingresar correctamente su Fecha de Nacimiento"); return false;}
	
	if(val>0 || n=="" || m==""  || ms1=="inline" || ms2=="inline" || ms3=="inline"|| ms4=="inline")
	{
		alert("No ha superado alguna validacion, favor de revisar su Informacion");
	}
	else
	{
		variables = $("#Formu_user").serialize();
		//alert(variables);
		$.ajax({
			type: "POST",
			url: "Proceso_guardausu.php",
			data: variables,
			success: function(datos65){
		    //alert(datos);
			datos=datos65.split("|_|");
			if (datos[0]==1)
			{
				alert("Registro Exitoso");
				//location.reload();
				pagina="saludo_bienvenido2.php?&usuario="+datos[1];
				location.href=pagina;
				return false;
			}
			if (datos[0]==5)
			{
				alert("Existe un usuario con ese correo, favor de usar otro correo");
				location.reload();
				return false;
			}
		  }
		  });

	}
}
function valida_usu()
{
	usu=document.getElementById("user").value;	
	pass=document.getElementById("pass").value;	
	variables_log="&usu="+usu+"&pass="+pass;
	$.ajax({
        type: "POST",
        url: "login_proceso.php",
        data: variables_log,
        success: function(datos){
       //aert(datos);
		if (datos!="") 
		    if (datos!=5)
		    {
			 dire="/saludo_bienvenido2.php?&usuario="+datos;
			 location.href=dire;
			}
			else
			{
				alert("Usuario o clave Incorecta");	
			}
      }
	  });
}
