Event.observe(window, 'load', body_load, false);

function body_load() {
  var ptd_top = $('proyector')
  if (ptd_top) {
    diaporama(ptd_top, $('diapo'), '/themed/visimport.com/img/promos/promo', 4, 'appear', 2, 4)
  }

  $A($$("a.deleteJS")).each(deleteClick);
}

function diaporama(e, i, base, counter, eff, dur, inter) {
  var count = counter + 1

  do {
   count --
   var img = document.createElement("img")
   img.src = base + count + ".jpg"
   img.id  = 'img' + count
   img.style.position = 'absolute'
   img.style.marginTop = '13px'
   img.style.marginLeft = '-521px'
   img.style.display = (count == 1)? 'inline' : 'none'
   e.appendChild(img)
  } while (count != 1)

  i.style.height = '0px'

  setInterval(function() {
    Effect.toggle('img' + ((count == 0)? 1 : count), eff,  { duration: dur })
    Effect.toggle('img' + ((count == 0)? counter : count + 1), eff, { duration: dur })
    count = (count == (counter - 1))? 0 : count +1
  },inter * 1000);
}

function deleteClick(a) {
  a.onclick = function() {
    var msg = this.warning? this.warning : '¿Está seguro de querer borrar este registro?'
    if(confirm(msg)) {
      this.href += '/OK';
      return true
    }
    return false
  }
}
