/* ***** Begin ***************************************************** */
function fadeObject(id, c1, c2, s1, s2) {
  var self = this;
  this.id      = id;
  this.elem    = false;
  this.colour  = {
    stt: [parseInt(c1.substr(0, 2), 16), parseInt(c1.substr(2, 2), 16), parseInt(c1.substr(4, 2), 16)],
    end: [parseInt(c2.substr(0, 2), 16), parseInt(c2.substr(2, 2), 16), parseInt(c2.substr(4, 2), 16)],
    now: [parseInt(c1.substr(0, 2), 16), parseInt(c1.substr(2, 2), 16), parseInt(c1.substr(4, 2), 16)]
  };
  this.steps   = [s1, s2];
  this.dir     = false;
  this.active  = false;
  this.queue   = [];
  this.msg     = [];
  this.message = 0;
  function d2h(num) {
    num = Math.round(num);
    return ((num < 16) ? "0" : "") + num.toString(16);
  }
  this.fade = function(message, direction) {
    this.elem = this.elem || document.getElementById(this.id);
    this.queue.push([message, direction]);
    for (var x = 0; x < this.queue.length; x++) {
      for (var y = x + 1; y < this.queue.length; y++) {
        if (this.queue[x][0] == this.queue[y][0] && this.queue[x][1] != this.queue[y][1]) {
          this.queue.splice(x, 1);
          this.queue.splice(y - 1, 1);
        }
      }
    }
    if (!this.active) setTimeout(function() { self.fadeLoop(); }, 0);
  };
  this.fadeLoop = function() {
    if (!this.active && this.queue.length) {
      if (this.dir && this.message != this.queue[0][0]) this.queue.unshift([this.message, false]);
      var msg = this.queue.shift();
      if (this.msg[msg[0]]) {
        this.active = true;
        this.elem.innerHTML = this.msg[this.message = msg[0]];
        this.dir = msg[1];
      }
    }
    if (this.dir) {
      var c1 = this.colour.stt, c2 = this.colour.end, s = this.steps[0];
    } else var c1 = this.colour.end, c2 = this.colour.stt, s = this.steps[1];
    for (var x = 0, cnow = "", inc = 0; x < 3; x++) {
      this.colour.now[x] += inc = (c2[x] - c1[x]) / s;
      cnow += this.colour.now[x] = (inc < 0) ? Math.max(this.colour.now[x], c2[x]) : Math.min(this.colour.now[x], c2[x]);
    } this.elem.style.color = "#" + d2h(this.colour.now[0]) + d2h(this.colour.now[1]) + d2h(this.colour.now[2]);
    if (cnow == c2.join("")) {
      this.active = false;
      if (!this.queue.length) {
        if (!this.dir) {
          if (this.msg[0]) {
            this.queue.push([0, true]);
            setTimeout(function() { self.fadeLoop(); }, 0);
          } else this.elem.innerHTML = "&nbsp;";
        }
      } else setTimeout(function() { self.fadeLoop(); }, 0);
    } else setTimeout(function() { self.fadeLoop(); }, 0);
  };
  if (window.addEventListener) {
    window.addEventListener('load', function() { self.fade(0, true); }, false); 
  } else if (window.attachEvent)
    window.attachEvent('onload', function() { self.fade(0, true); });
}
/* ***** End ******************************************************* */




/* *****
 * User defined fade objects and messages
 *
 * These messages are used in fades triggered by mouseovers and
 * mouseouts on table cells.  They are the simplest type of fade and
 * require no extra Javascript code.
 */
 
var fader = new Array();

/* *****
 * The code below describes how to make a throbbing or automatic fade
 * sequence of messages.  It is important to note that this function is
 * NOT part of the Buffered Text-Fade Effect, but merely an example of
 * how it can be used.  In this example, the throb() function controls
 * the commands which are sent to the fade engine; it is called
 * repeatedly at set time intervals rather than using mouseover events
 * as triggers.
 *
 * Notes:
 * - A global array "hash" is used to keep track of where each
 *   animation is currently in the sequence.
 * - The list of messages defined in the fader *must* start at one (1)
 *   and count upwards without skipping any integers.
 * - The third line of the throb() function controls how fast
 *   commands get sent to the fade engine.  It waits only 100 milli-
 *   seconds when fading out, but 5000 milliseconds (5 seconds) when
 *   fading in; this means the message will remain visible for about 5
 *   seconds before fading out again.
 *
 * Other types of fade animation are possible simply by designing
 * different ways to control the fade-ins and fade-outs!
 */
