var articulo = new Array (103);

//articulo[0] = new libro("ISBN","TÍTULO", "PRECIO EUROS sin IVA");
articulo[0] = new libro("ISBN","TÍTULO",0);
articulo[1] = new libro("978-84-95333-58-2","Lecturas para estrenarse en FILOSOFÍA.",1058);
articulo[2] = new libro("978-84-95333-59-9","Lecturas para estrenarse en ÉTICA.",1058);
articulo[3] = new libro("978-84-95333-60-5","Lecturas para estrenarse en PSICOLOGÍA.",1058);
articulo[4] = new libro("978-84-95333-64-3","Lecturas para estrenarse en ANTROPOLOGÍA.",1058);
articulo[5] = new libro("978-84-95333-51-3","Ocho metáforas sobre la CONDICIÓN HUMANA.",1058);
articulo[6] = new libro("978-84-95333-57-5","Lecturas para estrenarse en FILOSOFÍA DE LA CIENCIA.",1058);
articulo[7] = new libro("978-84-95333-41-4","Lo que debes saber sobre la HISTORIA.",1058);
articulo[8] = new libro("978-84-95333-90-2","SOCIOLOGÍA.",1683);
articulo[9] = new libro("978-84-95333-95-7","FISCALIDAD DE LA EMPRESA 2007.Tomos I y II.",3750);
articulo[10] = new libro("978-84-922704-5-3","INCENTIVOS FISCALES para las PYME en los impuestos sobre la renta (IRPF e IS).",2019);
articulo[11] = new libro("978-84-922704-4-6","DISCRECIONALIDAD TÉCNICA en la comprobación tributaria de valores (la problemática de su control judicial).",2500);
articulo[12] = new libro("978-84-95333-28-5","EL PAGO DE LA DEUDA TRIBUTARIA a través de las entidades colaboradoras.",2019);
articulo[13] = new libro("978-84-96976-00-9","Los animales de la lluvia",1250);
articulo[14] = new libro("978-84-96976-01-6","Els animals de la pluja",1250);
articulo[15] = new libro("978-84-922704-9-1","PLATÓN. LIBRO VII DE LA REPÚBLICA.",1154);
articulo[16] = new libro("978-84-95333-00-1","PLATÓ. LLIBRE VII DE LA REPÚBLICA.",1154);
articulo[17] = new libro("978-84-922704-0-8","NIETZSCHE. UNA INTRODUCCIÓN DIDÁCTICA A LA GENEALOGÍA DE LA MORAL.",1154);
articulo[18] = new libro("978-84-95333-09-4","NIETZSCHE. LA GENEALOGIA DE LA MORAL. Dissertacions I i II. (Edició didàctica).",1154);
articulo[19] = new libro("978-84-95333-07-0","DESCARTES. DISCURSO DEL MÉTODO.",1154);
articulo[20] = new libro("978-84-95333-08-7","NIETZSCHE. SOBRE VERDAD Y MENTIRA EN SENTIDO EXTRAMORAL.",1154);
articulo[21] = new libro("978-84-95333-22-3","NIETZSCHE. SOBRE VERITAT I MENTIDA EN SENTIT EXTRAMORAL.",1154);
articulo[22] = new libro("978-84-95333-91-9","K. MARX - F. ENGELS. MANIFIESTO COMUNISTA.",1154);
articulo[23] = new libro("978-84-96976-47-4","MARX, Manifest comunista. Capítols I i II",1058);
articulo[24] = new libro("978-84-95333-06-3","LA CHICA DEL VIDEOCLUB ME MIRA.",1154);
articulo[25] = new libro("978-84-95333-53-7","El conflicto palestino-israelí.",1058);
articulo[26] = new libro("978-84-95333-43-8","De la biotecnología a la clonación.",1058);
articulo[27] = new libro("978-84-95333-45-2","OPERACIÓN J.",1250);
articulo[28] = new libro("978-84-95333-46-9","EL BOSQUE DE MI ABECEDARIO",1250);
articulo[29] = new libro("978-84-95333-42-1","Nuestro Estado de Derecho.",1058);
articulo[30] = new libro("978-84-95333-52-0","Yo estuve en Cheste. --- AGOTADO ---",0);
articulo[31] = new libro("978-84-95333-35-3","El botiquín filosófico.",1058);
articulo[32] = new libro("978-84-95333-47-6","A galope tendido.",1250);
articulo[33] = new libro("978-84-95333-48-3","Gato Gato.",1250);
articulo[34] = new libro("978-84-95333-49-0","El último sueño de Nietzsche.",1587);
articulo[35] = new libro("978-84-95333-65-0","El oso y la niña.",1250);
articulo[36] = new libro("978-84-95333-67-4","L'ós i la nena.",1250);
articulo[37] = new libro("978-84-95333-66-7","!Que vuelvan las vacas locas!.",1250);
articulo[38] = new libro("978-84-95333-68-1","Volem que tornin les vaques boges!.",1250);
articulo[39] = new libro("978-84-95333-69-8","Tú hablas, yo entiendo.",1250);
articulo[40] = new libro("978-84-95333-70-8","LA ASISTENCIA ADMINISTRATIVA en materia de liquidación tributaria en la Unión Europea.",1683);
articulo[41] = new libro("978-84-95333-71-1","Sapere Aude! Para qué escribí la Crítica de la Razón Pura.",1683);
articulo[42] = new libro("978-84-95333-79-7","Lou Andrea Salomé. La Bruja de Hainberg.",1683);
articulo[43] = new libro("978-84-95333-72-8","Así es la vida.",1250);
articulo[44] = new libro("978-84-95333-73-5","Així és la vida.",1250);
articulo[45] = new libro("978-84-95333-74-2","Tres viajes.",1250);
articulo[46] = new libro("978-84-95333-75-9","Tres viatges.",1250);
articulo[47] = new libro("978-84-95333-84-1","Vic Pupo lo quiere todo.",1250);
articulo[48] = new libro("978-84-95333-85-8","Vic Pupo ho vol tot.",1250);
articulo[49] = new libro("978-84-95333-88-9","Séneca. El camino del sabio.",1683);
articulo[50] = new libro("978-84-95333-86-5","¡Espera, ya voy!.",1250);
articulo[51] = new libro("978-84-95333-87-2","Espera, ja hi vinc!.",1250);
articulo[52] = new libro("978-84-95333-89-6","Peso Cero.",1683);
articulo[53] = new libro("978-84-95333-94-0","La fraternidad. Claro-oscuro de una esperanza.",1154);
articulo[54] = new libro("978-84-96976-02-3","¿Qué es arte?.",1250);
articulo[55] = new libro("978-84-96976-16-0","Filosofía y Ciudadanía. 1º BACHILLERATO. OBRA COMPLETA (4 Cuadernos).",4981);
articulo[56] = new libro("978-84-96976-21-4","Filosofia i Ciutadania. 1º BATXILLERAT. OBRA COMPLETA (4 Quaderns).",4981);
articulo[57] = new libro("978-84-96976-17-7","Filosofía y Ciudadanía. 1º BACHILLERATO. EL SABER FILOSÓFICO (Cuaderno I).",1245);
articulo[58] = new libro("978-84-96976-22-1","Filosofia i Ciutadania. 1º BATXILLERAT. EL SABER FILOSÒFIC (Quadern I).",1245);
articulo[59] = new libro("978-84-96976-18-4","Filosofía y Ciudadanía. 1º BACHILLERATO. EL SER HUMANO: PERSONA Y SOCIEDAD (Cuaderno II).",1245);
articulo[60] = new libro("978-84-96976-23-8","Filosofia i Ciutadania. 1º BATXILLERAT. L'ÉSSER HUMÀ: PERSONA I SOCIETAT (Quadern II).",1245);
articulo[61] = new libro("978-84-96976-19-1","Filosofía y Ciudadanía. 1º BACHILLERATO. FILOSOFÍA MORAL Y POLÍTICA (Cuaderno III).",1245);
articulo[62] = new libro("978-84-96976-24-5","Filosofia i Ciutadania. 1º BATXILLERAT. FILOSOFIA MORAL I POLÍTICA (Quadern III).",1245);
articulo[63] = new libro("978-84-96976-20-7","Filosofía y Ciudadanía. 1º BACHILLERATO. DEMOCRACIA Y CIUDADANÍA (Cuaderno IV).",1245);
articulo[64] = new libro("978-84-96976-25-2","Filosofia i Ciutadania. 1º BATXILLERAT. DEMOCRÀCIA I CIUTADANIA (Quadern IV).",1245);
articulo[65] = new libro("978-84-96976-06-1","Ciudadanía y Derechos Humanos",2212);
articulo[66] = new libro("978-84-96976-14-6","Ciutadania i Drets Humans",2212);
articulo[67] = new libro("978-84-96976-07-8","Ética Cívica 4º ESO",2308);
articulo[68] = new libro("978-84-96976-15-3","Ètica Cívica 4º ESO",2308);
articulo[69] = new libro("978-84-95333-92-6","Filósofos.Vida íntima.",1683);
articulo[70] = new libro("978-84-95333-99-5","La Fidelidad o el amor al desnudo.",1250);
articulo[71] = new libro("978-84-96976-10-8","La hormiga viajera.",1250);
articulo[72] = new libro("978-84-96976-11-5","La formiga viatgera.",1250);
articulo[73] = new libro("978-84-96976-08-5","Quiquiricosas.",1250);
articulo[74] = new libro("978-84-96976-09-2","Quiquiricoses.",1250);
articulo[75] = new libro("978-84-96976-03-0","Pienso, pero ... ¿existo?!.",1346);
articulo[76] = new libro("978-84-95333-98-8","Cuando no puedas con ellos.",1442);
articulo[77] = new libro("978-84-96976-31-3","Tópicos y formas del sexismo.",1346);
articulo[78] = new libro("978-84-96976-13-9","El Budismo.",1346);
articulo[79] = new libro("978-84-96976-12-2","Psicología 1º de Bachillerato.",2740);
articulo[80] = new libro("978-84-96976-33-7","EPICURO: Carta a Meneceo - SÉNECA: Sobre la vida feliz. 2º Bachillerato",1058);
articulo[81] = new libro("978-84-96976-41-2","EPICUR: Lletra a Meneceo - SÈNECA: De la lletra benaurada. 2n Batxillerat",1058);
articulo[82] = new libro("978-84-96976-34-4","DESCARTES, Discurso del método. Partes I-IV. 2º Bachillerato",1058);
articulo[83] = new libro("978-84-96976-42-9","DESCARTES, Discurs del mètode. Parts I-IV. 2n Batxillerat",1058);
articulo[84] = new libro("978-84-96976-32-0","PLATÓN, La República. Libro VI-VII. 2º Bachillerato",1058);
articulo[85] = new libro("978-84-96976-40-5","PLATÓ, La República. Llibres VIé i VIIé. 2n Batxillerat",1058);
articulo[86] = new libro("978-84-96976-35-1","HUME, Compendio de un Tratado de la naturaleza humana (1-25) + Investigación sobre los principios de la moral. Apéndice 1º: Sobre el sentimiento moral ",1058);
articulo[87] = new libro("978-84-96976-43-6","HUME, Compendi d'un Tractat de la naturalesa humana (1-25) + Investigació sobre els principis de la moral. Apèndix 1: Sobre el sentiment moral",1058);
articulo[88] = new libro("978-84-96976-37-5","ROUSSEAU, Profesión de fe del vicario saboyano",1058);
articulo[89] = new libro("978-84-96976-45-0","ROUSSEAU, Professió de fe del vicari savoià",1058);
articulo[90] = new libro("978-84-96976-36-8","KANT, Crítica de la Razón Pura. Prólogo B (2ª edición) VII - XXXVII",1058);
articulo[91] = new libro("978-84-96976-38-2","NIETZSCHE, Crepúsculo de los ídolos",1058);
articulo[92] = new libro("978-84-96976-39-9","MARX, Manifiesto Comunista. Capítulos I y II",1058);
articulo[93] = new libro("978-84-96976-48-1","La danza de los versos.",1250);
articulo[94] = new libro("978-84-96976-49-8","La dança dels versos.",1250);
articulo[95] = new libro("978-84-96976-46-7","NIETZSCHE, Crepúscle dels ídols",1058);
articulo[96] = new libro("978-84-96976-44-3","KANT, Crítica de la Raó Pura. Pròleg B (2a edició) VII - XXXVII",1058);
articulo[97] = new libro("978-84-96976-4-7","La Eutanasia. Una cuestión de dignidad humana.",1346);
articulo[98] = new libro("978-84-96976-51-1","EDUCACIÓN FÍSICA. 1º ESO. Material didáctico.",913);
articulo[99] = new libro("978-84-96976-53-5","EDUCACIÓ FÍSICA. 1er ESO. Material didàctic.",913);
articulo[100] = new libro("978-84-96976-52-8","EDUCACIÓN FÍSICA. 2º ESO. Material didáctico.",913);
articulo[101] = new libro("978-84-96976-54-2","EDUCACIÓ FÍSICA. 2n ESO. Material didàctic.",913);
articulo[102] = new libro("978-84-96976-50-4","Psicopedagogía 1º Bachillerato.",2740);

