/*
mooSimpleSlide - Simple SlideShow Class
version: 0.4
copyright 2008 07 25 - Huug Helmink, Ace Group bv


mootools v.1.2 classes
Core: Core, Browser
Native: Array, Function, Number, String, Hash
Class: Class, Class.Extras
Element: Element, Element.Style
Fx: Fx, Fx.CSS, Fx.Tween


Usage:
Usage:
  var mySlideShow = new mooSimpleSlide([images::array]);
    or
  var mySlideShow = new mooSimpleSlide([images::array],{period:[interval between images in ms::integer]});
  mySlideShow.displayImage();
*/
var mooSimpleSlide = new Class({
  Implements: Options,
  options: {
    period: 0
  },
  initialize: function(imageArray,options) {
    // Check if imageArray is an array
    if($type(imageArray) != 'array') return;
    
    this.images = imageArray;
    this.setOptions(options);
    this.active = this.images.length-1;
    this.max = this.images.length;
    
    // Set styles so images will fade in and out nicely
    this.images.each(function(img) {
      img.setStyles({
        'display': 'none',
        'position':'absolute',
		'width':'100%'
      }).fade('in');
    });
	$('home_player_infos').fade('in');
    
    // If period options is set > 0, periodical display an image
    if(this.options.period > 0) this.displayImage.periodical(this.options.period,this);
  },

  displayImage: function() {
    var FxTransitionTime = this.options.period/2;
    
    // Hide image
    this.images[this.active].get('tween',{property:'opacity', duration:FxTransitionTime, onComplete:function(item) {
      item.setStyle('display','none');
    }}).start(1,0);
    
    // Set next image or the first
    this.active < this.max-1 ? this.active++ : this.active = 0;
	var activeItem = this.active;
    
    // Show image
    this.images[this.active].get('tween',{property:'opacity', duration:FxTransitionTime, onStart:function(item) {
      item.setStyle('display','inline');
	  $$('#home_player_infos h5').fade('out');
	  $$('#home_player_infos h5')[activeItem].fade('in');
    }}).start(0,1);
  }
});
