function GimmickVerschubStart()
{
  if(this.running)
    return
  this.running = true
  if(document[this.id])
  {
    this.pos              = parseInt(document[this.id].top)
    document[this.id].top += this.verschub
    setTimeout(this.name + ".end(" + document[this.id].top + ")", this.duration)
  }
  else
  {
    this.pos                     = parseInt(window[this.id].style.posTop)
    window[this.id].style.posTop += this.verschub
    setTimeout(this.name + ".end(" + parseInt(window[this.id].style.posTop) + ")", this.duration)
  }
}

function GimmickVerschubEnde(akt_pos)
{
  if(akt_pos > this.pos)
    akt_pos--
  if(document[this.id])
  {
    document[this.id].top = akt_pos
  }
  else
  {
    window[this.id].style.top = akt_pos
  }
  if(akt_pos == this.pos)
    setTimeout(this.name + ".running = false", this.duration_wait)
  else
    setTimeout(this.name + ".end(" + akt_pos + ")", this.duration_effect)
}

function GimmickVerschub(id, name)
{
  this.verschub        = 24
  this.duration        = 1000
  this.duration_effect = 50
  this.duration_wait   = 3000
  this.running         = false
  this.id              = id
  this.name            = name
  this.pos             = 0
  this.start           = GimmickVerschubStart
  this.end             = GimmickVerschubEnde
}

// --- Gimmick Erdbeben ---

function GimmickErdbebenStart()
{
  if(this.running)
    return
  this.running = true
  this.counter = 0
  if(document[this.id])
  {
    this.pos = parseInt(document[this.id].top)
    setTimeout(this.name + ".end()", this.duration_effect)
  }
  else
  {
    this.pos = parseInt(window[this.id].style.posTop)
    setTimeout(this.name + ".end()", this.duration_effect)
  }
}

function GimmickErdbebenEnde(akt_pos)
{
  var welle = this.hoehe * Math.sin(Math.PI * this.increment * this.counter) *
              ((this.max_counter - this.counter) / this.max_counter)
  if(document[this.id])
    document[this.id].top = this.pos + welle
  else
    window[this.id].style.posTop = this.pos + welle
  this.counter++
  if(this.counter == this.max_counter)
  {
    if(document[this.id])
      document[this.id].top = this.pos
    else
      window[this.id].style.posTop = this.pos
    setTimeout(this.name + ".running = false", this.duration_wait)
  }
  else
    setTimeout(this.name + ".end()", this.duration_effect)
}

function GimmickErdbeben(id, name)
{
  this.hoehe           = 20
  this.duration_effect = 5
  this.duration_wait   = 1000
  this.running         = false
  this.id              = id
  this.name            = name
  this.increment       = .1
  this.pos             = 0
  this.counter         = 0
  this.max_counter     = 100
  this.start           = GimmickErdbebenStart
  this.end             = GimmickErdbebenEnde
}

// --- Gimmick HinUndHer ---

function GimmickHinUndHerStart()
{
  if(this.running)
    return
  this.running = true
  this.counter = 0
  if(document[this.id])
  {
    this.pos = parseInt(document[this.id].left)
    setTimeout(this.name + ".end()", this.duration_effect)
  }
  else
  {
    this.pos = parseInt(window[this.id].style.posLeft)
    setTimeout(this.name + ".end()", this.duration_effect)
  }
}

function GimmickHinUndHerEnde(akt_pos)
{
  var welle = this.hoehe * Math.sin(Math.PI * this.increment * this.counter) *
              ((this.max_counter - this.counter) / this.max_counter)
  if(document[this.id])
    document[this.id].left = this.pos + welle
  else
    window[this.id].style.posLeft = this.pos + welle
  this.counter++
  if(this.counter == this.max_counter)
  {
    if(document[this.id])
      document[this.id].left = this.pos
    else
      window[this.id].style.posLeft = this.pos
    setTimeout(this.name + ".running = false", this.duration_wait)
  }
  else
    setTimeout(this.name + ".end()", this.duration_effect)
}

function GimmickHinUndHer(id, name)
{
  this.hoehe           = 20
  this.duration_effect = 5
  this.duration_wait   = 1000
  this.running         = false
  this.id              = id
  this.name            = name
  this.increment       = .1
  this.pos             = 0
  this.counter         = 0
  this.max_counter     = 100
  this.start           = GimmickHinUndHerStart
  this.end             = GimmickHinUndHerEnde
}

// --- Gimmick Spirale ---

function GimmickSpiraleStart()
{
  if(this.running)
    return
  this.running = true
  this.counter = 0
  if(document[this.id])
  {
    this.pos_x = parseInt(document[this.id].left)
    this.pos_y = parseInt(document[this.id].top)
    setTimeout(this.name + ".end()", this.duration_effect)
  }
  else
  {
    this.pos_x = parseInt(window[this.id].style.posLeft)
    this.pos_y = parseInt(window[this.id].style.posTop)
    setTimeout(this.name + ".end()", this.duration_effect)
  }
}

function GimmickSpiraleEnde(akt_pos)
{
  var r_x = this.radius * Math.sin(Math.PI * this.increment * this.counter) *
            Math.sin(Math.PI * this.counter / this.max_counter)
  var r_y = this.radius * Math.cos(Math.PI * this.increment * this.counter) *
            Math.sin(Math.PI * this.counter / this.max_counter)
  if(document[this.id])
  {
    document[this.id].left = this.pos_x + r_x
    document[this.id].top  = this.pos_y + r_y
  }
  else
  {
    window[this.id].style.posLeft = this.pos_x + r_x
    window[this.id].style.posTop  = this.pos_y + r_y
  }
  this.counter++
  if(this.counter == this.max_counter)
  {
    if(document[this.id])
    {
      document[this.id].left = this.pos_x
      document[this.id].top  = this.pos_y
    }
    else
    {
      window[this.id].style.posLeft = this.pos_x
      window[this.id].style.posTop  = this.pos_y
    }
    setTimeout(this.name + ".running = false", this.duration_wait)
  }
  else
    setTimeout(this.name + ".end()", this.duration_effect)
}

function GimmickSpirale(id, name)
{
  this.radius          = 8 //24
  this.duration_effect = 5
  this.duration_wait   = 1000
  this.running         = false
  this.id              = id
  this.name            = name
  this.increment       = .05
  this.pos_x           = 0
  this.pos_y           = 0
  this.counter         = 0
  this.max_counter     = 150
  this.start           = GimmickSpiraleStart
  this.end             = GimmickSpiraleEnde
}

