//contac
//'00 RUT
//'01 DIGITO_VERIFICADOR
//'02 NOMBRE
//'03 APELLIDOS
//'04 EMPRESA
//'05 DIRECCION
//'06 TELEFONO
//'07 E-MAIL
//'08 COMENTARIOS
//'09 TIPO_DE_CONSULTA
//*****************************************************
//*****************************************************
// CRISTIAN QUINTANA  VARIABLES GLOBALES
var swOK=0;
var nEle=0;
var sError='';
// CRISTIAN QUINTANA
function darioquintana() {
var nTot=0;
var nPas=0;
var nTorna=0;
sError=" CONTACTO: \n CAMARA NACIONAL DE COMERCIO SERVICIOS Y TURISMO DE CHILE \n----> Detectó error en el ingreso de datos <----\n* ---------------------------------------------------------- *"+"\n";
//sError2="Gracias por Contactarce, "+"\n";
//sError2="Gracias por Contactarce, +quintana.nombre_del_contacto.value+,su e-mail es : +quintana.email.value+  "+"\n";
//sError3="hola,"+document.forms[0].elements[nEle].name.substr(0)+",contiene caracteres NO VALIDOS"+"\r"
//sError="Lista de errores: "+"\n";
  for (var j=0; j<12; j++) {
      nEle=j;
    // CRISTIAN QUINTANA LOS TIPOS
    var sNom=document.forms[0].elements[j].name;
var sOne=sNom.substring(0,1);
var sTwo=sNom.substring(1,2);
var stre=sNom.substring(2,3);
var scua=sNom.substring(3,4);
var scin=sNom.substring(4,5);
var ssei=sNom.substring(5,6);
var ssie=sNom.substring(6,7);
var soch=sNom.substring(7,8);
var snue=sNom.substring(8,9);
var sdie=sNom.substring(9,10);
var sonc=sNom.substring(10,11);
    //var soch=sNom.substring(7,8);
//(sOne=='N' && sTwo=='O' && stre=='O' && scua=='O' && scin=='O' && ssei=='O' && ssie=='O' && soch=='O' && snue=='O'
//&& sdie=='O' && sonc=='O' && sdoc=='O' && strec=='O' && scat=='O' && squi=='O' && sdies=='O' && sdiesi=='O' 
//&& sdiesio=='O') 
//'00 RUT
if (sOne=='R' && sTwo=='U' && stre=='T') {
CaracterNoValid(document.forms[0].elements[j].value,'00');
nTot+=swOK;
}
//'01 DIGITO_VERIFICADOR
if (sOne=='D' && sTwo=='I' && stre=='G' && scua=='I') {
CaracterNoValid(document.forms[0].elements[j].value,'01');
nTot+=swOK;
}
//'02 NOMBRE
if (sOne=='N' && sTwo=='O' && stre=='M' && scua=='B') {
CaracterNoValid(document.forms[0].elements[j].value,'02');
nTot+=swOK;
}
//'03 APELLIDOS
if (sOne=='A' && sTwo=='P' && stre=='E' && scua=='L') {
CaracterNoValid(document.forms[0].elements[j].value,'03');
nTot+=swOK;
}
//'04 EMPRESA
if (sOne=='E' && sTwo=='M' && stre=='P' && scua=='R') {
CaracterNoValid(document.forms[0].elements[j].value,'04');
nTot+=swOK;
}
//'05 DIRECCION
if (sOne=='D' && sTwo=='I' && stre=='R' && scua=='E') {
CaracterNoValid(document.forms[0].elements[j].value,'05');
nTot+=swOK;
}
//'06 TELEFONO
if (sOne=='T' && sTwo=='E' && stre=='L' && scua=='E') {
CaracterNoValid(document.forms[0].elements[j].value,'06');
nTot+=swOK;
}
//'07 E-MAIL
if (sOne=='E' && sTwo=='-' && stre=='M' && scua=='A') {
CaracterNoValid(document.forms[0].elements[j].value,'07');
nTot+=swOK;
}
//'08 COMENTARIOS
if (sOne=='C' && sTwo=='O' && stre=='M' && scua=='E') {
CaracterNoValid(document.forms[0].elements[j].value,'08');
nTot+=swOK;
}
//'09 TIPO_DE_CONSULTA
if (sOne=='T' && sTwo=='I' && stre=='P' && scua=='O') {
CaracterNoValid(document.forms[0].elements[j].value,'09');
nTot+=swOK;
}


    // CRISTIAN QUINTANA DE ERRORES
    if (nPas==0 && nTot>0) {
      document.forms[0].elements[nEle].focus()
      nPas=1
    }
  }
  if (nTot>0)
    alert(sError)
else
    //alert(sError2)
   // alert(sError3)
document.contac.submit();
}
// CRISTIAN QUINTANA CAMPO A CAMPO
//------12345678901234567890123456789012345678901234567890123456789012345678901234567890101234
//------°!"#$%&/()=?¡|¿,;.:-{}[]<>@*¬^+\_'~ABCDEFGHIJLMNÑOPQRSTUVWXYZabcdefghijlmnñopqrstuvwxyz no " no \
function CaracterNoValid(pCaracter,pType) {

//'00 RUT
  if (pType=='00') {
   swOK=0;
    if (pCaracter=='') {
       sError+="* Ingrese su, "+document.forms[0].elements[nEle].name.substr(0)+" ,solo numeros ej: 100542xx"+"\n\r"
       swOK=1;
       return
     }
    for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1);
      if (
sByte=="°" || sByte=="!" || sByte=="#" || sByte=="$" || sByte=="%" || sByte=="&" || sByte=="/" || 
sByte=="(" || sByte==")" || sByte=="=" || sByte=="?" || sByte=="¡" || sByte=="|" || sByte=="¿" || 
sByte=="," || sByte==";" || sByte==":" || sByte=="{" || sByte=="}" || 
sByte=="[" || sByte=="]" || sByte=="<" || sByte==">" || sByte=="@" || sByte=="*" || sByte=="¬" ||
sByte=="^" || sByte=="+" || sByte=="_" || sByte=="'" || sByte=="~" || 
sByte=="A" || sByte=="B" || sByte=="C" || sByte=="D" || sByte=="E" || sByte=="F" || sByte=="G" ||
sByte=="H" || sByte=="I" || sByte=="J" || sByte=="L" || sByte=="M" || sByte=="N" ||
sByte=="Ñ" || sByte=="O" || sByte=="P" || sByte=="Q" || sByte=="R" || sByte=="S" || sByte=="T" ||
sByte=="U" || sByte=="V" || sByte=="W" || sByte=="X" || sByte=="Y" || sByte=="Z" ||
sByte=="Á" || sByte=="É" || sByte=="Í" || sByte=="Ó" || sByte=="Ú" || 
sByte=="a" || sByte=="b" || sByte=="c" || sByte=="d" || sByte=="e" || sByte=="f" || sByte=="g" ||
sByte=="h" || sByte=="i" || sByte=="j" || sByte=="l" || sByte=="m" || sByte=="n" ||
sByte=="ñ" || sByte=="o" || sByte=="p" || sByte=="q" || sByte=="r" || sByte=="s" || sByte=="t" ||
sByte=="u" || sByte=="v" || sByte=="w" || sByte=="x" || sByte=="y" || sByte=="z" ||
sByte=="á" || sByte=="é" || sByte=="í" || sByte=="ó" || sByte=="ú" )
 {
        sError+="error! en "+document.forms[0].elements[nEle].name.substr(0)+" ,Usted  ingreso caracteres no válidos, es numérico ej: 100542xx"+"\n\r"
        swOK=1;
        return;
      }
    }
  }
