//JAVASCRIPT QUi REGROUPE LES FONCTION jS NECESSAIRE Au SLIDE Et EFFET
/* ********************************************************************************************************************************* */
/* ********************************************************************************************************************************* */
/*                                                        IMAGES ACCUEIL                                                             */
/* ********************************************************************************************************************************* */
/* ********************************************************************************************************************************* */
var DELAI_TRANSITION=250; //en miliisonde
var DELAI_AVANT_PREMIERE_TRANSITION=2000; //2s
var DELAI_ENTRE_CHAQUE_TRANSITION=7000; //5s

var next_idx=0;
var cur_idx=0;
var cur_col=0;
var next_img_to_load="";
preload_image_object = new Image();

var actif_opac_ctw;
var i_opac_ctw;	
var actif_opac_wtc;
var i_opac_wtc;	
var CPT_ILLUSTR=0;
var IDX_PHOTO_EN_COURS=1;

var preload_image_next = new Image();

//on fonctionalise la suite
function anim_slide_accueil() {
	next_idx=0;
	setTimeout('opac_color_to_next_illustration_start_transition()', DELAI_AVANT_PREMIERE_TRANSITION); //temps avant la première slide
}
	
function opac_color_to_next_illustration_start_transition(){
	i_opac_ctw=0.01;
	///alert(page);
//		var next_random_choice_img=photo_url[random_illustr()];
		var next_random_choice_idx=next_illustr(); //random_illustr();
		//on renseigne le nouveau IDX
		IDX_PHOTO_EN_COURS=next_random_choice_idx;
		var next_random_choice_img=photo_url[next_random_choice_idx];
		
		//alert(next_random_choice_img);
		
		preload_image_next.src=path_img_acc+next_random_choice_img;
		
		div_ILLUSR=document.getElementById('DIV_CUR_ILLUSTR');
//		div_ILLUSR.style.backgroundImage = "url('"+preload_image_object.src+"')";
		//alert("url('"+path_img_acc+next_random_choice_img+"')");
		div_ILLUSR.style.backgroundImage = "url('"+path_img_acc+next_random_choice_img+"')";
		//div_ILLUSR.style.backgroundImage = "url('./_admin/images_slide_accueil/FIDELISER.jpg')";
		//alert("url('"+preload_image_object.src+"')");
		actif_opac_ctw = setInterval('opac_color_to_transparent_action()',DELAI_TRANSITION); //50 vitesse de fondu
}
// COULEUR -> TRANSPARENT
function opac_color_to_transparent_action() { 
	var loc_img=document.getElementById('IMG_CUR_ILLUSTR');
	if(i_opac_ctw >= 1 ){ 
		window.clearInterval(actif_opac_ctw); 
		//changement de tof
		//alert(cur_idx);
		//alert(preload_image_object.src);
		loc_img.src=preload_image_next.src
		//alert(loc_img.src);
		//puis opac inverse
		i_opac_ctw=0.01;
		IsIE?loc_img.style.filter="alpha(opacity='"+(1-i_opac_ctw)*100+"')":loc_img.style.opacity=(1-i_opac_ctw);
				
		
		//ICI ETAPE SUIVANTE ->>>>>>>>>>>		
		//on preload la prochaine le bat 1
		//preload_image_object.src=root_cow+bat2_img;
		setTimeout('opac_color_to_next_illustration_start_transition()', DELAI_ENTRE_CHAQUE_TRANSITION);
		
		
	}
	i_opac_ctw = i_opac_ctw+0.1;

	//NN4x / OP4x / NN6+ / OP5+
	IsIE?loc_img.style.filter="alpha(opacity='"+(1-i_opac_ctw)*100+"')":loc_img.style.opacity=(1-i_opac_ctw);

	i_opac_ctw = i_opac_ctw+0.1;
}

//choix de la prochain slide au pif
function random_illustr() {
	var ret=1;
	//alert(CPT_ILLUSTR);
	ret=Math.floor(Math.random()*(CPT_ILLUSTR+1));
	//ret=ret+1;
	//alert(CPT_ILLUSTR+" - "+ret+" - "+photo_url[ret]);
	if (ret>CPT_ILLUSTR) {ret=random_illustr();}
	//si 0 on recommence
	if (ret==0) {ret=random_illustr();}
	//si même valeur que précdente on recommance
	if (ret==IDX_PHOTO_EN_COURS) {ret=random_illustr();}
		
	//alert(ret);
	return ret;
}

//choix de la prochain slide 
function next_illustr() {
	var ret=1;
	
	ret=IDX_PHOTO_EN_COURS+1;
	if (ret>CPT_ILLUSTR) {ret=1;}
		
	//alert(ret);
	return ret;
}



