
Effect.Bounce = function(element, options) {
  element = $(element);
  var opt = Object.extend({
  	height : 20,//100,
		fps : 100
  }, {} | options);
  var oldStyle = {
    top: element.getStyle('top'),
    left: element.getStyle('left') };
    var h = opt.height;
		var f = opt.fps;
    return new Effect.Move(element,
      { x: 0, y: 0-h,duration: 0.17, fps:f, afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x: 0, y: h, duration: 0.18, fps:f, afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x: 0, y: 0-(Math.round(h*0.4)), duration: 0.16, fps:f, afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x: 0, y: Math.round(h*0.4), duration: 0.14, fps:f, afterFinishInternal: function(effect) {
        effect.element.undoPositioned();
        effect.element.setStyle(oldStyle);
      }}) }}) }}) }});
}


/*
* Class: Bouncer
* Written by: Andrew Tetlaw http://tetlaw.id.au
* takes a list and performs a bounce effect on a random list element at a regular interval
* Option:default
* interval:2 // how often to bounce a list item
*/
var Bouncer = Class.create();

Bouncer.prototype = {
	initialize : function(element, options) {
		this.element = $(element);
		this.options = Object.extend({
	  	interval : 1
 	 }, {} | options);
		this.items = $A(this.element.getElementsByTagName('IMG'));
		var i = this.options.interval;
		new PeriodicalExecuter(this.bounceRandom.bind(this), i);
	},
	bounceRandom : function() {
		var idx = Math.round(Math.random()*(this.items.length-1));
		new Effect.Bounce(this.items[idx]);
	}
}

