function validaremail(valor)
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d)\.(\d)\.(\d)\.(\d)\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
	var matchArray= valor.match(emailPat)
	if (matchArray==null) {
		$("#mensaje").html("La entrada de e-mail parece ser incorrecta, compruebe haber escrito el @ y el .");
		$(".mensaje" ).dialog({modal: true, buttons: { "Aceptar": function() { $(this).dialog("close"); $("#email").focus();} }});
		//alert("La entrada de e-mail parece ser incorrecta, chequee el @ y el .")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	if (user.match(userPat)==null) {
		$("#mensaje").html("El nombre de email parace no ser correcto");
		$(".mensaje" ).dialog({modal: true, buttons: { "Aceptar": function() { $(this).dialog("close"); $("#email").focus();} }});
		//alert("El nombre de email parace no ser correcto.")
		return false
	}
	
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				$("#mensaje").html("La direccion IP del e-mail no parece valida");
				$(".mensaje" ).dialog({modal: true, buttons: { "Aceptar": function() { $(this).dialog("close"); $("#email").focus();} }});
				//alert("Direccion IP no valida!")
			return false
			}
		}
		return true
	}
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		$("#mensaje").html("El nombre de dominio del email, parace no ser correcto");
		$(".mensaje" ).dialog({modal: true, buttons: { "Aceptar": function() { $(this).dialog("close"); $("#email").focus();} }});
		//alert("El nombre de dominio del email, parace no ser correcto.")
		return false
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
		domArr[domArr.length-1].length>4) {
		$("#mensaje").html("La direccion de correo debe acabar en 3 o 4 letras de dominio, o 2 si es de un pais");
		$(".mensaje" ).dialog({modal: true, buttons: { "Aceptar": function() { $(this).dialog("close"); $("#email").focus();} }});
	   //alert("La direccion de correo debe acabar en 3 o 4 letras de dominio, o 2 si es de un pais.")
	   return false
	}
	
	if (len<2) {
		$("#mensaje").html("Esta direccion es desconocida como IP");
		$(".mensaje" ).dialog({modal: true, buttons: { "Aceptar": function() { $(this).dialog("close"); $("#email").focus();} }});
	   //alert(errStr)
	   return false
	}
	return true;
}


function LimitAttach(tField,iType)
{
	file=tField;
	if (iType==1) {
		extArray = new Array(".gif",".jpg",".png",".jpeg",".bmp");
	}
	if (iType==2) {
		extArray = new Array(".pdf",".doc",".rtf",".odt");
	}
	allowSubmit = false;
	if (!file) return true;

	while (file.indexOf("\\") != -1) file = file.slice(file.indexOf("\\") + 1);
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) {
			allowSubmit = true;
			break;
		}
	}
	if (!allowSubmit)
	{
		$("#mensaje").html("Usted sólo puede subir archivos con extensiones " + (extArray.join(" ")) + "\nPor favor seleccione un nuevo archivo");
		$(".mensaje" ).dialog({modal: true, buttons: { "Aceptar": function() { $(this).dialog("close"); } }});
	}
	return allowSubmit;
}


