// JavaScript Document
function validaEmail(email) 
{ 
	var er_Correo_electronico_usuario = /^(.+\@.+\..+)$/
	//comprueba campo de email
	if (email.value != "")	{
		if(!er_Correo_electronico_usuario.test(email.value)) { 
			email.value='';
			email.focus();
			email.select();
			return false
		}
	}
	return true; 
}
function chkRut(rut)
{
       var miString = "";
       miString=rut.value;
       if (miString!="")
       {
               var result = "";
               var dv1="";
               if (miString.length <= 3)
               {
                       alert("Rut Incompleto");
                       rut.focus();
                       return false;
               }
               for (i=0;i<miString.length-1;i++)
               {
                       if (miString.charAt(i)!="." && miString.charAt(i)!="-")
                       {
                               result+=miString.charAt(i);
                       }
               }
               dv1 = miString.charAt(i);
	       if (dv1=="K" || dv1=="k")
	       {
	       		dv1="k";
	       }
               if (dv1 != dv(result))
               {
                       alert("Rut Incorrecto");
                       rut.focus();
                       return false;
               }
               rut.value = result + "-" + dv1
       }
}
function dv(T)
{
       var M=0,S=1, valor=T;
       for(;T;T=Math.floor(T/10))
               S=(S+T%10*(9-M++%6))%11;

       return S?S-1:'k';
}
function Enter()
{
   if (event.keyCode==13)
   {
	event.keyCode=9;
   }
}

function EvaluateText(cadena, obj, e){
    opc = false;    
    tecla = (document.all) ? e.keyCode : e.which;    
    if (tecla==13 || tecla==9 || tecla==8)
    {
        opc = true;
    }
    if (cadena == "%n") // Solo Numeros
    {       
        if (tecla > 47 && tecla < 58)
        {
            opc = true;
        }
    }    
    if (cadena == "%d") // Solo Decimal
    {
        if (tecla > 47 && tecla < 58)
        {
            opc = true;
        }
        else
        {
           if (tecla == 46)
           {
              opc = true;
           }        

        }
    }       
    return opc;
}