function libro (isbn, titulo, eurosiniva) {
  this.Isbn = isbn;
  this.Titulo = titulo;  
  this.Eurosiniva = eurosiniva; // linea 36
  this.Cant=0;
  this.Acum=0;
  this.Euroiva = AddDecimal(Math.round(parseFloat(eurosiniva*1.04))); 
  this.DimeDatos = libro_Mostrar_en_Documento;
 
}


function libro_Mostrar_en_Documento() {
 
 document.write("<B>" + "ISBN: " + this.Isbn + "</B><br>");
 document.write("<I><FONT color=#021d60>" + "Título: " + this.Titulo + "</FONT></I><br>");
 document.write("<FONT color=#800000>" + "Precio sin I.V.A.: " + AddDecimal(this.Eurosiniva) + " E" + " / " + "</FONT>");
 document.write("<FONT color=#800000>" + "Precio con I.V.A.: " + this.Euroiva + " E" + "</FONT><br>");
  
}

function AddDecimal(numero){
  var ConDecimal = "";
  var num = "" + numero;
  if (num.length == 0) {
    ConDecimal += "0";
  } else if (num.length == 1) {
    ConDecimal += "0.0" + num;
  } else if (num.length == 2) {
    ConDecimal += "0." + num;
  } else {
  ConDecimal += num.substring(0, num.length - 2);
  ConDecimal += ".";
  ConDecimal += num.substring(num.length - 2, num.length);
  }
  return ConDecimal;
}


