
<!-- Oculta el codigo a navegadores antiguos

// AUTOR: Enric Cappellani
// Modificado ligeramente por Daniel Rodriguez

// Variables Globales
var euro = 166.386;
var swOK=0;
var nEle=0;
var sError='';
var swOK1=0;
var nEle1=0;
var sError1='';

// Función para multiplicar el valor de las cajas de bolsas de 40 gr.
// =========================================================================
function calculo40() {
  document.Formu.T1.value=document.Formu.noCantidad_40gr.value*2250
  calculototales()
}

function a160() {
  document.Formu.noCantidad_160gr.focus()
}

// Función para multiplicar el valor de las cajas de bolsas de 160 gr.
// =========================================================================
function calculo160() {
  document.Formu.T2.value=document.Formu.noCantidad_160gr.value*1920
  document.Formu.noCantidad_200gr.focus()
  calculototales()
}

function a200() {
  document.Formu.noCantidad_200gr.focus()
}

// Función para multiplicar el valor de las cajas de bolsas de 200 gr.
// =========================================================================
function calculo200() {
  document.Formu.T3.value=document.Formu.noCantidad_200gr.value*1920
  document.Formu.noCantidad_400gr.focus()
  calculototales()
}

function a400() {
  document.Formu.noCantidad_400gr.focus()
}


// Función para multiplicar el valor de las cajas de bolsas de 400 gr.
// =========================================================================
function calculo400() {
  document.Formu.T4.value=document.Formu.noCantidad_400gr.value*1920
  document.Formu.noCantidad_1kg.focus()
  calculototales()
}

function a1kg() {
  document.Formu.noCantidad_1kg.focus()
}


// Función para multiplicar el valor de las cajas de bolsas de 1 Kgr.
// =========================================================================
function calculo1kg() {
  document.Formu.T5.value=document.Formu.noCantidad_1kg.value*1987
  document.Formu.noCantidad_3kg.focus()
  calculototales()
}
function a3kg() {
  document.Formu.noCantidad_3kg.focus()
}



// Función para multiplicar el valor de las cajas de bolsas de 3 Kgr.
// =========================================================================
function calculo3kg() {
  document.Formu.T6.value=document.Formu.noCantidad_3kg.value*1987
  document.Formu.srEmpresa.focus()
  calculototales()
}

function aEmpresa() {
  document.Formu.srEmpresa.focus()
}

// Función para calcular los totales
// =========================================================================
function calculototales() {
     document.Formu.TOTAL.value=Math.round((document.Formu.T1.value*1)+(document.Formu.T2.value*1)
     +(document.Formu.T3.value*1)+(document.Formu.T4.value*1)+(document.Formu.T5.value*1)+(document.Formu.T6.value*1))
     document.Formu.IVA.value= Math.round((document.Formu.TOTAL.value*7)/100)
     document.Formu.IMPORTE.value=(document.Formu.TOTAL.value*1)+(document.Formu.IVA.value*1)
     document.Formu.EUROS.value=Math.round(parseInt(document.Formu.IMPORTE.value)/euro*100)/100; 
}


// VERIFICA EL FORMULARIO
//===================================
function Verifica() {
  var nTot=0;
  var nPas=0;
  var nTorna=0;
  sError="Lista de errores:                                           "+"\n";
  for (var j=0; j<24; j++) {
    nEle=j;

    // AVERIGUA LOS TIPOS
    var sNom=document.forms[0].elements[j].name;
    var sOne=sNom.substring(0,1);
    var sTwo=sNom.substring(1,2);

    // CORREO OBLIGATORIO
    if (sOne=='e' && sTwo=='r') {
       CaracterNoValid(document.forms[0].elements[j].value,'Er');
       nTot+=swOK;
    }
    else
       if (sOne=='e' && document.forms[0].elements[nEle].value!='') {
           CaracterNoValid(document.forms[0].elements[j].value,'Eo');
           nTot+=swOK;
         }

    // NUMERICO Y OBLIGATORIO else NUMERICO NO OBLIGATORIO PERO INFORMADO
    if (sOne=='n' && sTwo=='r') {
       CaracterNoValid(document.forms[0].elements[j].value,'Nr');
       nTot+=swOK;
    }
    else
       if (sOne=='n' && document.forms[0].elements[nEle].value!='') {
           CaracterNoValid(document.forms[0].elements[j].value,'No');
           nTot+=swOK;
       }

    // CADENA Y OBLIGATORIA
    if (sOne=='s' && sTwo=='r') {
       CaracterNoValid(document.forms[0].elements[j].value,'Sr');
       nTot+=swOK;
    }

    // LISTA DE ERRORES
    if (nPas==0 && nTot>0) {
      document.forms[0].elements[0].focus()
      nPas=1
    }
  }

  if (nTot>0) {
    alert(sError)
    document.forms[0].elements[0].focus()
 }
  else
    document.forms[0].submit();
}

