/*
mooSimpleSlide - Simple SlideShow Class
version: 0.3
copyright 2008 04 02 - Huug Helmink, Ace Group bv


mootools v.1.11 classes
Core: Core
Class: Class, Class.Extras
Native: Array, String, Function, Number, Element
Fx: Fx.Base, Fx.Style


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({
  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 = 0;
    this.max = this.images.length;
	this.active = (this.max - 1);

    
    // Set styles so images will fade in and out nicely
    this.images.each(function(img) {
      img.setStyles({
        'display': 'none',
		'position': 'absolute',
        'opacity': 0
      });
    });
    this.images[0].getParent().setStyle('position','relative');
	if(window.ie)
	{
		this.images[0].getParent().setStyle('left',-570);
	}


    
    // 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/5;
	
		// Hide image
    this.images[this.active].effect('opacity',{duration:FxTransitionTime,onComplete:function(item) {
      item.setStyle('display','none');
    }}).start(1,0);
	
    
    // Set next image or the first
    if(this.active < this.max-1)
	{
		this.active++;
	} else {
		this.active = 0;
	}
    
    // Show image
    this.images[this.active].effect('opacity',{duration:FxTransitionTime,onStart:function(item) {
      item.setStyle('display','block');
    }}).start(0,1);
	


	
	
	
  }
});
mooSimpleSlide.implement(new Options);