    function mail(texto){

            var mailres = true;
            var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";

            var arroba = texto.indexOf("@",0);
            if ((texto.lastIndexOf("@")) != arroba) arroba = -1;

            var punto = texto.lastIndexOf(".");

             for (var contador = 0 ; contador < texto.length ; contador++){
                if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
                    mailres = false;
                    break;
             }
            }

            if ((arroba > 1) && (arroba + 1 < punto) && (punto + 2 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
             mailres = true;
            else
             mailres = false;

            return mailres;
        }


function RevisarFormContacto()

    {

            var Nombre;
            var Email;
            var Comentarios;
            var MsgError;
            var Error;

            

            Nombre=document.getElementById("nombre").value;
            Email=document.getElementById("email").value;
            Comentarios=document.getElementById("comentarios").value;

            

            MsgError="ATENCION: Atoparonse os seguintes erros: \n";

            if (Nombre=="")

                    {
                            Error=1
                            MsgError=MsgError + "- Debe especificar un nome\n";
                    }

           if (Email=="")
				{
					Error=1
					MsgError=MsgError + "- Debe especificar un email\n";
				}
                        else
                                {

                                    ComprobarMail=mail(Email)

                                    if (ComprobarMail==false)

                                        {
                                            Error=1
                                            MsgError=MsgError + "- O email non e correcto\n";

                                        }

                                }

            if (Comentarios=="")
                    {
                            Error=1
                            MsgError=MsgError + "- Debe escribir o seu motivo de consulta\n";
                    }

            if (Error==1)
                    {
                            alert (MsgError);
                    }
            else
                    {
                            document.getElementById("FormContacto").submit();
                    }
    }