// ANALIZA CAMPO A CAMPO SI SON NUMERICOS
//=========================================
function CaracterNoValid(pCaracter,pType) {
  swOK=0;
  // E-MAIL OBLIGATORIO
  if (pType=='Er') { 
   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+="Campo "+document.forms[0].elements[nEle].name.substr(2)+" ha de ser e-mail y es obligatorio" +"\r" 
   }
   return;
 }

  // NUMERICO OBLIGATORIO
  if (pType=='Nr') {
    swOK=0;
    if (pCaracter=='') {
      swOK=1
      sError+="Campo "+document.forms[0].elements[nEle].name.substr(2)+" ha de ser numérico y es obligatorio" +"\r"
      return
    }

    for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1);
      if (sByte<"0" || sByte>"9") {
        sError+="Campo "+document.forms[0].elements[nEle].name.substr(2)+" ha de ser numérico y es obligatorio" +"\r"
        swOK=1;
        return;
      } 
    }
  }

  // NUMERICO INFORMADO
  if (pType=='No') { 
    swOK=0;
    if (pCaracter=='')  {
      swOK=1
      sError+="Campo "+document.forms[0].elements[nEle].name.substr(2)+" ha de ser numérico y NO es obligatorio" +"\r"
      return
    }
    for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1);
      if (sByte<"0" || sByte>"9") {
        sError+="Campo "+document.forms[0].elements[nEle].name.substr(2)+" ha de ser numérico y NO es obligatorio" +"\r"
        swOK=1;
        return;
      } 
    }
  }

  // CADENA
  if (pType=='Sr') { 
    if (pCaracter=='') {
       sError+="Campo "+document.forms[0].elements[nEle].name.substr(2)+" ha de ser texto y es obligatorio"+"\r"
       swOK=1;
       return
     }
  }

}
// --> 
  
// VERIFICA EL FORMULARIO
//===================================
function Verifica2() {
  var nTot1=0;
  var nPas1=0;
  var nTorna1=0;
  sError1="Lista de errores:                                           "+"\n";
  for (var j1=0; j1<8; j1++) {
    nEle1=j1;

    // AVERIGUA LOS TIPOS
    var sNom1=document.forms[1].elements[j1].name;
    var sOne1=sNom1.substring(0,1);
    var sTwo1=sNom1.substring(1,2);

    // CORREO OBLIGATORIO
    if (sOne1=='e' && sTwo1=='r') {
       CaracterNoValid1(document.forms[1].elements[j1].value,'Er');
       nTot1+=swOK1;
    }
    else
       if (sOne1=='e' && document.forms[1].elements[nEle1].value!='') {
           CaracterNoValid1(document.forms[1].elements[j1].value,'Eo');
           nTot1+=swOK1;
         }

    // NUMERICO Y OBLIGATORIO else NUMERICO NO OBLIGATORIO PERO INFORMADO
    if (sOne1=='n' && sTwo1=='r') {
       CaracterNoValid1(document.forms[1].elements[j1].value,'Nr');
       nTot1+=swOK1;
    }
    else
       if (sOne1=='n' && document.forms[1].elements[nEle1].value!='') {
           CaracterNoValid1(document.forms[1].elements[j1].value,'No');
           nTot1+=swOK1;
       }

    // CADENA Y OBLIGATORIA
    if (sOne1=='s' && sTwo1=='r') {
       CaracterNoValid1(document.forms[1].elements[j1].value,'Sr');
       nTot1+=swOK1;
    }

    // LISTA DE ERRORES
    if (nPas1==0 && nTot1>0) {
      document.forms[1].elements[0].focus()
      nPas1=1
    }
  }

  if (nTot1>0) {
    alert(sError1)
    document.forms[1].elements[0].focus()
 }
  else
    document.forms[1].submit();
}

// ANALIZA CAMPO A CAMPO SI SON NUMERICOS
//=========================================
function CaracterNoValid1(pCaracter1,pType1) {
  swOK1=0;
  // E-MAIL OBLIGATORIO
  if (pType1=='Er') { 
   swOK1=2
   for (var i=0;i<pCaracter1.length;i++) {
     var sByte1=pCaracter1.substring(i,i+1);
     if (sByte1=="@" || sByte1==".") {
       swOK1=swOK1-1;
     } 
   }
   if (swOK1>0) { 
      sError1+="Campo "+document.forms[1].elements[nEle1].name.substr(2)+" ha de ser e-mail y es obligatorio" +"\r" 
   }
   return;
 }

  // NUMERICO OBLIGATORIO
  if (pType1=='Nr') {
    swOK1=0;
    if (pCaracter1=='') {
      swOK1=1
      sError1+="Campo "+document.forms[1].elements[nEle1].name.substr(2)+" ha de ser numérico y es obligatorio" +"\r"
      return
    }

    for (var i=0;i<pCaracter1.length;i++) {
      var sByte=pCaracter1.substring(i,i+1);
      if (sByte1<"0" || sByte1>"9") {
        sError1+="Campo "+document.forms[1].elements[nEle1].name.substr(2)+" ha de ser numérico y es obligatorio" +"\r"
        swOK1=1;
        return;
      } 
    }
  }

  // NUMERICO INFORMADO
  if (pType1=='No') { 
    swOK1=0;
    if (pCaracter1=='')  {
      swOK1=1
      sError1+="Campo "+document.forms[1].elements[nEle1].name.substr(2)+" ha de ser numérico y NO es obligatorio" +"\r"
      return
    }
    for (var i=0;i<pCaracter1.length;i++) {
      var sByte=pCaracter1.substring(i,i+1);
      if (sByte1<"0" || sByte1>"9") {
        sError1+="Campo "+document.forms[1].elements[nEle1].name.substr(2)+" ha de ser numérico y NO es obligatorio" +"\r"
        swOK1=1;
        return;
      } 
    }
  }

  // CADENA
  if (pType1=='Sr') { 
    if (pCaracter1=='') {
       sError1+="Campo "+document.forms[1].elements[nEle1].name.substr(2)+" ha de ser texto y es obligatorio"+"\r"
       swOK1=1;
       return
     }
  }

}
  // --> 



