// Script de la bannière du site www.onyx-metal.fr //
// Copyright REDBLAST //

var guitarWidth;
var guitarHeight;
var motifWidth;
var motifInc;

var motifDecal;
var tempo2;

function initGuitarOnyx() {
  motifWidth = 20;
  motifInc = 8;

  var guitarDeform = document.getElementById("guitarOnyxDeform");
  guitarDeform.style.display = "block";

  var guitar = document.getElementById("guitarOnyx");
  guitarWidth = guitar.offsetWidth;
  guitarHeight = guitar.offsetHeight;

  motifDecal = guitarWidth + motifWidth;
  tempo2 = 0;
  
  setGuitarMotif(motifDecal);

  setInterval("updateGuitarOnyx()", 30);
}

function updateGuitarOnyx() {
  if (motifDecal < guitarWidth)
    motifDecal += motifInc;
  else {
    if (tempo2 < 100) {
      tempo2++;
      return;
    } else
      tempo2 = 0;
    motifDecal = -motifWidth;
  }

  setGuitarMotif(motifDecal);
}

function setGuitarMotif(decal) {
  var guitarDeform = document.getElementById("guitarOnyxDeform");

  guitarDeform.style.left = decal + "px";
  guitarDeform.style.top = "0px";
  guitarDeform.style.width = motifWidth + "px";
  guitarDeform.style.height = guitarHeight + "px";
  guitarDeform.style.backgroundPosition = -decal + "px 0px";
}
