/**
* Simple Slide Show v.0.1
* @author Enrique Erne
* @copyright 2008 MILD
* @license GPL V2 or newer
*/

var active;
var imgsCount;


function fadeIn (pic) {
	var opacityChange = new Fx.Style(pic, 'opacity', {duration:2000});	opacityChange.start(0, 1);
}

function fadeOut (pic) {
	var opacityChange = new Fx.Style(pic, 'opacity', {duration:2000});	opacityChange.start(1, 0);
}

function slideShow () {
	//$E('#logo').setHTML(imgsCount);
	var i = 0;
	$ES('#slideShow img').each(function(el) {
		i++;
		if (active === imgsCount) {
			el.setOpacity(1);
		}
		if (active === i) {
			// document.loginfrm.username.value = active;

			if (active === 1) {
				fadeIn($ES('#slideShow img').getLast());
				active  = imgsCount+1;
			} else {
				fadeOut(el);
			}
		}
	});
	active--;
}
window.addEvent('domready', function(){
	if ( $chk($E('#slideShow')) ) {
		$ES('#slideShow img').setOpacity(0);
		var slide;
		imgsCount = $E('#slideShow').getChildren().length;
		active = 1;
		
		(function(){slideShow()}).delay(2000);
		slideShow.periodical(5000, slide);
	}});

// blend
/*window.addEvent('domready', function(){
	if ( $chk($E('.blendIn')) ) {
		$ES('.blendIn').each(function(el) {
			el.setOpacity(0);
			var blendIn = new Fx.Style(el, 'opacity', {duration:2000});			blendIn.start(0, 1);
		});
	}});*/