function meterencarro(formu) {
unidades=formu.numpedido.value;
descripcion=formu.producto.value;
if (confirm) {
numeroregistro = 0;  
numeroregistro = getcookie("numerodeorden");
numeroregistro++;
if ( numeroregistro > 20 )
     alert("ATENCIÓN\nSu carrito esta lleno.\nPor favor, acceda a la hoja de pedido.\nGracias.");
else {
actualizarbase = formu.numpedido.value + "|"  + formu.precio.value  + "|" + formu.referencia.value + "|" + formu.producto.value;
nuevopedido = "Order." + numeroregistro;
setcookie (nuevopedido, actualizarbase, null, "/");
setcookie ("numerodeorden", numeroregistro, null, "/");

aviso = "LIBRO SELECCIONADO\n\n" + "Cantidad: " + unidades + " unidad/es.\n"
+ "Libro: \n" + descripcion + "\n\nPulse sobre Ver Carro para acceder\na su lista de compra.\nGracias";
alert(aviso);
}
}
}

function getcookieval (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function getcookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen)
        {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) return getcookieval (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
        }
   return null;
}

function setcookie (name,value,expires,path,domain,secure) {
   document.cookie = name + "=" + escape (value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
}

function getcookieval (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
   endstr = document.cookie.length;
 return unescape(document.cookie.substring(offset, endstr));
}

function getcookie (name) {
 var arg = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i < clen)
    {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) return getcookieval (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
    }
  return null;
}

