/**
 * 
 * @return
 */
function afficherAnim(){

}
/**
 * 
 * @param el
 * @param radioGroup
 * @return
 */
function $RF(el, radioGroup) {
    if($(el).type && $(el).type.toLowerCase() == 'radio') {
        var radioGroup = $(el).name;
        var el = $(el).form;
    } else if ($(el).tagName.toLowerCase() != 'form') {
        return false;
    }
    var checked = $(el).getInputs('radio', radioGroup).find(
        function(re) {return re.checked;}
    );
    return (checked) ? $F(checked) : null;
}

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 retirerAnim(){
	anim2();
}
/**
 * 
 * @return
 */
function voirAnim(){
	anim2();
}
/**
 * 
 * @return
 */
function rejouerIntro(){
	$$('.bloc').each(function(o,index) {
		position_depart(o,index);
	})
	$('body').addClassName('nofirst')
}
/**
 * 
 * @return
 */
function anim2(){
	if($('slogan').hasClassName('ouvert')){
		$('animation').style.display = 'none';
		new Effect.Parallel([
			new Effect.Morph('slogan', {
				style: 'height: 190px; background: #C9A886; margin-left: 345px; margin-top: 170px; width: 230px'
				}),
			new Effect.Opacity('slogan',{
				from: 1.0, to: 0.7
			})				
		], { 
	  		duration: 0.8,
  			afterFinish: function(){
					$('slogan').removeClassName('ouvert');
					$('slogan').setStyle({height:'',width:'',marginLeft:'',marginTop:''});
					//$('accroche').setStyle({visibility:''});
					$('cache').removeClassName('ouvert');
					Element.setOpacity($('slogan'), 1)
				},
			beforeStart:function(){
					if($('page').hasClassName('variante2')){
						if($$('.video').length>0) {
							$$('.video')[0].setStyle({display:''})
						}
					};
					if($('body').hasClassName('v2')&&!$('body').hasClassName('nofirst')){
					$('slogan').setStyle({background:'#666666'});}
				}
				//,transition: Effect.Transitions.sinoidal
		});
	}else{
		new Effect.Parallel([
			new Effect.Morph('slogan', {
				style: 'height: 556px; background: #C9A886; margin-left: 0; margin-top: 0; width: 918px'
			}),
			new Effect.Opacity('slogan',{
				from: 0.8, to: 1
			})				
		], { 
	  		duration: 0.4,
				beforeStart: function(){
					$('animation').style.display = 'none';
					$('cache').addClassName('ouvert');
					$('slogan').setStyle({width: '220px', height: '168px',marginLeft:'260px',marginTop:'135px',background: '#666666'})
					if($('page').hasClassName('variante2')){
						if($$('.video').length>0) {
							window.setTimeout("$$('.video')[0].setStyle({display:'none'})",100);
						}
					};
					},
				afterFinish: function(){
					$('slogan').addClassName('ouvert');
					window.setTimeout("$('animation').style.display = 'block'",100);
					//writeAttribute($('animation').down('embed'),bgcolor,'#666666');
				}
				//,transition: Effect.Transitions.sinoidal
/*,
				queue: 'end'*/
		});
	}
}
/**
 * 
 * @return
 */
function anim1(){
	if($('slogan').hasClassName('ouvert')){
		$('animation').style.display = 'none';
		new Effect.Parallel([
			new Effect.Morph('slogan', {
				style: 'height: 1px; background: #C9A886'
			}),
			new Effect.Opacity('slogan',{
				from: 1.0, to: 0.7
			})
		], { 
	  		duration: 0.8,				
	  		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')){
					$('slogan').setStyle({background:'#666666'});
					}
				}
				//,transition: Effect.Transitions.sinoidal
		});
	}else{
		$('animation').style.display = 'block';
		new Effect.Parallel([
			new Effect.Morph('slogan', {
				style: 'height: 556px; background: #fff'

			}),
			new Effect.Opacity('slogan',{
				from: 0.8, to: 1
			})

		], { 
				duration: 0.7,
				beforeStart: function(){
					$('cache').addClassName('ouvert');
					//$('accroche').setStyle({visibility:'hidden'});
					if($('page').hasClassName('variante2')){window.setTimeout("$('bloc_3').setStyle({display:'none'})",300)};
					},
					
					
				afterFinish: function(){$('slogan').addClassName('ouvert')}
				//,transition: Effect.Transitions.sinoidal
		});
	}
}