var hash = new Array();
function throb(item) {

  // If the hash array does not have an entry for this item, initialise it at 2
  if (!hash[item]) hash[item] = 2;

  // Send a fade command using the hash array to tell us what parameters we should use
  fader[item].fade(Math.floor(hash[item] / 2), !(hash[item] % 2));

  // Call this function again for this same item after a certain amount of time
  setTimeout(function() { throb(item); }, (hash[item] % 2) ? 100 : 8000);

  // If we have exceeded the number of messages in this fader, start over again at 2
  if (++hash[item] > fader[item].msg.length * 2 - 1) hash[item] = 2;
}

fader[2] = new fadeObject('fade2', '000000', 'FFFFFF', 50, 30);

fader[2].msg[1] = "&ldquo;Sergio ha conseguido dar una vuelta de tuerca al género creando una mezcla entre Frankenstein y los zombis de Romero. Una obra de arte dentro de la literatura zombi que acercará el género al gran público.&rdquo;<br /><span>&mdash; Álvaro Fuentes</span>";

fader[2].msg[2] = "&ldquo;¡¡¡¡EXCELENTE!!!!! Realmente excelente tu historia. Me la he leído de una sola vez y debo decirte que es más que adictiva. Los detalles, el protagonista, el escenario… realmente te has esmerado en ella.&rdquo;<br /><span>&mdash; Moblade</span>";

fader[2].msg[3] = "&ldquo;Sinceramente, tienes madera para escribir. Esta historia es total y completamente excelente.&rdquo;<br /><span>&mdash; Moblade</span>";

fader[2].msg[4] = "&ldquo;Definitivamente ya no se como felicitarte por tu relato, tocas lo más profundo de la sensibilidad humana con cada línea que escribes.&rdquo;<br /><span>&mdash; Moblade</span>";

fader[2].msg[5] = "&ldquo;Increíble, simplemente increíble.&rdquo;<br /><span>&mdash; SuperTruper!</span>";

fader[2].msg[6] = "&ldquo;Esta historia es como un buen vino, proviene de buena uva, ha madurado bien en la vida, se ha trabajado con cariño, y te estimula cada sentido en su justa medida al degustarlo.&rdquo;<br /><span>&mdash; Apicio</span>";

fader[2].msg[7] = "&ldquo;Impresionante, soberbia, magistral. ¡Gran historia, sí Señor!.&rdquo;<br /><span>&mdash; Garraty</span>";

fader[2].msg[8] = "&ldquo;Hace ya tiempo que le vengo siguiendo el rastro a este maravilloso relato, pero siempre posponía el comentario sobre el mismo, pues cualquier cosa buena que decir respecto al mismo parece poca...Sólo puedo decir que es una de las mejores historias que se cocinan en este foro, y que te aliento a continuarla porque nos tienes enganchados a tus lectores, totalmente....&rdquo;<br /><span>&mdash; Zankuro</span>";

fader[2].msg[9] = "&ldquo;Magnífica, conmovedora, brutal me faltan palabras. Gracias, kinea, por tan maravillosa historia.&rdquo;<br /><span>&mdash; Balthazar</span>";

fader[2].msg[10] = "&ldquo;El relato es bueno y se pone cada vez mejor....¡¡¡me sacaste las lagrimas!!!.&rdquo;<br /><span>&mdash; Cadejo</span>";

fader[2].msg[11] = "&ldquo;Quisiera que esta historia fuera un libro para poder leer sin interrupción constantemente hasta su conclusión.&rdquo;<br /><span>&mdash; Oinkzombie</span>";

