// pour les agrandissements
var photo_cur = 1;
var num_cadre_cur = 1;
var photoOpened = 0;
function openPhotoBig(num_cadre) {
	num_cadre_cur = num_cadre;
	var obj_div = $('fiche_photoBigDiv');
	var obj_photo = $('fiche_photoBig');
	var obj_photo_low = $('photos_affichage');
	
	if (obj_photo && obj_div) {
		obj_photo.src = obj_photo_low.src; // evite le debut de l'anim avec aucune photo si elle n'a pas eu le temps de chagrer
	
		var id = (photos_active + num_cadre - 1);
		if ( id < photos_nb ) {
			obj_photo.src = photo_base[id];
			photo_cur = id + 1;
		} else {
			return;
		}
		obj_div.style.left	= 331;
		obj_div.style.top	= -430;
		photoOpened = 1;
		var myEffect = new Fx.Morph(obj_div, {duration: 600, transition: Fx.Transitions.Sine.easeOut });
		if (num_cadre == 1) {
			myEffect.start({
				'left': [331, 7],
				'top': [-430, -584],
				'width': 724,  //Morphs the 'width' style from 900px to 300px.
				'height': 544 //Morphs the 'height' style from 10px to 100px.
			});
		}
		obj_div.style.visibility = 'visible';
		// var obj = $('page_photo_alpha');
		// if (obj) obj.style.filter = 'alpha(opacity=50)';
		// if (obj) obj.style.opacity =".5";
		// obj = $('page_photo_block');
		// if (obj) obj.style.top = '-70px';

	}
}

function closePhotoBig() {
	var obj_div = $('fiche_photoBigDiv');
	var obj_photo = $('fiche_photoBig');
	photoOpened = 0;
	mout_photo(1); // on cache l'icone
	mout_photo(2); // on cache l'icone
	mout_photo(3); // on cache l'icone
	if (obj_div && obj_photo) {
		var myEffect = new Fx.Morph(obj_div, {duration: 600, transition: Fx.Transitions.Sine.easeOut, onComplete: function(){ obj_div.style.visibility = 'hidden'; obj_div.style.top = -568; obj_div.style.left = 0; } });
		if (num_cadre_cur == 1) {
			myEffect.start({
				'left': [7, 331],
				'top': [-584, -430],
				'width': 395,  //Morphs the 'width' style from 900px to 300px.
				'height': 297 //Morphs the 'height' style from 10px to 100px.
			});
		}
		var obj = $('page_photo_alpha');
		if (obj) obj.style.filter = 'alpha(opacity=100)';
		if (obj) obj.style.opacity ="1";
		obj = $('page_photo_block');
		if (obj) obj.style.top = '0px';

	}
}


function goPhotoNext() {
	if (photo_base.length <= 1) return; // on fait rien si pas ou une seule photo

	if (photo_base.length <= 1) return; // on fait rien si pas ou une seule photo
	if (photo_cur < photo_base.length) {
		photo_cur ++;
	} else {
		photo_cur = 1;
	}
	var obj_photo = $('fiche_photoBig');
	obj_photo.src = photo_base[photo_cur - 1];
	var obj_compte = $('fiche_photoCompte_txt');
	if (obj_compte) obj_compte.innerHTML = photo_cur +" / "+ photo_base.length;
}

function goPhotoPrev() {
	if (photo_base.length <= 1) return; // on fait rien si pas ou une seule photo
	if (photo_cur > 1) {
		photo_cur --;
	} else {
		photo_cur = photo_base.length;
	}
	var obj_photo = $('fiche_photoBig');
	obj_photo.src = photo_base[photo_cur - 1];
	var obj_compte = $('fiche_photoCompte_txt');
	if (obj_compte) obj_compte.innerHTML = photo_cur +" / "+ photo_base.length;
}


var allTimeoutPrev = new Array();
var allTimeoutCompte = new Array();
var allTimeoutNext = new Array();
function mover_photo(laquelle) {
	if (photoOpened == 0) return; //on quitte  car on ferme la fenettre de toute facon
	//alert('mover_photo('+ laquelle +')');
	var obj;
	var obj2;
	if (laquelle == 1) {
		clearTimeout(allTimeoutPrev);
		obj = $('fiche_photoGoPrev');
		if (obj) obj.style.display = 'block';
	} else if (photo_base.length && laquelle == 2) {
		clearTimeout(allTimeoutCompte);
		obj = $('fiche_photoCompte');
		obj2 = $('fiche_photoCompte_txt');
		if (obj2) obj2.innerHTML = photo_cur +" / "+ photo_base.length;
		if (obj) obj.style.display = 'block';
	} else if (laquelle == 3) {
		clearTimeout(allTimeoutNext);
		obj = $('fiche_photoGoSuiv');
		if (obj) obj.style.display = 'block';
	}
}
function mout_photo(laquelle) {
	if (!laquelle || laquelle == 0) {
		allTimeoutPrev = setTimeout('mout_photo(1)', 50);
		allTimeoutCompte = setTimeout('mout_photo(2)', 50);
		allTimeoutNext = setTimeout('mout_photo(3)', 50);
	} else {
		//alert('mout_photo('+ laquelle +')');
		var obj;
		if (laquelle == 1) {
			obj = $('fiche_photoGoPrev');
			if (obj) obj.style.display = 'none';
			clearTimeout(allTimeoutPrev);
		} else if (laquelle == 2) {
			obj = $('fiche_photoCompte');
			if (obj) obj.style.display = 'none';
			clearTimeout(allTimeoutCompte);
		} else if (laquelle == 3) {
			obj = $('fiche_photoGoSuiv');
			if (obj) obj.style.display = 'none';
			clearTimeout(allTimeoutNext);
		}
	}
}