/* ********************************************************************************************************************************* */
/* ********************************************************************************************************************************* */
/*                                                        ETUDES DE CAS                                                              */
/* ********************************************************************************************************************************* */
/* ********************************************************************************************************************************* */
var DELAI_TRANSITION_CTWTC=250; //en miliisonde
var DELAI_ENTRE_CHAQUE_ETUDE_CAS=10000; //5s
var DELAI_AVANT_PREMIERE_ETUDE_CAS_A=2000; //2s
var DELAI_AVANT_PREMIERE_ETUDE_CAS_B=7900; //2s
var DELAI_AVANT_PREMIERE_ETUDE_CAS_C=9800; //2s
var next_idec=0;
var i_opac_ec_ctw;	
var actif_opac_ec_ctw;

var i_opac_ec_ctw_a;	
var actif_opac_ec_ctw_a;
var i_opac_ec_ctw_b;	
var actif_opac_ec_ctw_b;
var i_opac_ec_ctw_c;	
var actif_opac_ec_ctw_c;


var IDX_ETUDE_CAS_A_EN_COURS=1;
var IDX_ETUDE_CAS_B_EN_COURS=1;
var IDX_ETUDE_CAS_C_EN_COURS=1;


//on fonctionalise la suite
function anim_slide_etude_cas(serie) {
	next_idec=0;
	var cur_delai;
	if (serie=="A") {cur_delai=DELAI_AVANT_PREMIERE_ETUDE_CAS_A;}
	if (serie=="B") {cur_delai=DELAI_AVANT_PREMIERE_ETUDE_CAS_B;}
	if (serie=="C") {cur_delai=DELAI_AVANT_PREMIERE_ETUDE_CAS_C;}
	setTimeout('opac_color_to_next_etude_cas_start_transition(\''+serie+'\')', cur_delai);
}

function opac_color_to_next_etude_cas_start_transition(serie){
	i_opac_ec_ctw=0.01;
	///alert(page);
	//on renseigne le nouveau IDX
//	alert("IDX_ETUDE_CAS_C_EN_COURS "+IDX_ETUDE_CAS_C_EN_COURS+" / "+cpt_idec_c);
	if (serie=="A") {i_opac_ec_ctw_a=0.01; IDX_ETUDE_CAS_A_EN_COURS=next_etude_cas(serie);
		actif_opac_ec_ctw_a = setInterval('opac_ctwtc_etude_cas_action(\''+serie+'\')',DELAI_TRANSITION_CTWTC); //50 vitesse de fondu
	}
	if (serie=="B") {i_opac_ec_ctw_b=0.01; IDX_ETUDE_CAS_B_EN_COURS=next_etude_cas(serie);
		actif_opac_ec_ctw_b = setInterval('opac_ctwtc_etude_cas_action(\''+serie+'\')',DELAI_TRANSITION_CTWTC); //50 vitesse de fondu
	}
	if (serie=="C") {i_opac_ec_ctw_c=0.01; IDX_ETUDE_CAS_C_EN_COURS=next_etude_cas(serie);
		actif_opac_ec_ctw_c = setInterval('opac_ctwtc_etude_cas_action(\''+serie+'\')',DELAI_TRANSITION_CTWTC); //50 vitesse de fondu
	}
	
	//alert("debut trans");
	//on entame la transition en blanc
	//actif_opac_ec_ctw = setInterval('opac_ctwtc_etude_cas_action()',DELAI_TRANSITION_CTWTC); //50 vitesse de fondu
	//actif_opac_ec_ctw = setInterval('opac_ctwtc_etude_cas_action(\''+serie+'\', \''+cur_lg+'\')',DELAI_TRANSITION_CTWTC); //50 vitesse de fondu
}

