/**
 * @package WordPress 
 * @subpackage Fastline_Theme 
 * @author : Nicolas Vakenberg (valkenbergn@gmail.com), based on wordpresse default theme
 */
 
var maxImg = 1;
var dur = 500;
var timeout = 3000;


var img = 0;
function show(id) {
	var obj = $(id);
	if (obj != null) {
		obj.set('styles', {
	        'visibility' : 'visible',
	        'z-index' : '100'
	    });
	}
}
function hide(id) {
	var obj = $(id);
	if (obj != null) {
		obj.set('styles', {
	        'visibility' : 'hidden',
	        'z-index' : '99'
	    });
	}
}
function showHide(idToShow, idToHide) {
	show(idToShow);
	hide(idToHide);
}
function transition(idFrom, idTo) {
	var from = $(idFrom);
	var to = $(idTo);
	if (from != null && to != null) {
		to.set('styles', {
	        'visibility' : 'hidden'
	    });
		from.set('styles', {
			        'visibility' : 'visible'
			    });
		to.set('styles', {
			        'z-index' : '100'
			    });
		from.set('styles', {
			        'z-index' : '99'
			    });
		var fx = new Fx.Tween(to, {duration: dur});
		setTimeout('showHide("' + idTo + '", "' + idFrom + '")', dur + 1);
		fx.start('opacity', '0', '1');
	}
}
function changeImg() {
	if (maxImg > 1) {
		var prefix = 'slideshow_a';
		var currentImg = prefix + img;
		img++;
		if (img >= maxImg) {
			img = 0;
		}
		var nextImg = prefix + img;
		transition(currentImg, nextImg);
	}
}

function slideshow() {
	changeImg();
	setTimeout('slideshow()', timeout);
}

window.addEvent('domready', function() {
	setTimeout('slideshow()', timeout);
});
