var imageTmp = new Object();

function afficherPhoto(_medaillon, _grosPlan, _ref, _aspect) {

	if(_aspect == 1) {
		document.getElementById('unePhoto_h').style.display = 'none';
		document.getElementById('legende_photo_h').style.display = 'none';
		document.getElementById('unePhoto_v').style.display = 'block';
		document.getElementById('legende_photo_v').style.display = 'block';

		document.getElementById('legende_photo_v').innerHTML = 'Ref.: '+ _ref;

		document.getElementById('laPhoto_v').src = 'images/portfolio-photo_v.jpg';

		imageTmp.onload = null;
		//imageTmp = new Image(235, 313);
		imageTmp = document.createElement('img');

		imageTmp.onload = afficherImgTmp_v;
		imageTmp.src = 'images/portfolio/'+ _grosPlan +'';

	} else {
		document.getElementById('unePhoto_v').style.display = 'none';
		document.getElementById('legende_photo_v').style.display = 'none';
		document.getElementById('unePhoto_h').style.display = 'block';
		document.getElementById('legende_photo_h').style.display = 'block';

		document.getElementById('legende_photo_h').innerHTML = 'Ref.: '+ _ref;

		document.getElementById('laPhoto_h').src = 'images/portfolio-photo_h.jpg';

		imageTmp.onload = null;
		//imageTmp = new Image(423, 280);
		imageTmp = document.createElement('img');

		imageTmp.onload = afficherImgTmp_h;
		imageTmp.src = 'images/portfolio/'+ _grosPlan +'';
	}

	var lesMedaillons = document.getElementById('medaillons');
	lesMedaillons = lesMedaillons.getElementsByTagName('A');

	for(var iMedaillon=0; iMedaillon<lesMedaillons.length; iMedaillon++) {
		lesMedaillons[iMedaillon].className = '';
	}

	_medaillon.className = 'medaillon_actif';

}

function afficherImgTmp_h() {
	document.getElementById('laPhoto_h').src = this.src;
}

function afficherImgTmp_v() {
	document.getElementById('laPhoto_v').src = this.src;
}

document.getElementById("premierMedaillon").onclick();

var timer_defil = null;

function commencerDefilDroite() {
	if(timer_defil) window.clearTimeout(timer_defil);
	defilDroite();
}
 
function commencerDefilGauche() {
	if(timer_defil) window.clearTimeout(timer_defil);
	defilGauche();
}
var tab = false;

function defilDroite() {
	defilDroiteDeXPX(5);

	//document.getElementById('medaillons').scrollLeft = document.getElementById('medaillons').scrollLeft + 5;
	timer_defil = window.setTimeout("defilDroite()", 25);
}

function defilDroiteDeXPX(xpx) {
	var gauche = parseInt(document.getElementById('medaillons-conteneur').style.left);
	var largeurConteneur = parseInt(document.getElementById('medaillons-conteneur').style.width);
	var largeurMedaillons = document.getElementById('medaillons').offsetWidth;

	if(isNaN(gauche)) gauche = 0;

	gauche -= xpx;

	if(gauche < (largeurConteneur * -1 + largeurMedaillons) ) gauche = largeurConteneur * -1 + largeurMedaillons;

	document.getElementById('medaillons-conteneur').style.left = gauche +"px";
}
 
function defilGauche() {
	defilGaucheDeXPX(5);

	//document.getElementById('medaillons').scrollLeft = document.getElementById('medaillons').scrollLeft - 5;
	timer_defil = window.setTimeout("defilGauche()", 25);
}

function defilGaucheDeXPX(xpx) {
	var gauche = parseInt(document.getElementById('medaillons-conteneur').style.left);
	var largeurConteneur = parseInt(document.getElementById('medaillons-conteneur').style.width);

	if(isNaN(gauche)) gauche = 0;

	gauche += xpx;

	if(gauche > 0) gauche = 0;

	document.getElementById('medaillons-conteneur').style.left = gauche +"px";
}
 
function arreterDefilDroite() {
	if(timer_defil) window.clearTimeout(timer_defil);
}
 
function arreterDefilGauche() {
	if(timer_defil) window.clearTimeout(timer_defil);
}

function defilBcpGauche() {
	defilGaucheDeXPX(100);
}

function defilBcpDroite() {
	defilDroiteDeXPX(100);
}


var obj_defil_gauche = document.getElementById('defil_gauche');
if(obj_defil_gauche) {
	obj_defil_gauche.onmouseover = commencerDefilGauche;
	obj_defil_gauche.onmouseout = arreterDefilGauche;

	obj_defil_gauche.onclick = defilBcpGauche;
}

var obj_defil_droite = document.getElementById('defil_droite');
if(obj_defil_droite) {
	obj_defil_droite.onmouseover = commencerDefilDroite;
	obj_defil_droite.onmouseout = arreterDefilDroite;

	obj_defil_droite.onclick = defilBcpDroite;
}