fader[2].msg[12] = "&ldquo;¡Increible! Tu historia es fenomenal.&rdquo;<br /><span>&mdash; adsabg1</span>";

fader[2].msg[13] = "&ldquo;Definitivamente, tu historia es de las que engancha y uno no se puede desenchufar... Hombre, tienes un don, y aquí­ seguiré expectante para seguir leyendo cómo le sigues dando rienda suelta....&rdquo;<br /><span>&mdash; Zankuro</span>";

fader[2].msg[14] = "&ldquo;Es muy interesante, llena de acción, suspenso y drama. Me conmueve tu historia, y no cualquiera me produce ese efecto.&rdquo;<br /><span>&mdash; NecrogeorgeX</span>";

fader[2].msg[15] = "&ldquo;De verdad que es uno de los mejores relatos que he leído.... Excelente.&rdquo;<br /><span>&mdash; Jess PArr</span>";

fader[2].msg[16] = "&ldquo;Increíble historia, nunca hubiera pensado que podría cogerle cariño a un zombi, pero es que este Erico tiene carisma.&rdquo;<br /><span>&mdash; Dirt_diver</span>";

fader[2].msg[17] = "&ldquo;Tío, te sales. Ojalá tuviera yo esa elocuencia al teclado. Me encantan tus descripciones. Aquí tienes a un fiel lector.&rdquo;<br /><span>&mdash; Supereze</span>";

fader[2].msg[18] = "&ldquo;Eres bueno, cabrón. Esa forma de escribir y de narrar la historia de Erico es simplemente excelente.&rdquo;<br /><span>&mdash; Julio 11998877</span>";

fader[2].msg[19] = "&ldquo;Esta entrada me encantó. Realmente es una historia muy bella. Haces énfasis en la especie humana y sus sentimientos.&rdquo;<br /><span>&mdash; Cadejo</span>";

fader[2].msg[20] = "&ldquo;Te mereces una ovación de pie por un relato tan bueno como el que llevas... sinceramente lo considero uno de los mejores, y sin duda ya es para mi una gema dentro de la literatura zombi, que ni una sola línea se desperdicia....&rdquo;<br /><span>&mdash; Zankuro</span>";

fader[2].msg[21] = "&ldquo;Qué gran relato, de verdad.. Me tienes super pegada a la página... Por favor, no dejes de escribirlo... ¡Excelente!.&rdquo;<br /><span>&mdash; iva_204</span>";

fader[2].msg[22] = "&ldquo;Este es, hoy por hoy, el mejor relato de los que se están publicando. Está escrito en una extraña forma que más parece que se trate de una confesión, es totalmente grandioso y sobretodo diferente a lo que he leído hasta ahora.&rdquo;<br /><span>&mdash; XXX</span>";

fader[2].msg[23] = "&ldquo;Soberbio.&rdquo;<br /><span>&mdash; Garraty</span>";

fader[2].msg[24] = "&ldquo;Coño, eres un puto maestro. Disculpen la expresión, pero es que no se me ocurre nada mejor para definirlo.&rdquo;<br /><span>&mdash; Balthazar</span>";

fader[2].msg[25] = "&ldquo;Felicidades, Kinea. Has logrado algo que pocos han logrado hacer en mí últimamente; recordarme que los sentimientos son por lo que vale la pena vivir, sigue así..&rdquo;<br /><span>&mdash; adsabg1</span>";

fader[2].msg[26] = "&ldquo;No sé si te valdrá de algo, pero llevo pegado al PC aproximadamente 15 horas en dos tandas leyéndote.&rdquo;<br /><span>&mdash; Badfun</span>";

fader[2].msg[26] = "&ldquo;Nuevo lector publicando su comentario. Muy buena tu historia. Me quedé todo 1 día leyendo por que me intrigó la 1ª entrada y así termine; queriendo más.&rdquo;<br /><span>&mdash; Kael</span>";

fader[2].msg[27] = "&ldquo;Tremendamente original, y además muy bien escrita.&rdquo;<br /><span>&mdash; Apicio</span>";

// Start this fader
setTimeout(function() { throb(2); }, 1000);
