var tab = new Array("ph1","ph2","ph3","ph4","ph5","ph6","ph7","ph8","ph9","ph10","ph11");
 var cpt=-1;
var v_left=0,v_center=1,v_right=2,tmp_left,tmp_right,tmp_center,current=0;


function change_rond()
{

jQuery('#texte'+((cpt%4)+1)).fadeOut("slow");
    //Apparition/Disparition de cette image
	cpt++;
    //jQuery('#' + tab[cImg]).fadeIn("slow");
	jQuery('#texte'+ ((cpt%4)+1)).delay("slow").fadeIn("slow");
	jQuery('#ronds').html('');
	for(var i=1;i<5;i++)
	{
	if (i!=((cpt%4)+1))
	jQuery('#ronds').append('<img src="http://tazieff.fr/CHT/wp-content/themes/CHT/Images/rond.png" id="rond'+i+'" onclick="rond('+i+');"/>');
	else
	jQuery('#ronds').append('<img src="http://tazieff.fr/CHT/wp-content/themes/CHT/Images/current.png" id="rond'+i+'" onclick="rond('+i+');"/>');
	}
    

}
function anime(id)
{
jQuery('#shadowing').css('display','block');
if (current!=0)
{

jQuery('#content_'+current).fadeOut(1500);
jQuery('#content_'+id).delay(1500).fadeIn(3000);
current=id;
return 1;
}
jQuery('#close').fadeIn(3000);

jQuery('#back_ecran').css('display','block');
jQuery('#back_ecran').animate({
  width : '800px'
  , height : '400px'
},2000);
jQuery('#content_'+id).fadeIn(3000);
current=id;


}
function fct_close()
{
jQuery('#shadowing').css('display','none');
jQuery('#content_'+current).fadeOut(1500);
jQuery('#close').fadeOut(1500);
jQuery('#back_ecran').animate({
  width : '800px'
  , height : '0px'
},2000);
jQuery('#back_'+current).fadeOut('slow');
current=0;
}

function rond(id)
{


jQuery('#ronds').html('');
for(var i=1;i<5;i++)
	{
	if (i!=id)
	jQuery('#ronds').append('<img src="http://tazieff.fr/CHT/wp-content/themes/CHT/Images/rond.png" id="rond'+i+'" onclick="rond('+i+');"/>');
	else
	jQuery('#ronds').append('<img src="http://tazieff.fr/CHT/wp-content/themes/CHT/Images/current.png" id="rond'+i+'" onclick="rond('+i+');"/>');
	}
jQuery('#texte'+((cpt%4)+1)).fadeOut("slow");
jQuery('#texte'+id).delay("slow").fadeIn("slow");

cpt=id-1;


}


 function ph_left(){
 

	tmp_left=v_left;
	while (v_left==tmp_left || v_left==v_right || v_left==v_center)
	{
v_left = Math.floor ( Math.random() * tab.length );
}
jQuery('#'+tab[tmp_left]).delay(100).zIndex(2).fadeOut(3000);
jQuery('#'+tab[v_left]).css('left',jQuery('#b_left').position().left+75);
jQuery('#'+tab[v_left]).zIndex(1).fadeIn(3000);
	//jQuery('#texte'+((cpt%4)+1)).delay(10000).fadeOut("slow");

}

 function ph_center(){
 

    
	tmp_center=v_center;
	while (v_center==tmp_center || v_center==v_right || v_center==v_left)
	{
v_center = Math.floor ( Math.random() * tab.length );
}
jQuery('#'+tab[tmp_center]).delay(100).zIndex(2).fadeOut(3000);
jQuery('#'+tab[v_center]).css('left',jQuery('#b_left').position().left+375);
jQuery('#'+tab[v_center]).zIndex(1).fadeIn(3000);
	//jQuery('#texte'+((cpt%4)+1)).delay(10000).fadeOut("slow");

}

function choice(){
switch  (Math.floor ( Math.random() * 3 ))
{
 case 0 :
	ph_left();
	break;
	case 1 :
	ph_center();
	break;
	case 2 :
	ph_right();
	}
}
 function ph_right(){
 
	
	tmp_right=v_right;
	while (v_right==tmp_right || v_right==v_center || v_right==v_left)
	{
v_right = Math.floor ( Math.random() * tab.length );
}
jQuery('#'+tab[tmp_right]).delay(100).zIndex(2).fadeOut(3000);
jQuery('#'+tab[v_right]).css('left',jQuery('#b_left').position().left+675);
jQuery('#'+tab[v_right]).zIndex(1).fadeIn(3000);
	//jQuery('#texte'+((cpt%4)+1)).delay(10000).fadeOut("slow");

}

jQuery(document).ready(function(){
jQuery(function(){
jQuery('#b_left').fadeIn(3000);
jQuery('#b_right').css('left',jQuery('#b_left').position().left+975);

jQuery('#b_right').fadeIn(3000);
change_rond();
ph_left();
ph_center();
ph_right();
//Au chargement de la page, 1ère exécution de toutes les fonctionnalités //de la bannière

setInterval("choice();",8000);
setInterval("change_rond();",12000);
    });

   
	})

