function precharger_images(){
	liste_image=0;
	var heavyImage= new Array();
	$$('.photo_liee_liste a').each(function(lien_image) {
		heavyImage[liste_image] = new Image(); 
		heavyImage[liste_image] = lien_image.get('alt');
		liste_image++;
	});
	
}

function agenda_defilant(){
	if($('contenu_evenements')){
		var nombre_items=0;
		$$('#contenu_evenements .evenement').each(function(el) {
			nombre_items++;
		});
		var marge=52;
		marge=parseInt(marge);
		
		
		marge_top=$('contenu_evenements').getStyle('margin-top');
		
		if(marge_top==undefined) marge_top=0;
		marge_top=parseInt(marge_top);
		marge_top_calcul=-(nombre_items-2)*marge;
		//alert('marge_top='+marge_top+' marge_top_calcul='+marge_top_calcul);
		if(i>2){
			if(marge_top>marge_top_calcul){
				
				nouvelle_marge=marge_top-marge;
				//alert('on bouge nouvelle_marge='+nouvelle_marge);
				$('contenu_evenements').set('tween', {
					duration: 500
				}).tween('marginTop',nouvelle_marge+'px');
				setTimeout(agenda_defilant,5000);
			}else{
				//alert('reset');
				$('contenu_evenements').set('tween', {
					duration: 500
				}).tween('marginTop','0px');
				setTimeout(agenda_defilant,3000);
			}
		}
	}
}


	function shadow_img2(){
		//var el=$('photo_apercu_786');
		 $$('.photo_cadre').each(function(el) {
			ombrer_element(el,'true');
		});
	}
		
	function ombrer_element(el,redimentionner){
		if(el.offsetWidth>0){
			
			var padding=8;
			var nombre_tours=8;
			var limite_affichage=380;
			if(redimentionner=='true'){
				taille_actuelle=el.offsetWidth;
				taille_finale=taille_actuelle-2*padding-4*nombre_tours;

				hauteur_actuelle=el.offsetHeight-2*padding;
				rapport_image=el.offsetWidth/el.offsetHeight
				hauteur_finale=taille_finale/rapport_image;
				hauteur_finale=hauteur_actuelle;
				//alert(rapport_image);
				if(taille_actuelle>limite_affichage){
					el.set('width',taille_finale);
					el.set('height',hauteur_finale);
				}else{
					taille_finale=taille_actuelle;
					hauteur_finale=taille_actuelle/rapport_image;
				}
				el.setStyle('padding',padding+'px');
				//alert('taille_actuelle='+taille_actuelle+' taille_finale='+taille_finale);	
			}else{
				taille_actuelle=el.getStyle('width').replace('px','');
				hauteur_actuelle=el.getStyle('height').replace('px','');
				taille_finale=taille_actuelle;
				hauteur_finale=hauteur_actuelle;
				el.setStyle('padding',padding+'px');
				//taille_finale=el.offsetWidth-2*padding-4*nombre_tours;
			}
		
			var destination=el;
			for (p=0;p<9;p++){
				var couleur=220+p*5;
				var taille=2*p+parseInt(taille_finale)+2*padding;
				var hauteur=2*p+parseInt(hauteur_finale)+2*padding;
				//alert(hauteur);
				var container = new Element('div').setStyles({
					border: 'solid 1px rgb('+couleur+','+couleur+','+couleur+')',
					width:taille+'px',
					height:hauteur+'px'

				}).injectBefore(destination).adopt(destination);
				container.addClass('div_ombre');
				destination=container;
			}
		}
	}
	var liste_images = $$('.image_centree'); 
	if(liste_images){
		liste_images.each(function(item) {
			src_item=item.get('src'); 
			height_item=item.get('height');
			
			var oImg = new Image();
			// Affectation du chemin de l'image a l'objet
			oImg.src = src_item;
			// On recupere les tailles reelles
			var height_true = dH = oImg.height;
			var width_true = dW = oImg.width;
			//alert('w='+width_true+' h='+height_true);
			if(width_true>height_true){ // paysage
				new_height=150;
				new_width=width_true*new_height/height_true;
				//marge_gauche='-'+( (new_width-124)/2 )+'px';
				marge_gauche='0px';
				marge_top='0px';
			}else{ // Portrait
				new_width=225;
				new_height=new_width*height_true/width_true;
				marge_gauche='0px';
				marge_top='0px';
				marge_top='-'+((new_height-135)/2)+'px';
			}
			
			//alert('w='+new_width+' h='+new_height);
			//$(item).set('style','margin-top:'+marge_top+'; margin-left:'+marge_gauche+'; width:'+new_width+'; height='+new_height+'; z-index:10;');
			$(item).set('width',new_width);
			$(item).set('height',new_height);
		});
	}


	  

function afficher_zoom_photo(src_new,zoom_new, suffixe_img) {
	$("photo_apercu_"+suffixe_img).src = src_new;
	$("photo_zoom_"+suffixe_img).href = zoom_new;
	
}

function afficher_diapo(num_page){
	myShow.pause(1);
	
	for(p=0;p<5;p++){
		src_defaut=$("bt2_"+p).get('src');
		//$$("div.slideshow-captions").removeClass("bt_"+p);
		
		nouvelle_src_defaut=src_defaut.replace('_on','_off');
		$("bt2_"+p).src=nouvelle_src_defaut;
	}
	
	var src_source=$("bt2_"+num_page).get('src');
	var nouvelle_src=src_source.replace('_off','_on');
	var nouvelle_image=new Image(0,0);
	nouvelle_image.src=nouvelle_src;
	$("bt2_"+num_page).src=nouvelle_src;
	
	myShow.go(num_page, 'left'); 
	//setTimeout("myShow.play(1)",10000);
	//$$("div.slideshow-captions").addClass("bt_"+num_page); 
}
	