function setcookie (name,value,expires,path,domain,secure) {
   document.cookie = name + "=" + escape (value) +
     ((expires) ? "; expires=" + expires.toGMTString() : "") +
     ((path) ? "; path=" + path : "") +
     ((domain) ? "; domain=" + domain : "") +
     ((secure) ? "; secure" : "");
}

function formatoeuros(input) {
    var euros = Math.floor(input)
    var tmp = new String(input)
    for (var decimalAt = 0; decimalAt < tmp.length; decimalAt++) {
       if (tmp.charAt(decimalAt)==".")
       break;
       }
  var centimos  = "" + Math.round(input * 100)
  centimos = centimos.substring(centimos.length-2, centimos.length)
  euros += ((tmp.charAt(decimalAt+2)=="9")&&(centimos=="00"))? 1 : 0;

  return euros + "." + centimos
}

function quitardelcarrito(RemOrder) {
   if (confirm("El libro seleccionado va a ser eliminado de su carro de la compra.\n¿Esta Vd. de acuerdo?")) {
   numerodeorden = getcookie("numerodeorden");
   for(i=RemOrder; i < numerodeorden; i++) {
       nuevopedido1 = "Order." + (i+1);
       nuevopedido2 = "Order." + (i);
       datos = getcookie(nuevopedido1);
       setcookie (nuevopedido2, datos, null, "/");
       }
       nuevopedido = "Order." + numerodeorden;
       setcookie ("numerodeorden", numerodeorden-1, null, "/");
       deletecookie(nuevopedido,"/");
       location.href=location.href;
    }
}

