
function formCheck (emailStr, nombreStr, msgStr) {

    var checkTLD=1;

    var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

    var emailPat=/^(.+)@(.+)$/;

    var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

    var validChars="\[^\\s" + specialChars + "\]";

    var quotedUser="(\"[^\"]*\")";

    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

    var atom=validChars + '+';

    var word="(" + atom + "|" + quotedUser + ")";

    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

    var matchArray=emailStr.match(emailPat);

    if (matchArray==null) {

    document.getElementById('mensajeError').innerHTML = "Su correo no aparece o es incorrecto.";

    return false;

    }

    var user=matchArray[1];

    var domain=matchArray[2];

    for (i=0; i<user.length; i++) {

    if (user.charCodeAt(i)>127) {

   document.getElementById('mensajeError').innerHTML = "Su correo no es correcto.";

    return false;

       }

    }

    for (i=0; i<domain.length; i++) {

    if (domain.charCodeAt(i)>127) {

    document.getElementById('mensajeError').innerHTML = "El dominio de la direccion introducida contiene caracteres incorrectos.";

    return false;

       }

    }

    if (user.match(userPat)==null) {

    document.getElementById('mensajeError').innerHTML = "El correo parece incorrecto.";

    return false;

    }

    var IPArray=domain.match(ipDomainPat);

    if (IPArray!=null) {

    for (var i=1;i<=4;i++) {

    if (IPArray[i]>255) {

    document.getElementById('mensajeError').innerHTML = "La direccion IPInternet Protocol de destino no es correcta!";

    return false;

       }

    }

    return true;

    }

    var atomPat=new RegExp("^" + atom + "$");

    var domArr=domain.split(".");

    var len=domArr.length;

    for (i=0;i<len;i++) {

    if (domArr[i].search(atomPat)==-1) {

    document.getElementById('mensajeError').innerHTML = "El email parece incorrecto, por favor compruebelo, incluyendo el uso incorrecto de signos, comas , o puntos [.] al final del mismo.";

    return false;

       }

    }

    if (checkTLD && domArr[domArr.length-1].length!=2 &&

    domArr[domArr.length-1].search(knownDomsPat)==-1) {

    document.getElementById('mensajeError').innerHTML = "Su email debe terminar en un dominio o dos letras " + "pais.";

    return false;

    }

    if (len<2) {

    document.getElementById('mensajeError').innerHTML = "Falta el nombre del host en su email - compruebelo. O puede haber un espacio en blanco al final del mismo - corrija el error e vuelva a intentarlo.";

    return false;

    }
	if ((msgStr=="Mensaje")||(msgStr=="") ||(msgStr==null)){
		document.getElementById('mensajeError').innerHTML = "Por favor, introduzca el motivo de su consulta.";

    return false;
	}
	
	if ((nombreStr=="Nombre")||(nombreStr=="") ||(nombreStr==null)){
		document.getElementById('mensajeError').innerHTML = "Por favor, introduzca su nombre.";

    return false;
	}
   
	
	document.getElementById('mensajeError').innerHTML = "Espere unos instantes mientras enviamos su mensaje.";
	

	
	return true;

    }
	
	function mensajeEnviado(){
		history.go(-1);
		document.getElementById('mensajeError').innerHTML ="Gracias por contactar con el Dr. Monreal. <br/>Su mensaje ha sido enviado, usando la dirección introducida en el formulario.";
		
		}
	function mensajeNoEnviado(){}

