/**
 * @author rico
 */

//------------------------------------------------------------------------------------

Cufon.replace('h1, h2, h3, a, p', { fontFamily: 'Rotis', hover: true });


//------------------------------------------------------------------------------------
/**
 * @author rico
 */

//------------------------------------------------------------------------------------

Cufon.replace('h1, h2, h3, a, p', { fontFamily: 'Rotis', hover: true });


//------------------------------------------------------------------------------------

var IMAGES = {
	duration:1200,
	wait:3000,
	fx:null,
	active:0,
	nodes:[]
};

function init_slideshow() {
	if( $('slideshow-container') ) {
		var container = $('slideshow-container');
		IMAGES.nodes = container.getChildren('img');
		if( IMAGES.nodes.length > 1 ) {
			IMAGES.nodes = IMAGES.nodes.shuffle();
			var activeNode = IMAGES.nodes[0];
			activeNode.setOpacity(0);
			activeNode.style.display = 'block';
			setInterval(function() {
				change_image();
			},IMAGES.wait);
			IMAGES.fx = new Fx.Morph( activeNode, { duration:IMAGES.duration});
			IMAGES.fx.start({opacity:1});
		}
	}
}

window.addEvent('domready',function(){ init_slideshow(); });

//------------------------------------------------------------------------------------

function change_image() {
	
	var activeNode = IMAGES.nodes[IMAGES.active];
	IMAGES.active = ( IMAGES.active >= IMAGES.nodes.length-1 ) ? 0 : IMAGES.active+1;
	var nextNode = IMAGES.nodes[IMAGES.active];
	
	activeNode.style.zIndex = 10;
	activeNode.style.visibility = 'visible';
	activeNode.style.display = 'block';
	
	nextNode.style.zIndex = 2;
	nextNode.style.visibility = 'visible';
	nextNode.style.display = 'block';
	
	IMAGES.fx = new Fx.Morph( activeNode, { duration:IMAGES.duration,onComplete:function() {
		activeNode.style.display = 'none';
		activeNode.setOpacity(1);
		activeNode.style.zIndex = 2;
	}});
	
	IMAGES.fx.start({opacity:0});
}

//------------------------------------------------------------------------------------