//'01 DIGITO_VERIFICADOR
  if (pType=='01') {
   swOK=0;
    if (pCaracter=='') {
       sError+="* Ingrese su, "+document.forms[0].elements[nEle].name.substr(0)+" ,solo el digito verificador ej: K"+"\n\r"
       swOK=1;
       return
     }
    for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1);
      if (
sByte=="°" || sByte=="!" || sByte=="#" || sByte=="$" || sByte=="%" || sByte=="&" || sByte=="/" || 
sByte=="(" || sByte==")" || sByte=="=" || sByte=="?" || sByte=="¡" || sByte=="|" || sByte=="¿" || 
sByte=="," || sByte==";" || sByte==":" || sByte=="{" || sByte=="}" || 
sByte=="[" || sByte=="]" || sByte=="<" || sByte==">" || sByte=="@" || sByte=="*" || sByte=="¬" ||
sByte=="^" || sByte=="+" || sByte=="_" || sByte=="'" || sByte=="~" || 
sByte=="A" || sByte=="B" || sByte=="C" || sByte=="D" || sByte=="E" || sByte=="F" || sByte=="G" ||
sByte=="H" || sByte=="I" || sByte=="J" || sByte=="L" || sByte=="M" || sByte=="N" ||
sByte=="Ñ" || sByte=="O" || sByte=="P" || sByte=="Q" || sByte=="R" || sByte=="S" || sByte=="T" ||
sByte=="U" || sByte=="V" || sByte=="W" || sByte=="X" || sByte=="Y" || sByte=="Z" ||
sByte=="Á" || sByte=="É" || sByte=="Í" || sByte=="Ó" || sByte=="Ú" || 
sByte=="a" || sByte=="b" || sByte=="c" || sByte=="d" || sByte=="e" || sByte=="f" || sByte=="g" ||
sByte=="h" || sByte=="i" || sByte=="j" || sByte=="l" || sByte=="m" || sByte=="n" ||
sByte=="ñ" || sByte=="o" || sByte=="p" || sByte=="q" || sByte=="r" || sByte=="s" || sByte=="t" ||
sByte=="u" || sByte=="v" || sByte=="w" || sByte=="x" || sByte=="y" || sByte=="z" ||
sByte=="á" || sByte=="é" || sByte=="í" || sByte=="ó" || sByte=="ú" )
 {
        sError+="error! en "+document.forms[0].elements[nEle].name.substr(0)+" ,Usted  ingreso caracteres no válidos, ej: k"+"\n\r"
        swOK=1;
        return;
      }
    }
  }
