function confirmar ( mensaje ) {
	return confirm( mensaje );
	}


      function validarCampos(){
            var name=document.getElementById('name').value;
            var mail=document.getElementById('mail').value;
            var friendname=document.getElementById('friendname').value;
            var friendmail=document.getElementById('friendmail').value;
            var procesa=false;
            if(name.length>0 && mail.length>0){


            if(validarAlfanumerico(name)){
                if(validarMail(mail)){
                    if(friendname.length>0 && friendmail.length>0){
                        //si lleno los campos de su amigo los validamos
                        if(validarAlfanumerico(friendname)){
                            if(validarMail(friendmail)){
                                procesa=true;
                            }else{
                                alert('El e-mail de su amigo es incorrecto.');

                            }
                        }else{
                            alert('Verifique el NOmbre de su amigo');

                        }
                    }else{
                        procesa=true;
                    }
                    if(procesa){
                        var formy=document.getElementById("formy");
			formy.submit();

                    }
                }else{
                    alert('Su e-mail es incorrecto');

                }
            }else{
                alert('Verifique su Nombre');

            }


            }else{
                alert('Debe ingresar sus datos primero.');

            }
        }

        function validarMail(elmail){
            var mailxpression=/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@+([_a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,200}\.[a-zA-Z]{2,6}$/;
                if ((elmail.match(mailxpression))){
               return true;

		}else {
                    return false;
		}
        }

        function validarAlfanumerico(lacadena){

        var validos = " abcdefghijklmnopqrstuvwxyzñ0123456789ABCDEFGHIJKLMNÑOPQRSTVUXYZ";
        var letra;
        var bien = true;
         for (var i=0; i<lacadena.length; i++) {
            letra=lacadena.charAt(i);
                if(validos.indexOf(letra)==-1){bien=false;}
                 }

                               if (!bien) {

                            return false;

                           }else{
                               return true;
                           }

        }



