var child_num = 0;
var defaultDelay = 5;
var myDuration = 1;
var myTarget = null;

Event.observe(window, 'load', function() {
	myTarget = $('slide-container');

	homeBannerMove();

	
	$$('#home-tabs a.tab-link').each(function(element){
		new Tip(
			element,				// the element we are attaching the tooltip to
			'&nbsp;',				// content
			{
				className: 'home-hover',
				hook: {target: 'topMiddle', tip: 'bottomMiddle' },
			    offset: {x:0, y:2} 
			}
		);

		element.observe('prototip:shown', function() {
			this.tip.shake();
		});
	});
});


function getNextChildNum(num) {
	if( num == 3 ) {
		return 1;
	} else {
		return num+1;
	}
}

homeBannerMove = function() {
	child_num = getNextChildNum(child_num)
	var num2 = getNextChildNum( child_num );
	var num3 = getNextChildNum( num2 );

	var child1 = $('slide' + child_num);
	var child2 = $('slide' + num2);
	var child3 = $('slide' + num3);
	
	/*
	child1.setAttribute('class', '');
	child2.setAttribute('class', 'hidden');
	child3.setAttribute('class', 'hidden');

	log('ids: child1=' + child1.getAttribute('id') + '; child2=' + child2.getAttribute('id') + '; child3=' + child3.getAttribute('id'));
	log('classes: child1=' + child1.getAttribute('class') + '; child2=' + child2.getAttribute('class') + '; child3=' + child3.getAttribute('class'));
	*/

	new Effect.Opacity(child1,	{ from: 0,		to: 1.0,  			duration: 0,		 	delay: 0,				queue: { position: 'end', scope: 'transition' } } );
	new Effect.Opacity(child2,	{ from: 1.0,	to: 0,  			duration: 0,		 	delay: 0,				queue: { position: 'end', scope: 'transition' } } );
	new Effect.Opacity(child3,	{ from: 1.0,	to: 0,  			duration: 0,		 	delay: 0,				queue: { position: 'end', scope: 'transition' } } );
	new Effect.Opacity(child2,	{ from: 0,		to: 1.0,			duration: 0,		 	delay: defaultDelay,	queue: { position: 'end', scope: 'transition' } } );
	new Effect.Move(myTarget,	{ x: -950,	y: 0, mode: 'relative', duration: myDuration,	delay: 0,				queue: { position: 'end', scope: 'transition' } } );
	new Effect.Move(child1,		{ x: +2850,	y: 0, mode: 'relative', duration: 0, 			delay: 0, 				queue: { position: 'end', scope: 'transition' }, afterFinish: homeBannerMove } );
}