//'02 NOMBRE
  if (pType=='02') {
   swOK=0;
    if (pCaracter=='') {
       sError+="* Ingrese su, "+document.forms[0].elements[nEle].name.substr(0)+" ,alfabético"+"\n\r"
       swOK=1;
       return
     }
    for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1);
      if (
sByte=="°" || sByte=="!" || sByte=="#" || sByte=="$" || sByte=="%" || sByte=="&" || sByte=="/" || sByte=="(" ||
sByte==")" || sByte=="=" || sByte=="?" || sByte=="¡" || sByte=="|" || sByte=="¿" || sByte=="," || sByte==";" || 
sByte==":" || sByte=="-" || sByte=="{" || sByte=="}" || sByte=="[" || sByte=="]" || sByte=="<" || sByte==">" || sByte=="@" ||
sByte=="*" || sByte=="¬" || sByte=="^" || sByte=="+" || sByte=="_" || sByte=="'" || sByte=="~" || sByte=="1" ||
sByte=="2" || sByte=="3" || sByte=="4" || sByte=="5" || sByte=="6" || sByte=="7" || sByte=="8" || sByte=="9" || sByte=="0")
 {
        sError+="error! en "+document.forms[0].elements[nEle].name.substr(0)+" ,Usted ingreso caracteres no válidos, es alfabético"+"\n\r"
        swOK=1;
        return;
      }
    }
  }
//'03 APELLIDOS
  if (pType=='03') {
   swOK=0;
    if (pCaracter=='') {
       sError+="* Ingrese sus, "+document.forms[0].elements[nEle].name.substr(0)+" ,alfabético"+"\n\r"
       swOK=1;
       return
     }
    for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1);
      if (
sByte=="°" || sByte=="!" || sByte=="#" || sByte=="$" || sByte=="%" || sByte=="&" || sByte=="/" || sByte=="(" ||
sByte==")" || sByte=="=" || sByte=="?" || sByte=="¡" || sByte=="|" || sByte=="¿" || sByte=="," || sByte==";" || 
sByte==":" || sByte=="-" || sByte=="{" || sByte=="}" || sByte=="[" || sByte=="]" || sByte=="<" || sByte==">" || sByte=="@" ||
sByte=="*" || sByte=="¬" || sByte=="^" || sByte=="+" || sByte=="_" || sByte=="'" || sByte=="~" || sByte=="1" ||
sByte=="2" || sByte=="3" || sByte=="4" || sByte=="5" || sByte=="6" || sByte=="7" || sByte=="8" || sByte=="9" || sByte=="0")
 {
        sError+="error! en "+document.forms[0].elements[nEle].name.substr(0)+" ,Usted ingreso caracteres no válidos, es alfabético"+"\n\r"
        swOK=1;
        return;
      }
    }
  }
