var av_rotator = new Array();;

function theRotator() {
	
	$('.rotator').each(function(){
		av_rotator.push(this);
		//Set the opacity of all images to 0
		$('ul li', this).css({opacity: 0.0});
		
		//Get the first image and display it (gets set to full opacity)
		$('ul li:first', this).css({opacity: 1.0});
	});
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	for(var i=0; i < av_rotator.length; i++) {
		setTimeout('rotate('+i+')', 2000+Math.round(2000*Math.random()));
	}
	
}

function rotate(pos) {	
	//Get the first image
//	$('.rotator').each(function(){
								
		var current = $('ul li.show', av_rotator[pos]);
	
		//Get next image, when it reaches the end, rotate it back to the first image
		var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('ul li:first', av_rotator[pos]) :current.next()) : $('ul li:first', av_rotator[pos]));	
		
		//Set the fade in effect for the next image, the show class has higher z-index
		next.css({opacity: 0.0})
		.addClass('show')
		.animate({opacity: 1.0}, 1000);
	
		//Hide the current image
		current.animate({opacity: 0.0}, 1000)
		.removeClass('show');
		setTimeout('rotate('+pos+')', 2000+Math.round(2000*Math.random()));
//	});
}

function add_produit(nom, prenom, date) {
	var ul = null;
	ul = document.getElementById("new_groupe_ref");
	num_ligne_prod++;
	var pos = num_ligne_prod;
	var li = document.createElement("LI");
	var html = "<div class='nom' >";
	html += "<input type='text' name='nom_voyageur_"+pos+"' value='"+nom+"'  /></div>";
	html += "<div class='prenom' ><input type='text' name='prenom_voyageur_"+pos+"' value='"+prenom+"' /></div>";
	html += "<div class='date' ><input type='text' name='date_naissance_voyageur_"+pos+"' value='"+date+"' /></div>";
	html += "<div style='float:left;' ><img src='admin/modules/ecommerce/images/plus_bleu.png' onclick=\"add_produit('', '', '');\" style='cursor:pointer;' title='Ajouter une nouvelle personne'  /></div>";	
	html += "<div style='clear:left;' ></div>";
	li.innerHTML = html;
	ul.appendChild(li);
}