function visualizarcarrito() {
   numerodeorden = 0;
   subtotal=0;
   preciototal=0;
   numerodeorden = getcookie("numerodeorden");
   tablas = "";
   for (i = 1; i <= numerodeorden; i++) {
    nuevopedido = "Order." + i;
    datos = "";
    datos = getcookie(nuevopedido);
    ficha0 = datos.indexOf("|", 0);
    ficha1 = datos.indexOf("|", ficha0+1);
    ficha2 = datos.indexOf("|", ficha1+1);
    campos = new Array;
    campos[0] = datos.substring( 0, ficha0 );
    campos[1] = datos.substring( ficha0+1, ficha1 );
    campos[2] = datos.substring( ficha1+1, ficha2 );
    campos[3] = datos.substring( ficha2+1, datos.length );
    subtotal = subtotal + (campos[1] * campos[0]);
    preciototal = formatoeuros(subtotal);
    tablas += "<tr style='font: 9pt; text-align: justify; color=white'><td>" + campos[2] + "</td><td  style='color=navy'>"
        + campos[3] + "</td><td>" + campos[1]
        + " €</td><td><input type=text id='inputcarro' size=2 name=\"Cantidad"+ i +"\" value=\""
        + campos[0] + "\"></td>"
        + "<td><input type=button id=boton value=\"  Eliminar  \" onClick=\"quitardelcarrito("+i+")\">"
      	+ "&nbsp;</td>" 
        + "<input type=hidden name=\"Referencia"+ i +"\" value=\"" + campos[2] + "\">"
        + "<input type=hidden name=\"Libro"+ i +"\" value=\"" + campos[3] + "\">"
        + "<input type=hidden name=\"Precio"+ i +"\" value=\"" + campos[1] + "\">";
        }
   document.write(tablas);
   document.write("</td></tr><tr><td colspan=2 style='font: 9pt'>TOTAL CARRITO IVA INCLUIDO</td><td style='color: navy'>");
   document.write(preciototal);
   //--document.write(" €</td><td colspan=2 style='font: 7pt; text-align: center; color=white'><input type=button id=boton value=\"  Seguir comprando  \" onClick=\"parent.history.back()\"> <input type=button id=boton value=\"  Finalizar compra  \" onClick=\"parent.history.back()\"></td>");
   document.write("<tr><td colspan=4 style='font: 6pt'color: navy >NO ESTÁN INCLUIDOS LOS GASTOS DE ENVÍO.Gastos de envío dentro del Estado Español: hasta 1Kg.=5 euros; hasta 3Kg.=6 euros. Más de 3Kg u otros destinos consultar en editilde1@wanadoo.es.</td><td style='color: navy'></td></tr>");
   
   
}

function deletecookie(name, path, domain) {
  if (getcookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
