/***************************************************************
 *  Copyright notice
 *
 *  (c) 2010 Benjamin Bergmann <b.bergmann@exinit.de>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
 *
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/

/**
 * The Fader class for the Exinit FX package
 *
 * @version 1.0.0
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
 */
var ExinitFXFader = new Class({
	Extends: ExinitFX,
	
	start: function() {
		var styles = new Hash();
		styles.include('position', 'absolute');
		styles.include('top', '0');
		styles.include('left', '0');
			
		var i = 0;
		this.items.each(function(item) {
			
			item.setStyles(styles);
			
			if (i != this.startIndex - 1) {
				item.set('opacity', 0);
			} else {
				item.set('opacity', 100);
			}
			i++;
		}.bind(this));
	},
	
	doProcess: function(noFX) {
		if (noFX) {
			this.items[this.prevIndex].set('opacity', 0);
			this.items[this.currentIndex].set('opacity', 1);
		} else {
			this.items[this.prevIndex].fade('out');
			this.items[this.currentIndex].fade('in');
		}
	}
});
