        //Escribe la fecha del dia
        function fecha(){
                today = new Date()
                day = today.getDay()
                if (day == 0){
                        document.write("Domingo ");
                }
                if (day == 1){
                        document.write("Lunes ");
                }
                if (day == 2){
                        document.write("Martes ");
                }
                if (day == 3){
                        document.write("Miércoles ");
                }
                if (day == 4){
                        document.write("Jueves ");
                }
                if (day == 5){
                        document.write("Viernes ");
                }
                if (day == 6){
                        document.write("Sábado ");
                }
                today = new Date()
                hours = today.getHours()
                minutes = today.getMinutes()
                year = parseInt(today.getYear(),10)

                zerom = ''
                zeroh = ''

                if (minutes < 10) {zerom = 0}
                if (hours < 10) {zeroh = 0}

                if (today.getMonth() == 0) {month = "Enero"}
                if (today.getMonth() == 1) {month = "Febrero"}
                if (today.getMonth() == 2) {month = "Marzo"}
                if (today.getMonth() == 3) {month = "Abril"}
                if (today.getMonth() == 4) {month = "Mayo"}
                if (today.getMonth() == 5) {month = "Junio"}
                if (today.getMonth() == 6) {month = "Julio"}
                if (today.getMonth() == 7) {month = "Agosto"}
                if (today.getMonth() == 8) {month = "Septiembre"}
                if (today.getMonth() == 9) {month = "Octubre"}
                if (today.getMonth() == 10) {month = "Noviembre"}
                if (today.getMonth() == 11) {month = "Diciembre"}
                if (today.getYear() == 99) {year = "1999"}
                if (today.getYear() == 0 || today.getYear() == 100 || today.getYear() == 2000) {year = "2000"}
                document.write( today.getDate()," de ",month,",  ",year);
        }

        ////////////  Conjunto de funciones Validadores de Correo  /////////////////////
        //<input type="text" name="..algo_referente_al_email.." onblur="ValidaCorreo(this)"
        var whitespace = " \t\n\r";

        function isEmpty(s){
                return ((s == null) || (s.length == 0))
        }

        function isWhitespace (s){
                var i;

                if (isEmpty(s)) return true;
                for (i = 0; i < s.length; i++){
                        var c = s.charAt(i);
                        if (whitespace.indexOf(c) == -1)return false;
                }
                return true;
        }

        function isEmail(correo) {
                value = correo.value
                var largo= value.length;
                var pt1=0;
                var pt2=0;
                var pt3=0;
                var arro=0;

                if (value == "")
                        return false;

                for(i=0;i<largo;i++){
                        c=value.charAt(i);
                        if (c=="@"){
                                if (arro == 0 && i != 0 && i < (largo - 5))
                                        arro=i;
                                else{
                                        alert("Incorrect Email")
                                        correo.select();
                                        correo.focus();
                                        return false;
                                }
                        }
                        else
                                if (c=="."){
                                        if ((pt1 == 0) && (i > 2)  && (i < (largo - 2)))
                                                pt1=i;
                                        else
                                                if((pt2 == 0) && (i > (pt1+2)) && (pt1 > 0) && (i < (largo - 2)))
                                                        pt2 = i;
                                                else
                                                        if((pt3 == 0) && (i > (pt2+2))  && (pt2 > 0) && (i < (largo - 2)))
                                                                pt3 = i;
                                                        else{
                                                                alert("Incorrect Email")
                                                                correo.select();
                                                                correo.focus();
                                                                return false;
                                                        }
                                }
                                else
                                if((c=="%") || (c == "#") || (c == "$") || (c == "&") || (c == "/") || (c == "?") || (c == "¡") || (c == "!") || (c == ";") || (c == ",") || (c == "+") || (c == "=") || (c == "<")  || (c == ">") || (c == "|") || (c == "`") || (c == "'") || (c == "'") || (c == "{") || (c == "}") || (c == " ")){
                                        alert("Incorrect Email")
                                        correo.select();
                                        correo.focus();
                                        return false;
                                }
                        }
                        if((arro >= 3) && (arro < (largo-5)))
                                if((pt1 > 1)  && (pt1 < (largo-2)))
                                        if (pt2 > pt1)
                                                if (pt3 > pt2)
                                                        if (arro > pt3){
                                                                alert("Incorrect Email")
                                                                correo.select();
                                                                correo.focus();
                                                                return false;
                                                        }
                                                        else
                                                                return true;
                                                else
                                                        if (arro > pt2){
                                                                alert("Incorrect Email")
                                                                correo.select();
                                                                correo.focus();
                                                                return false;
                                                        }
                                                        else
                                                                return true;
                                        else
                                                if (arro > pt1){
                                                        alert("Incorrect Email")
                                                        correo.select();
                                                        correo.focus();
                                                        return false;
                                                }
                                                else
                                                        return true;
                                else{
                                        alert("Incorrect Email")
                                        correo.select();
                                        correo.focus();
                                        return false;
                                }
                        else{
                                alert("Incorrect Email")
                                correo.select();
                                correo.focus();
                                return false;
                        }
        }

        function ValidaCorreo(obj_email){
                if (isEmpty(obj_email.value))
                        if (ValidaCorreo.arguments.length == 1)
                                return false;
                        else
                                return (ValidaCorreo.arguments[1] == true);

                if (isWhitespace(obj_email.value))return false;

                var i = 1;
                var sLength = obj_email.value.length;

                // busca @
                while ((i < sLength) && (obj_email.value.charAt(i) != "@")){
                        i++
                }

                if ((i >= sLength) || (obj_email.value.charAt(i) != "@")){
                        alert("Incorrect Email");
                        obj_email.focus();
                        obj_email.select();
                        return false;
                }
                else
                        i += 2;

                // busca .
                while ((i < sLength) && (obj_email.value.charAt(i) != ".")){
                        i++
                }

                // Debe haber al menos un caracter despues del .
                if ((i >= sLength - 1) || (obj_email.value.charAt(i) != ".")){
                        alert("Incorrect Email");
                        obj_email.focus();
                        obj_email.select();
                        return false;
                }
                else
                        return true;
        }
        ////////////  Fin Conjunto de funciones Validadores de Correo  /////////////////////

        ////////////  Conjunto de Funciones Validadoras de Rut  ////////////////////////
        //  Analiza los campos de Rut y DV, para ver si es un RUT valido
        //  recomendado usar en la casilla del DV
        //  <input type="text" name="..algo_referente_al_DV.." onblur="checkRutField(document.form.rut,this)"

        function checkDV(obj_rut,obj_dv){
                texto = obj_rut.value + obj_dv.value
                var tmpstr = "";
                for (i=0; i < texto.length ; i++)
                        if (texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-')
                                tmpstr = tmpstr + texto.charAt(i);
                texto = tmpstr;

                largo = texto.length;
                if (largo < 2){
                        alert("Debe ingresar el RUT completo.")
                        obj_rut.focus();
                        obj_rut.select();
                        return false;
                }

                if (largo > 2)
                        rut = texto.substring(0, largo - 1);
                else
                        rut = texto.charAt(0);
                dv = texto.charAt(largo-1);
                if (!checkCDV(dv)){
                        alert("Debe ingresar un dígito verificador válido.");
                        obj_dv.focus();
                        obj_dv.select();
                }

                if (rut == null || dv == null)
                        return 0
                var dvr = '0'

                suma = 0
                mul  = 2

                for (i= rut.length -1 ; i >= 0; i--){
                        suma = suma + rut.charAt(i) * mul
                        if (mul == 7)
                                mul = 2
                        else
                                mul++
                }

                res = suma % 11
                if (res==1)
                        dvr = 'k'
                else if (res==0)
                                dvr = '0'
                        else{
                                dvi = 11-res
                                dvr = dvi + ""
                        }

                if (dvr != dv.toLowerCase()){
                        alert("EL RUT es incorrecto.");
                        obj_rut.select();
                        obj_rut.value = "";
                        obj_dv.value = "";
                        obj_rut.focus();
                        return false;
                }
                return true
        }

        function checkCDV( dvr ){
                dv = dvr + ""
                if (dv != '0' && dv != '1' && dv != '2' && dv != '3' && dv != '4' && dv != '5' && dv != '6' && dv != '7' && dv != '8' && dv != '9' && dv != 'k'  && dv != 'K'){
                        return false;
                }
                return true;
        }

        function checkRutField(obj_rut,obj_dv){
                //Quitar Ceros
                var auxRut=obj_rut.value;
                var auxLargo=auxRut.length;
                if (auxLargo>1){
                        while ((auxRut.substring(0,1)=="0") || (auxRut.substring(0,1)==".")){
                                auxRut=auxRut.substring(1,auxLargo);
                                auxLargo=auxRut.length
                        }
                }
                obj_rut.value=auxRut;
                  //Fin Quitar Ceros

                texto = obj_rut.value + obj_dv.value

                var tmpstr = "";
                  if ((obj_rut.value==0)&&(obj_dv.value==0)){
                        alert("El RUT no es válido.");
                        obj_rut.value="";
                        obj_dv.value = "";
                        obj_rut.focus();
                        return false;
                }
                for ( i=0; i < texto.length ; i++ )
                        if ( texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' )
                                tmpstr = tmpstr + texto.charAt(i);
                texto = tmpstr;
                largo = texto.length;
                if (largo < 2){
                        alert("Debe ingresar el RUT completo.")
                        obj_rut.select();
                        obj_dv.value = "";
                        obj_rut.focus();
                        return false;
                }
                for (i=0; i < largo ; i++ ){
                        if (texto.charAt(i) !="0" && texto.charAt(i) != "1" && texto.charAt(i) !="2" && texto.charAt(i) != "3" && texto.charAt(i) != "4" && texto.charAt(i) !="5" && texto.charAt(i) != "6" && texto.charAt(i) != "7" && texto.charAt(i) !="8" && texto.charAt(i) != "9" && texto.charAt(i) !="k" && texto.charAt(i) != "K" ){
                                alert("El valor ingresado no corresponde a un RUT válido.");
                                obj_dv.value = "";
                                obj_dv.focus();
                                return false;
                        }
                }
                if (obj_dv.value == "k"){
                        obj_dv.value="K"
                }
                if (checkDV(obj_rut,obj_dv))
                        return true;
                return false;
        }

        //  Funcion que agrega los puntos en el RUT del usuario y cualqueir casilla que maneje numeros
        //  <input type="text" name="..nombre_referente_al_rut.." onblur="puntosEnRut(this)"
        function puntosEnNumero(obj_rut){
                var invertido = "";
                var texto="";
                var tmpstr="";

                texto=obj_rut.value
                largoRut=texto.length

                for ( i=0; i < largoRut ; i++ ){
                        if ( texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' )
                        {
                                tmpstr = tmpstr + texto.charAt(i);
                        }
                }
                texto = tmpstr;
                largoRut=texto.length

                for ( i=(largoRut-1),j=0; i>=0; i--,j++ ){
                  invertido = invertido + texto.charAt(i);
                }
                var dtexto = "";
                cnt = 0;

                for (i=0,j=1; i<largoRut; i++,j++){
                        if (cnt == 3){
                                dtexto = dtexto + '.';
                                j++;
                                dtexto = dtexto + invertido.charAt(i);
                                cnt = 1;
                        }
                        else{
                                dtexto = dtexto + invertido.charAt(i);
                                cnt++;
                        }
                }

                invertido = "";

                for (i=(dtexto.length-1),j=0; i>=0; i--,j++)
                        if (dtexto.charAt(i) == "k")
                                invertido = invertido + "K";
                        else
                                invertido = invertido + dtexto.charAt(i);
                obj_rut.value = Trim(invertido);
        }

        function ponerPuntosEnNumero(valor){
                var invertido = "";
                var texto="";
                var tmpstr="";

                texto=valor + "";
                largoRut=texto.length

                for ( i=0; i < largoRut ; i++ ){
                        if ( texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' )
                        {
                                tmpstr = tmpstr + texto.charAt(i);
                        }
                }
                texto = tmpstr;
                largoRut=texto.length

                for ( i=(largoRut-1),j=0; i>=0; i--,j++ ){
                  invertido = invertido + texto.charAt(i);
                }
                var dtexto = "";
                cnt = 0;

                for (i=0,j=1; i<largoRut; i++,j++){
                        if (cnt == 3){
                                dtexto = dtexto + '.';
                                j++;
                                dtexto = dtexto + invertido.charAt(i);
                                cnt = 1;
                        }
                        else{
                                dtexto = dtexto + invertido.charAt(i);
                                cnt++;
                        }
                }

                invertido = "";

                for (i=(dtexto.length-1),j=0; i>=0; i--,j++)
                        if (dtexto.charAt(i) == "k")
                                invertido = invertido + "K";
                        else
                                invertido = invertido + dtexto.charAt(i);
                return (Trim(invertido));
        }
        ////////////  Fin Conjunto de Funciones Validadoras de Rut  ////////////////////////


        //  Elimina los espacios sobrantes al principio y al final de un String
        //  var nombre_variable_sin_espacios = Trim(..variable_con_espacios..)
        function Trim(strTxt){
                pos1 = 0;
                pos2 = strTxt.length-1;
                for (i=0; i<strTxt.length; i++){
                        if (strTxt.charAt(i) == ' ') pos1 = pos1 + 1;
                        else break;
                }
                if (pos1 != (pos2+1)){
                        for (i=strTxt.length-1; i>0; i--){
                                if (strTxt.charAt(i) == ' ') pos2 = pos2 - 1
                                else break;
                        }
                }
                return strTxt.substring(pos1,pos2+1);
        }


        // Verifica si una casilla posee el largo minimo estipulado
        function largoVar(obj_txt,largo_min){
                var bool = (obj_txt.value.length >= largo_min)?true:false;
                return bool
        }

        ///////////  Valida si una expresion es un Numero Valido
        function esNumero(numero){
                //numero = Trim(numero)
                if (isNaN(numero.value)){
                        alert("Casilla con Caracter no Valido")
                        numero.focus();
                        numero.value = "";
                        return false;
                }
                nNumero = new Number(sacaPuntos(numero.value))
                var numeroLength = numero.value.length;
                for (i = 0; i < numeroLength; i++) {
                        var aChar = numero.value.substring(i,i+1);
                        if (aChar == " ") return false;
                }
                if ((nNumero == "") && (numeroLength != 0) && (nNumero != 0)){
                        alert("No es un numero Valido")
                        numero.focus();
                        numero.value = "";
                        return false;
                }
                return true;
        }

        /////////////  Combinacion de funciones para determinar si un numero es Entero
        function validValue(value,validchars,casesensitive){
                if (casesensitive!=1) {
                        value=value.toUpperCase();
                        validchars=validchars.toUpperCase();
                }
                var charposn=0;
                while((charposn<value.length)&&(validchars.indexOf(value.charAt(charposn))!=-1))
                {
                        charposn++;
                }
                if (charposn==value.length) {
                        return true;
                } else {
                        return false;
                }
        }

        function esEntero(x){
                if (validValue(x,"1234567890",0)) {
                        return true;
                } else {
                        return false;
                }
        }
        /////////////  FIN  Combinacion de funciones para determinar si un numero es Entero



        //  Valida si un nuemro es mayor que cero
        function esNumeroPos(numero){
                //numero = Trim(numero)
                nNumero = new Number(sacaPuntos(numero.value))
                if (isNaN(nNumero)){
                        alert("Casilla con Caracter no Valido")
                        numero.focus();
                        numero.value = "";
                        return false;
                }
                if (nNumero < 0){
                        alert("Debe ingresar un valor mayor que cero")
                        numero.focus();
                        numero.value = "";
                        return false;
                }
                var numeroLength = numero.value.length;
                for (i = 0; i < numeroLength; i++) {
                        var aChar = numero.value.substring(i,i+1);
                        if (aChar == " ") return false;
                }
                if ((nNumero == "") && (numeroLength != 0) && (nNumero != 0)){
                        alert("No es un numero Valido")
                        numero.focus();
                        numero.value = "";
                        return false;
                }
                return true;
        }



        ///////////  Valida si una expresion es Alfanumerico
        function esAlfanumerico(Expression){
                Expression2 = Expression.value.toLowerCase();
                RefString = "abcdefghijklmnñopqrstuvwxyz0123456789/#Ñº. ";
                var bool = true
                for (var i = 0; i < Expression2.length; i++){
                        var ch = Expression2.substr(i, 1)
                        var a = RefString.indexOf(ch, 0)
                        if (a == -1) {
                                bool = false;
                        }
                }
                if ((!bool) && (!isEmpty(Expression.value))){
                        alert("Caracter No valido")
                        Expression.value = "";
                        Expression.select();
                        Expression.focus();
                        return false
                }
                return true;
        }
		/// valida direccion solamente letras numeros y caracteres aceptados //////////
		function esDireccion(Expression){
                Expression2 = Expression.value.toLowerCase();
                RefString = "abcdefghijklmnñopqrstuvwxyz0123456789#º/.Ñ ";
                var bool = true
                for (var i = 0; i < Expression2.length; i++){
                        var ch = Expression2.substr(i, 1)
                        var a = RefString.indexOf(ch, 0)
                        if (a == -1) {
                                bool = false;
                        }
                }
                if ((!bool) && (!isEmpty(Expression.value))){
                        alert("Caracter No valido")
                        Expression.value = "";
                        Expression.select();
                        Expression.focus();
                        return false
                }
                return true;
        }
		//////////////////// fin validacion de direcion ///////////////////////////
        /// funcion que valida que pueda ser cualquier cosa menos caracteres no validos
        function esString(Expression){
                Expression2 = Expression.value.toLowerCase();
                RefString = "abcdefghijklmnñopqrstuvwxyz0123456789./ ";
                RefString += "ÇüñÑ"
                RefString += "áéíóúÁÉÍÓÚ"
                RefString += "âäåçêëèï"
                RefString += "îìÄÅæÆôöò"
                RefString += "ûùÖÜ£ "
                RefString += ".:,\"\""
                RefString += "(-)"
                RefString += "\t\n\r"

                var bool = true
                for (var i = 0; i < Expression2.length; i++){
                        var ch = Expression2.substr(i, 1)
                        var a = RefString.indexOf(ch, 0)
                        if (a == -1) {
                                bool = false;
                        }
                }
                if ((!bool) && (!isEmpty(Expression.value))){
                        alert("Caracter No valido")
                        Expression.value = "";
                        Expression.select();
                        Expression.focus();
                        return false
                }
                return true;
        }

        ///////////  Valida si una expresion es un Telefono Valido
        function esTelefono(Expression){
                Expression2 = Expression.value.toLowerCase();
                RefString = "()-0123456789";
                var bool = true
                for (var i = 0; i < Expression2.length; i++){
                        var ch = Expression2.substr(i, 1)
                        var a = RefString.indexOf(ch, 0)
                        if (a == -1)  {
                                bool = false;
                        }
                }
                if ((!bool) && (!isEmpty(Expression.value))){
                        alert("Caracter No valido")
                        Expression.value = "";
                        Expression.select();
                        Expression.focus();
                        return false
                }
                return true;
        }

        /////  Verifica si una expresion es una letra valida, letras mas espacio
        function esLetra(Expression){
                var RefString = "abcdefghijklmnñopqrstuvwxyz ";
                RefString += RefString.toUpperCase();
                RefString += "Çü"
                RefString += "éâäàåçêëèï"
				RefString += "îìÄÅÉæÆôöò"
                RefString += "ÁÉÍÓÚ"
                RefString += "ûùÖÜ£"
                RefString += "áíóúñÑ "
                var bool = true;
                for (var i = 0; i < Expression.value.length; i++){
                        var ch = Expression.value.substr(i, 1)
                        var a = RefString.indexOf(ch, 0)
                        if (a == -1) {
                                bool = false;
                        }
                }
                if ((!bool) && (!isEmpty(Expression.value))){
                        alert("Caracter No valido")
                        Expression.value = "";
                        Expression.select();
                        Expression.focus();
                        return false
                }
                return true;
        }

        ////  Funcion Volver
        function Volver(){
                history.back(-1);
        }


        ///  Validacion si un Textbox de SOLO NUMEROS es obligatorio o no
        function esObligNumeros(obj_textbox,bool){
                if (bool){
                        if (!isEmpty(obj_textbox.value)){
                                var temp = new Number(sacaPuntos(obj_textbox.value))
                                obj_textbox.value = temp
                                if ((esNumeroPos(obj_textbox)) && (esEntero(obj_textbox.value))){
                                        return true
                                }
                                else{
                                        return false
                                }
                        }else
                                return false
                }
                else{
                        if (!isEmpty(obj_textbox.value)){
                                var temp = new Number(sacaPuntos(obj_textbox.value))
                                obj_textbox.value = temp
                                if ((esNumeroPos(obj_textbox)) && (esEntero(obj_textbox.value))){
                                        return true
                                }
                                else{
                                        return false
                                }
                        }else{
                                return true
                        }
                }
        }

        ///  Validacion si un Textbox de SOLO LETRAS es obligatorio o no
        function esObligLetras(obj_textbox,bool){
                if (bool){
                        if (!isEmpty(obj_textbox.value))
                                return esLetra(obj_textbox)
                        else
                                return false
                }
                else{
                        if (!isEmpty(obj_textbox.value))
                                return esLetra(obj_textbox)
                        else
                                return true
                }
        }

        ///  Validacion si un Textbox de SOLO ALFANUMERICO es obligatorio o no
        function esObligAlfanum(obj_textbox,bool){
                if (bool){
                        if (!isEmpty(obj_textbox.value))
                                return esAlfanumerico(obj_textbox)
                        else
                                return false
                }
                else{
                        if (!isEmpty(obj_textbox.value))
                                return esAlfanumerico(obj_textbox)
                        else
                                return true
                }
        }

        ///  Validacion si un Textbox de SOLO STRING es obligatorio o no
        function esObligString(obj_textbox,bool){
                if (bool){
                        if (!isEmpty(obj_textbox.value))
                                return esString(obj_textbox)
                        else
                                return false
                }
                else{
                        if (!isEmpty(obj_textbox.value))
                                return esString(obj_textbox)
                        else
                                return true
                }
        }

        ///  Validacion si un Textbox de SOLO TELEFONO es obligatorio o no
        function esObligFono(obj_textbox,bool){
                if (bool){
                        if (!isEmpty(obj_textbox.value))
                                return esTelefono(obj_textbox)
                        else
                                return false
                }
                else{
                        if (!isEmpty(obj_textbox.value))
                                return esTelefono(obj_textbox)
                        else
                                return true
                }
        }

        ///  Validacion si un Textbox de SOLO EMAIL es obligatorio o no
        function esObligEmail(obj_textbox,bool){
                if (bool){
                        if (!isEmpty(obj_textbox.value))
                                return isEmail(obj_textbox)
                        else
                                return false
                }
                else{
                        if (!isEmpty(obj_textbox.value))
                                return isEmail(obj_textbox)
                        else
                                return true
                }
        }

        ///  Validacion si un Radiobutton es obligatorio o no
        function esObligRadio(obj_radio,bool){
                if (bool)
                        if (!esRadioSel(obj_radio))
                                return false
                        else
                                return true
                else
                        /*if (esRadioSel(obj_radio))
                                return false
                        else*/
                                return true
        }

        ///  Validacion si un Combo es obligatorio o no
        function esObligCombo(obj_combo,bool){
                if (bool)
                        if ((obj_combo.selectedIndex == "") || (obj_combo.selectedIndex == -1))
                                return false
                        else
                                return true
                else
                        if (obj_combo.selectedIndex != "")
                                return false
                        else
                                return true
        }

        ///  Validacion si una Fecha es obligatoria o no
        function esObligFecha(obj_textbox,bool){
                if (bool){
                        if (!isEmpty(obj_textbox.value))
                                return isDate(obj_textbox.value)
                        else
                                return false
                }
                else{
                        if (!isEmpty(obj_textbox.value))
                                return isDate(obj_textbox.value)
                        else
                                return true
                }
        }

        ///  Validacion si un Checkbox es obligatorio o no (objeto,obligatorio o no,largo del checkbox)
        //hay que pulirla
        function esObligChkBx(nomtag,bool,largo){
                var salida = false
                if (bool){
                        for (i=0;i<largo;i++){
                                if (obj_chk[i].checked == true)
                                        salida =  true
                        }
                        return salida
                }
                else
                                return true
        }

        ///  verifica si esta seleccionado un radiobutton determinado
        function esRadioSel(obj_radio){
                var rLength = obj_radio.length
                var contador = 0
                for (i=0;i<rLength;i++){
                        if (!(obj_radio[i].checked))
                                contador+=1
                }
                if (contador == rLength)
                        return false;
                return true;
        }

        //  Activa o desactiva un radiobutton dependiendo del parametro bool
        //  asi lo desactiva
        //  desactivaRadio(obj_radio,true)
        function desactivaRadio(obj_radio,bool){
                var rLength = obj_radio.length
                var contador = 0
                for (i=0;i<rLength;i++){
                        obj_radio[i].disabled = bool
                        if (bool)
                                obj_radio[i].checked = false
                }
                return true;
        }

        //  Activa o desactiva un combo dependiendo del parametro bool
        //  asi lo desactiva
        //  desactivaCombo(obj_combo,true)
        function desactivaCombo(obj_combo,bool){
                obj_combo.disabled = bool
                return true;
        }

        function ultDiaMes(num_mes){
                var MonthDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
                return MonthDays[num_mes-1];
        }

        function compFechas(fecha1,fecha2,separador){
                var fecha1Tmp = fecha1.split(separador);
                var fecha2Tmp = fecha2.split(separador);
                var dia1 = fecha1Tmp[0];
                var mes1 = fecha1Tmp[1];
                var ano1 = fecha1Tmp[2];
                var dia2 = fecha2Tmp[0];
                var mes2 = fecha2Tmp[1];
                var ano2 = fecha2Tmp[2];
                fec1 = ano1 + mes1 + dia1;
                fec2 = ano2 + mes2 + dia2;
                if(Number(fec1) > Number(fec2))
                        return false;
                return true;

        }
        //  Activa o desactiva un textbox dependiendo del parametro bool
        //  asi lo desactiva
        //  desactivaTextbox(obj_text,true)
        function desactivaTextbox(obj_text,bool){
                obj_text.disabled = bool
                return true;
        }
        //  formatea un numero, le saca los puntos
        function sacaPuntos(numero){
                var sinPtos = numero;
                var nNum = new String(numero)
                if (nNum.indexOf(".") != -1){
                        var sinPtos = '';
                        for (i=0;i<nNum.length;i++){
                                if (nNum.substr(i,1) != ".")
                                        sinPtos += nNum.substr(i,1)
                        }
                }
                return sinPtos
        }

        function separaRut(obj_rut,obj_dv){
                var dv = obj_rut.value.charAt(obj_rut.value.length-1);
                var rut = obj_rut.value.substring(0,obj_rut.value.length-1);
                if(!isEmpty(obj_rut.value)){
                        if ((obj_rut.value.indexOf(".") == -1) && (obj_rut.value.indexOf("-") == -1)){
                                obj_rut.value = rut;
                                obj_dv.value = dv;
                                if (esNumeroPos(obj_rut)){
                                        puntosEnNumero(obj_rut)
                                        if(!checkRutField(obj_rut,obj_dv))
                                                return false
                                        obj_rut.value = obj_rut.value +'-'+obj_dv.value
                                }
                                else
                                        return false
                        }
                        else{
                                var raya = rut.charAt(rut.length-1);
                                rut = rut.substring(0,rut.length-1);
                                if (raya == "-"){
                                        obj_rut.value = sacaPuntos(rut);
                                        obj_dv.value = dv;
                                        if (esNumeroPos(obj_rut)){
                                                puntosEnNumero(obj_rut)
                                                if(!checkRutField(obj_rut,obj_dv))
                                                        return false
                                                obj_rut.value = obj_rut.value +'-'+obj_dv.value
                                        }
                                        else {
                                                alert("El RUT es Incorrecto")
                                                obj_rut.focus();
                                                obj_rut.value = '';
                                                return false;
                                        }
                                }
                                else{
                                        alert("El RUT es Incorrecto")
                                        obj_rut.focus();
                                        obj_rut.value = '';
                                        return false;
                                }

                        }
                }else
                        return false;
                return true;
        }

        //  Valida si un nuemro es mayor que cero
        function esNumeroPosFlash(numero){
                //numero = Trim(numero)
                nNumero = new Number(sacaPuntos(numero))
                if (isNaN(nNumero)){
                        alert("Casilla con Caracter no Valido")
                        return false;
                }
                if (nNumero < 0){
                        alert("Debe ingresar un valor mayor que cero")
                        return false;
                }
                var numeroLength = numero.length;
                for (i = 0; i < numeroLength; i++) {
                        var aChar = numero.substring(i,i+1);
                        if (aChar == " ") return false;
                }
                if ((nNumero == "") && (numeroLength != 0) && (nNumero != 0)){
                        alert("No es un numero Valido")
                        return false;
                }
                return true;
        }

        function checkDVFlash(rut,obj_dv){
                texto = rut + obj_dv.value
                var tmpstr = "";
                for (i=0; i < texto.length ; i++)
                        if (texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-')
                                tmpstr = tmpstr + texto.charAt(i);
                texto = tmpstr;

                largo = texto.length;
                if (largo < 2){
                        alert("Debe ingresar el RUT completo.")
                        //obj_rut.focus();
                        //obj_rut.select();
                        return false;
                }

                if (largo > 2)
                        rut_int = texto.substring(0, largo - 1);
                else
                        rut_int = texto.charAt(0);
                dv = texto.charAt(largo-1);
                if (!checkCDV(dv)){
                        alert("Debe ingresar un dígito verificador válido.");
                }

                if (rut_int == null || dv == null)
                        return 0
                var dvr = '0'

                suma = 0
                mul  = 2

                for (i= rut_int.length -1 ; i >= 0; i--){
                        suma = suma + rut_int.charAt(i) * mul
                        if (mul == 7)
                                mul = 2
                        else
                                mul++
                }

                res = suma % 11
                if (res==1)
                        dvr = 'k'
                else if (res==0)
                                dvr = '0'
                        else{
                                dvi = 11-res
                                dvr = dvi + ""
                        }

                if (dvr != dv.toLowerCase()){
                        alert("EL RUT es incorrecto.");
                        return false;
                }
                return true
        }


        function checkRutFieldFlash(rut,obj_dv){
                //Quitar Ceros
                var auxRut=rut;
                var auxLargo=auxRut.length;
                if (auxLargo>1){
                        while ((auxRut.substring(0,1)=="0") || (auxRut.substring(0,1)==".")){
                                auxRut=auxRut.substring(1,auxLargo);
                                auxLargo=auxRut.length
                        }
                }
                rut=auxRut;
                  //Fin Quitar Ceros

                texto = rut + obj_dv.value

                var tmpstr = "";
                  if ((rut==0)&&(obj_dv.value==0)){
                        alert("El RUT no es válido.");
                        return false;
                }
                for ( i=0; i < texto.length ; i++ )
                        if ( texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' )
                                tmpstr = tmpstr + texto.charAt(i);
                texto = tmpstr;
                largo = texto.length;
                if (largo < 2){
                        alert("Debe ingresar el RUT completo.")
                        return false;
                }
                for (i=0; i < largo ; i++ ){
                        if (texto.charAt(i) !="0" && texto.charAt(i) != "1" && texto.charAt(i) !="2" && texto.charAt(i) != "3" && texto.charAt(i) != "4" && texto.charAt(i) !="5" && texto.charAt(i) != "6" && texto.charAt(i) != "7" && texto.charAt(i) !="8" && texto.charAt(i) != "9" && texto.charAt(i) !="k" && texto.charAt(i) != "K" ){
                                alert("El valor ingresado no corresponde a un RUT válido.");
                                return false;
                        }
                }
                if (obj_dv.value == "k"){
                        obj_dv.value="K"
                }
                if (checkDVFlash(rut,obj_dv))
                        return true;
                return false;
        }


        function separaRutFlash(rut,obj_dv){
                var dv = rut.charAt(rut.length-1);
                var rut_int = rut.substring(0,rut.length-1);

                if(!isEmpty(rut)){
                        if ((rut.indexOf(".") == -1) && (rut.indexOf("-") == -1)){
                                rut = rut_int;
                                obj_dv.value = dv;
                                if (esNumeroPosFlash(rut)){
                                        ponerPuntosEnNumero(rut)
                                        if(!checkRutFieldFlash(rut,obj_dv))
                                                return false
                                }
                                else
                                        return false
                        }
                        else{
                                var raya = rut.charAt(rut.length-2);
                                rut_int = rut.substring(0,rut.length-2);
                                if (raya == "-"){
                                        rut = sacaPuntos(rut_int);
                                        obj_dv.value = dv;
                                        if (esNumeroPosFlash(rut)){
                                                ponerPuntosEnNumero(rut)
                                                if(!checkRutFieldFlash(rut,obj_dv))
                                                        return false
                                                rut = rut +'-'+obj_dv.value
                                        }
                                        else {
                                                alert("El RUT es Incorrecto")
                                                return false;
                                        }
                                }
                                else{
                                        alert("El RUT es Incorrecto")
                                        return false;
                                }

                        }
                }else
                        return false;
                return true;
        }

        function seleccionaCombo(obj_combo,valor){
                for(i=0;i<obj_combo.length;i++){
                        if(obj_combo.options[i].value == valor){
                                obj_combo.selectedIndex = i;
                                return true;
                        }
                }
                return false;

        }

        //  funciones pensadas en el onKeyPress
        //  <input type="text" name="..el_que_sea.." onKeyPress="validaInput('numeros')>"
        function validaInput(tipo,e){
                var teclaCodigo = 0;
                if (navigator.appName == 'Netscape')
                        teclaCodigo = e.which
            else
                        teclaCodigo = e.keyCode
                if (tipo == "numeros"){//desde el 0 al 9
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57)
                        || (teclaCodigo == 0)
                        || (teclaCodigo == 8)){event.returnValue = true}else return false;
                }
                if (tipo == "numeros_y_UF"){//desde el 0 al 9 mas ,
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57)
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
                        || (teclaCodigo == 44)){event.returnValue = true}else return false;
                }
                if (tipo == "password"){//desde el 0 al 9
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57) //NUMEROS
                        || (teclaCodigo >= 65 && teclaCodigo <= 90) //mayusculas
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
                        || (teclaCodigo >= 97 && teclaCodigo <= 122)){event.returnValue = true}else return false; //minusculas
                }
                if (tipo == "alfanumerico"){//desde el 0 al 9 y de la A a la Z sin Ñ ni cosas raras
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57) //NUMEROS
                        || (teclaCodigo >= 65 && teclaCodigo <= 90) //mayusculas
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
						|| (teclaCodigo == 164) // ñ
						|| (teclaCodigo == 165) // Ñ
                        || (teclaCodigo >= 97 && teclaCodigo <= 122)){event.returnValue = true}else return false; //minusculas
                }
                if (tipo == "letras"){//mayusculas y minusculas, acentos y caracteres especiales, barra espacio y borrar
                        if ((teclaCodigo >= 65 && teclaCodigo <= 90)
                        || (teclaCodigo >= 97 && teclaCodigo <= 122)
                        || (teclaCodigo >= 192 && teclaCodigo <= 207)
                        || (teclaCodigo >= 209 && teclaCodigo <= 214)
                        || (teclaCodigo >= 217 && teclaCodigo <= 220)
                        || (teclaCodigo >= 224 && teclaCodigo <= 239)
                        || (teclaCodigo >= 241 && teclaCodigo <= 246)
                        || (teclaCodigo >= 249 && teclaCodigo <= 253)
                        || (teclaCodigo == 255)
                        || (teclaCodigo == 32)
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
						|| (teclaCodigo == 164) // ñ
						|| (teclaCodigo == 165) // Ñ
                        || (teclaCodigo == 127)){event.returnValue = true}else return false;
                }
                if (tipo == "fono"){//desde el 0 al 9
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57)
                        || (teclaCodigo >= 40 && teclaCodigo <= 41)
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
                        || (teclaCodigo == 45)){event.returnValue = true}else return false;
                }
                if (tipo == "string"){//mayusculas y minusculas, acentos y caracteres especiales, barra espacio, gato y borrar, comas, puntos
                        if ((teclaCodigo >= 65 && teclaCodigo <= 90) //mayusculas
                        || (teclaCodigo >= 97 && teclaCodigo <= 122)  //minusculas
                        || (teclaCodigo >= 192 && teclaCodigo <= 207) //
                        || (teclaCodigo >= 209 && teclaCodigo <= 214)
                        || (teclaCodigo >= 217 && teclaCodigo <= 220)
                        || (teclaCodigo >= 224 && teclaCodigo <= 239)
                        || (teclaCodigo >= 241 && teclaCodigo <= 246)
                        || (teclaCodigo >= 249 && teclaCodigo <= 253)
                        || (teclaCodigo == 255)
                        || (teclaCodigo == 32) // espacio
						|| (teclaCodigo == 127) // borrar
                        || (teclaCodigo >= 48 && teclaCodigo <= 57) //numeros
                        || (teclaCodigo == 40) // (
                        || (teclaCodigo == 41) // )
                        || (teclaCodigo == 44) // ,
                        || (teclaCodigo == 58) // :
                        || (teclaCodigo == 45) // -
						|| (teclaCodigo == 46) // .
						|| (teclaCodigo == 47) // /
                        || (teclaCodigo == 35) // #
						|| (teclaCodigo == 39) // '
						|| (teclaCodigo == 8) //tecla para borrar
						|| (teclaCodigo == 13) //tecla Enter
                        || (teclaCodigo == 0)
						|| (teclaCodigo == 164) // ñ
						|| (teclaCodigo == 165) // Ñ
                        || (teclaCodigo == 46)){event.returnValue = true}else return false; // .
                }
                if (tipo == "email"){//desde el 0 al 9
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57)
                        || (teclaCodigo >= 65 && teclaCodigo <= 90)
                        || (teclaCodigo >= 97 && teclaCodigo <= 122)
                        || (teclaCodigo == 95)
                        || (teclaCodigo == 64)
						|| (teclaCodigo == 45) //tecla -
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
                        || (teclaCodigo == 46)){event.returnValue = true}else return false;
                }
                if (tipo == "rut"){//desde el 0 al 9 mas punto (.)
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57)
                        || (teclaCodigo >= 45 && teclaCodigo <= 46)
                        || (teclaCodigo == 75)
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
                        || (teclaCodigo == 107)){event.returnValue = true}else return false;

                }
                if (tipo == "rut_old"){//desde el 0 al 9 mas punto (.)
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57)
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
                        || (teclaCodigo == 46)){event.returnValue = true}else return false;
                }
                if (tipo == "num_ptos"){//desde el 0 al 9 mas punto (.)
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57)
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
                        || (teclaCodigo == 46)){event.returnValue = true}else return false;
                }
                if (tipo == "dv"){//desde el 0 al 9 mas - y la k y K
                        if ((teclaCodigo >= 49 && teclaCodigo <= 57)
                        //|| (teclaCodigo == 48)
                        || (teclaCodigo == 75)
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
                        || (teclaCodigo == 107)){event.returnValue = true}else return false;
                }
                if (tipo == "fecha"){//desde el 0 al 9 mas - y /
                        if ((teclaCodigo >= 48 && teclaCodigo <= 57)
                        || (teclaCodigo == 47)//Tecla /
                        || (teclaCodigo == 45)//Tecla -
                        || (teclaCodigo == 8) //tecla para borrar
                        || (teclaCodigo == 0)
                        || (teclaCodigo == 107)){event.returnValue = true}else return false;
                }
                //return false
        }

        ////// Crea arreglos multidimensionales //////
        function arrayMD(iRows,iCols){
                var i;
                var j;
                var a = new Array(iRows);
                for (i=0; i < iRows; i++){
                        a[i] = new Array(iCols);
                        for (j=0; j < iCols; j++){
                                a[i][j] = "";
                        }
                }
                return(a);
        }

        /////  Validador de Fecha donde el formato es dd/mm/aaaa o dd-mm-aaaa
        function isDate(dateStr){

                var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
                var matchArray = dateStr.match(datePat); // is the format ok?

                if (matchArray == null){
                        alert("Por favor ingrese una fecha dd/mm/aaaa o dd-mm-aaaa.");
                        dateStr.select();
                        dateStr.focus();
                        return false;
                }

                day = matchArray[1]; // parse date into variables
                month = matchArray[3];
                year = matchArray[5];

                if (month < 1 || month > 12){ // check month range
                        alert("El Mes debe estar entre 1 y 12");
                        dateStr.select();
                        dateStr.focus();
                        return false;
                }

                if (day < 1 || day > 31){
                        alert("El Dia debe estar entre 1 y 31.");
                        dateStr.select();
                        dateStr.focus();
                        return false;
                }

                if ((month==4 || month==6 || month==9 || month==11) && day==31){
                        alert("El Mes "+month+" no tiene 31 dias!")
                        dateStr.select();
                        dateStr.focus();
                        return false;
                }

                if (month == 2){ // check for february 29th
                        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
                        if (day > 29 || (day==29 && !isleap)){
                                alert("El año " + year + ", Febrero no tiene " + day + " dias!");
                                        dateStr.select();
                                        dateStr.focus();
                                return false;
                        }
                }
                return true; // date is valid
        }

        /////  Validador de Fecha donde el formato es dd/mm/aaaa o dd-mm-aaaa
        function esFecha(dateStr){
            if (!isEmpty(dateStr.value)){
                                var fecha = dateStr.value
                var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
                var matchArray = fecha.match(datePat); // is the format ok?

                if (matchArray == null){
                        alert("Por favor ingrese una fecha dd/mm/aaaa o dd-mm-aaaa.");
                        dateStr.select();
                        dateStr.focus();
                        return false;
                }

                day = matchArray[1]; // parse date into variables
                month = matchArray[3];
                year = matchArray[5];

                if (month < 1 || month > 12){ // check month range
                        alert("El Mes debe estar entre 1 y 12");
                        dateStr.select();
                        dateStr.focus();
                        return false;
                }

                if (day < 1 || day > 31){
                        alert("El Dia debe estar entre 1 y 31.");
                        dateStr.select();
                        dateStr.focus();
                        return false;
                }

                if ((month==4 || month==6 || month==9 || month==11) && day==31){
                        alert("El Mes "+month+" no tiene 31 dias!")
                        dateStr.select();
                        dateStr.focus();
                        return false;
                }

                if (month == 2){ // check for february 29th
                        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
                        if (day > 29 || (day==29 && !isleap)){
                                alert("El año " + year + ", Febrero no tiene " + day + " dias!");
                                        dateStr.select();
                                        dateStr.focus();
                                return false;
                        }
                }
                return true; // date is valid
            } else return true;
        }

        // valida dos campos de clave..
        function validaPass(pass1,pass2){
                if (pass1.value != pass2.value){
                        //ert("Ambas claves deben ser iguales")
                        //ss1.value = '';
                        //ss2.value = '';
                        //ss1.focus();
                        return false;
                }
        return true;
        }

        ////////////  Conjunto de funciones Para restringir el Nº de Caracteres  /////////////////////
        function restrictinput(maxlength,e,placeholder){
                    if (window.event&&event.srcElement.value.length >= maxlength){
                        return false
                    }else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
                        var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
                        if (pressedkey.test(String.fromCharCode(e.which)))
                            e.stopPropagation()
                    }
                }

                function countlimit(maxlength,e,placeholder){
                    var theform=eval(placeholder)
                    var lengthleft=maxlength-theform.value.length
                    var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
                    if (window.event||e.target&&e.target==eval(placeholder)){
                        if (lengthleft < 0)
                            theform.value = theform.value.substring(0,maxlength)
                    placeholderobj.innerHTML = lengthleft
                    }
                }


                function displaylimit(theform,thelimit){
                    var ns6=document.getElementById&&!document.all
                    var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> caracteres restantes. '
                    if (document.all||ns6)
                        document.write(limit_text)
                    if (document.all){
                        eval(theform).onkeypress = function(){ return restrictinput(thelimit,event,theform)}
                        eval(theform).onkeyup = function(){ countlimit(thelimit,event,theform)}
                    }else if (ns6){
                        document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
                        document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
                    }
                }

///////////////////////////////////////////////////////////////



