/**
 * 
 */
var toutVerso = new Array()
/**
 * 
 */
var toutRecto = new Array()
/**
 * 
 * @param n
 * @return
 */
function toutJouer(n){
	if( $$('#puzzle div.bloc-contenu.verso').size() >= $$('#puzzle div.bloc-contenu.recto').size() ) { 
		retourneToutVerso(0);
	} else {
		retourneToutRecto(0);
	}
}
/**
 * 
 * @param n
 * @return
 */
function retourneToutVerso(n) {
	if(n==0) {
		toutVerso = $$('#puzzle div.bloc-contenu.verso').toArray();
	}
	if(n<toutVerso.length){
		element = toutVerso[n];
		tourne(element);
		n++;
		window.setTimeout('retourneToutVerso('+n+')',80);
	}
}
/**
 * 
 * @param n
 * @return
 */
function retourneToutRecto(n){
	if(n==0){
		toutRecto = $$('#puzzle div.bloc-contenu.recto').toArray();
	}
	if(n<toutRecto.length){
		element = toutRecto[n];
		tourne(element);
		n++;
		window.setTimeout('retourneToutRecto('+n+')',80)
	}
}
/**
 * 
 * @return
 */
function voirAnim(){
	anim();
}
/**
 * 
 * @return
 */
function rejouerIntro(){
	$$('.bloc').each(function(o,index) {
		position_depart(o,index);
	})
	$('body').addClassName('nofirst');
}
/**
 * 
 * @return
 */
function anim(){
	if($('slogan').hasClassName('ouvert')){
		new Effect.Morph('slogan', {
			style: 'height: 1px; background: #C9A886',
			afterFinish: function(){
				$('slogan').removeClassName('ouvert');
				$('slogan').setStyle({background:'',height:''});
				//$('accroche').setStyle({visibility:''});
				$('cache').removeClassName('ouvert');
			},
			beforeStart:function(){
				if($('page').hasClassName('variante2')){$('bloc_3').setStyle({display:''})};
				if($('body').hasClassName('v2')&&!$('body').hasClassName('nofirst')){
					//rejouerIntro();
				}
			},
			duration: 0.8
		});		
	}else{
/*		new Effect.Morph('slogan', {
			style: 'height: 100px; background: #666', 
			beforeStart: function(){$('accroche').setStyle({visibility:'hidden'})},
			duration: 0.1,
			queue: 'front'
		});
*/
		new Effect.Morph('slogan', {
			style: 'height: 585px; background: #fff', 
			beforeStart: function(){
				$('cache').addClassName('ouvert');
				//$('accroche').setStyle({visibility:'hidden'});
				if($('page').hasClassName('variante2')){$('bloc_3').setStyle({display:'none'})};
			},
			afterFinish: function(){$('slogan').addClassName('ouvert')},
			duration: 0.7,
			queue: 'end'
		});
	}
}