//'04 EMPRESA
  if (pType=='04') {
   swOK=0;
    if (pCaracter=='') {
       sError+="* Ingrese su, "+document.forms[0].elements[nEle].name.substr(0)+" ,alfabético"+"\n\r"
       swOK=1;
       return
     }
    for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1);
      if (
sByte=="°" || sByte=="!" || sByte=="#" || sByte=="$" || sByte=="%" || sByte=="&" || sByte=="/" || sByte=="(" ||
sByte==")" || sByte=="=" || sByte=="?" || sByte=="¡" || sByte=="|" || sByte=="¿" || sByte=="," || sByte==";" || 
sByte==":" || sByte=="-" || sByte=="{" || sByte=="}" || sByte=="[" || sByte=="]" || sByte=="<" || sByte==">" || sByte=="@" ||
sByte=="*" || sByte=="¬" || sByte=="^" || sByte=="+" || sByte=="_" || sByte=="'" || sByte=="~")
 {
        sError+="error! en "+document.forms[0].elements[nEle].name.substr(0)+" ,Usted ingreso caracteres no válidos, es alfabético"+"\n\r"
        swOK=1;
        return;
      }
    }
  }
//'05 DIRECCION
  if (pType=='05') {
   swOK=0;
    if (pCaracter=='') {
       sError+="* Ingrese la, "+document.forms[0].elements[nEle].name.substr(0)+" ,alfabético"+"\n\r"
       swOK=1;
       return
     }
    for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1);
      if (
sByte=="°" || sByte=="!" || sByte=="#" || sByte=="$" || sByte=="%" || sByte=="&" || sByte=="/" || sByte=="(" ||
sByte==")" || sByte=="=" || sByte=="?" || sByte=="¡" || sByte=="|" || sByte=="¿" || sByte=="," || sByte==";" || 
sByte==":" || sByte=="-" || sByte=="{" || sByte=="}" || sByte=="[" || sByte=="]" || sByte=="<" || sByte==">" || sByte=="@" ||
sByte=="*" || sByte=="¬" || sByte=="^" || sByte=="+" || sByte=="_" || sByte=="'" || sByte=="~" )
 {
        sError+="error! en "+document.forms[0].elements[nEle].name.substr(0)+" ,Usted ingreso caracteres no válidos, es alfabético"+"\n\r"
        swOK=1;
        return;
      }
    }
  }
//'06 TELEFONO
  if (pType=='06') {
    swOK=0;
    if (pCaracter=='') {
      swOK=1
      sError+="* Ingrese su, "+document.forms[0].elements[nEle].name.substr(0)+" ,ej: 2865899"+"\n\r"
      return
    }
    for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1);
      if (sByte<"0" || sByte>"9") {
        sError+="error! en "+document.forms[0].elements[nEle].name.substr(0)+" ,Usted  ingreso caracteres no válidos, es numérico"+"\n\r"
        swOK=1;
        swOK=1;
        return;
      }
    }
   }
//'07 E-MAIL
  if (pType=='07') {
   swOK=2
   for (var i=0;i<pCaracter.length;i++) {
     var sByte=pCaracter.substring(i,i+1);
     if (sByte=="@" || sByte==".") {
       swOK=swOK-1;
     }
   }
   if (swOK>0)    {
       sError+="* Ingrese su, "+document.forms[0].elements[nEle].name.substr(0)+" ,ej: usuario@dominio" +"\n\r" }
   return;
 }
//'08 COMENTARIOS
 if (pType=='08') {
  swOK=0;
    if (pCaracter=='') {
       sError+="* Ingrese sus, "+document.forms[0].elements[nEle].name.substr(0)+" ,alfanumerico" +"\n\r"
       swOK=1;
       return
     }
  }
//'09 TIPO_DE_CONSULTA
  if (pType=='09') {
   swOK=0;
    if (pCaracter=='-1') {
       sError+="* Seleccione, "+document.forms[0].elements[nEle].name.substr(0)+" ,obligatotio "+"\n\r"
       swOK=1;
       return
     }
  }


 }

