

        function registra(nome,email){

                 validEmail = validar(email);



                 if(validEmail == true){

                 window.open('cadastra.php?email='+email+'&nome='+nome,'Registro','toolbar=0,location=0,status=0,resizable=1,width=300,height=290');

                 }

        }





function validar(valor) {



     var emailStr = valor;



        // define user@domain pattern

        var emailPat=/^(.+)@(.+)$/

        // define special characters ( ) < > @ , ; : \ " . [ ]

        var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

        // define invalid characters

        var validChars="\[^\\s" + specialChars + "\]"

        // quoted user string can contain any characters

        var quotedUser="(\"[^\"]*\")"

        // domain is specified as an IP address (in brackets)

        var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

        // atomize strings of valid characters

        var atom=validChars + '+'

        // The following string represents one word in the typical username.

        // (For example, in john.doe@somewhere.com, john and doe are words)

        var word="(" + atom + "|" + quotedUser + ")"

        // The following pattern describes the structure of the user

        var userPat=new RegExp("^" + word + "(\\." + word + ")*$")



        // The following pattern describes the structure of a normal symbolic domain

        var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")



        /* Finally, let's start trying to figure out if the supplied address is

           valid. */



        var validEmail=true;

        // See if email address matches normal email address pattern

        var matchArray=emailStr.match(emailPat)

        if (matchArray==null) {

            validEmail=false;

            alert(emailStr+" não é um e-mail válido");

        }

        if (validEmail) {

            var user=matchArray[1]

            var domain=matchArray[2]

            // See if "user" is valid

            if (user.match(userPat)==null) {

              alert(emailStr+" não é um e-mail válido");

                validEmail=false;

            }

        }

        if (validEmail) {

            // Validate domain

            var IPArray=domain.match(ipDomainPat);

            if (IPArray!=null) {

           // this is an IP address

                for (var i=1;i<=4;i++) {

                    if (IPArray[i]>255) {

                        alert(emailStr+" não é um e-mail válido");

                        validEmail=false;



                    }

                }



            } else {



                // Domain is symbolic name

        var domainArray=domain.match(domainPat);

           if (domainArray==null) {

             alert(emailStr+" não é um e-mail válido");

             validEmail=false;

                }



                if (validEmail) {

                    // Make sure there's a host name preceding the domain.

                    var atomPat=new RegExp(atom,"g")

                    var domArr=domain.match(atomPat)

					  var len=domArr.length;

         if (len<2) {

                 validEmail=false;

                 alert(emailStr+" não é um e-mail válido");

                    }

                }

            }



        }

        return validEmail

    	}//end of function validateEmail