// COULEUR -> TRANSPARENT -> COULEUR
function opac_ctwtc_etude_cas_action(serie) { 
	var loc_div=document.getElementById('DIV_ETUDE_CAS_'+serie);
	
	var loc_i_opac_ec_ctw;
	if (serie=="A") {loc_i_opac_ec_ctw=i_opac_ec_ctw_a;}
	if (serie=="B") {loc_i_opac_ec_ctw=i_opac_ec_ctw_b;}
	if (serie=="C") {loc_i_opac_ec_ctw=i_opac_ec_ctw_c;}
	
	if(loc_i_opac_ec_ctw >= 1 ){ 
		//window.clearInterval(actif_opac_ec_ctw); 
		//ICI ETAPE SUIVANTE ->>>>>>>>>>>		
		//on change le texte et les liens
		var next_idx_serie;
		if (serie=="A") {
			window.clearInterval(actif_opac_ec_ctw_a); 
			next_idx_serie=IDX_ETUDE_CAS_A_EN_COURS;
			document.getElementById('A_HREF_ETUDE_CAS_'+serie).innerHTML=arr_etudes_cas_titre_a[next_idx_serie];
			document.getElementById('A_HREF_ETUDE_CAS_'+serie).href=langue+"+"+arr_etudes_cas_a[next_idx_serie]+".html";
			document.getElementById("DIV_ETUDE_CAS_"+serie+"_TXT").innerHTML=arr_etudes_cas_txt_a[next_idx_serie]; //arr_etudes_cas_txt_c[IDX_ETUDE_CAS_A_EN_COURS]
			i_opac_ec_ctw_a=0.01;
			IsIE?loc_div.style.filter="alpha(opacity='"+(1-i_opac_ec_ctw_a)*100+"')":loc_div.style.opacity=(1-i_opac_ec_ctw_a);
		}
		if (serie=="B") {
			window.clearInterval(actif_opac_ec_ctw_b); 
			next_idx_serie=IDX_ETUDE_CAS_B_EN_COURS;
			document.getElementById('A_HREF_ETUDE_CAS_'+serie).innerHTML=arr_etudes_cas_titre_b[next_idx_serie];
			document.getElementById('A_HREF_ETUDE_CAS_'+serie).href=langue+"+"+arr_etudes_cas_b[next_idx_serie]+".html";
			document.getElementById("DIV_ETUDE_CAS_"+serie+"_TXT").innerHTML=arr_etudes_cas_txt_b[next_idx_serie]; //arr_etudes_cas_txt_c[IDX_ETUDE_CAS_A_EN_COURS]
			i_opac_ec_ctw_b=0.01;
			IsIE?loc_div.style.filter="alpha(opacity='"+(1-i_opac_ec_ctw_b)*100+"')":loc_div.style.opacity=(1-i_opac_ec_ctw_b);
		}
		if (serie=="C") {
			window.clearInterval(actif_opac_ec_ctw_c); 
			next_idx_serie=IDX_ETUDE_CAS_C_EN_COURS;
			document.getElementById('A_HREF_ETUDE_CAS_'+serie).innerHTML=arr_etudes_cas_titre_c[next_idx_serie];
			document.getElementById('A_HREF_ETUDE_CAS_'+serie).href=langue+"+"+arr_etudes_cas_c[next_idx_serie]+".html";
			document.getElementById("DIV_ETUDE_CAS_"+serie+"_TXT").innerHTML=arr_etudes_cas_txt_c[next_idx_serie]; //arr_etudes_cas_txt_c[IDX_ETUDE_CAS_A_EN_COURS]
			i_opac_ec_ctw_c=0.01;
			IsIE?loc_div.style.filter="alpha(opacity='"+(1-i_opac_ec_ctw_c)*100+"')":loc_div.style.opacity=(1-i_opac_ec_ctw_c);
		}
		
		//on réopacifie
		//alert("reopac "+serie);
		//puis on lance la prochaien transition
		setTimeout('opac_color_to_next_etude_cas_start_transition(\''+serie+'\')', DELAI_ENTRE_CHAQUE_ETUDE_CAS);
	}


	if (serie=="A") {
		i_opac_ec_ctw_a = i_opac_ec_ctw_a+0.1;
		//NN4x / OP4x / NN6+ / OP5+
		IsIE?loc_div.style.filter="alpha(opacity='"+(1-i_opac_ec_ctw_a)*100+"')":loc_div.style.opacity=(1-i_opac_ec_ctw_a);
		i_opac_ec_ctw_a = i_opac_ec_ctw_a+0.1;
	}
	if (serie=="B") {
		i_opac_ec_ctw_b = i_opac_ec_ctw_b+0.1;
		//NN4x / OP4x / NN6+ / OP5+
		IsIE?loc_div.style.filter="alpha(opacity='"+(1-i_opac_ec_ctw_b)*100+"')":loc_div.style.opacity=(1-i_opac_ec_ctw_b);
		i_opac_ec_ctw_b = i_opac_ec_ctw_b+0.1;
	}
	if (serie=="C") {
		i_opac_ec_ctw_c = i_opac_ec_ctw_c+0.1;
		//NN4x / OP4x / NN6+ / OP5+
		IsIE?loc_div.style.filter="alpha(opacity='"+(1-i_opac_ec_ctw_c)*100+"')":loc_div.style.opacity=(1-i_opac_ec_ctw_c);
		i_opac_ec_ctw_c = i_opac_ec_ctw_c+0.1;
	}
//	i_opac_ec_ctw = i_opac_ec_ctw+0.1;
	//NN4x / OP4x / NN6+ / OP5+
//	IsIE?loc_div.style.filter="alpha(opacity='"+(1-i_opac_ec_ctw)*100+"')":loc_div.style.opacity=(1-i_opac_ec_ctw);
//	i_opac_ec_ctw = i_opac_ec_ctw+0.1;
}


/*------------------------------------------------- */
//choix de la prochain slide 
function next_etude_cas(serie) {
	var ret=1;
	
	if (serie=="A") {
		ret=IDX_ETUDE_CAS_A_EN_COURS+1;
		if (ret>cpt_idec_a) {ret=1;}
	}
	if (serie=="B") {
		ret=IDX_ETUDE_CAS_B_EN_COURS+1;
		if (ret>cpt_idec_b) {ret=1;}
	}
	if (serie=="C") {
		ret=IDX_ETUDE_CAS_C_EN_COURS+1;
		if (ret>cpt_idec_c) {ret=1;}
	}

	//alert("serie "+serie+" : "+ret);
	return ret;
}



