/* déclaration des variables */
var parametres = new ParseScriptParam('biographie');
var type = '';
var lang = '';
var chemin = '';
var num_legend = '';
var firstThumb = '';
var lastThumb = '';
var pas = '';
var tmp_pas = '';
var SvalueLeft = '';
var SvalueRight = '';
var timerLeft='';
var timerRight='';
var Largeur = '';
var positionFilet ='';
var thumbEncours = '';
/* fin déclaration des variables */

/* init des variables */
function initScroll(){
	firstThumb = 1;
	lastThumb = 7;
	Largeur = 0;
	pas = 84;
	tmp_pas = 84;
	SvalueLeft = 0;
	SvalueRight = 0;
	positionFilet = 0; 
	if (lang=='nl'){
		num_legend = 1;
	} else if (lang=='fr'){
		num_legend = 2;
	} else if (lang=='en'){
		num_legend = 3;
	}
	if (nbThumb>7) $('carrousel_flecheD').style.display='block';
}
/* fin init des variables */

function nomage(){
	eltFilet = $('filet');
	eltToScroll = $('scroller');
	eltVscroll = $('blockTextScroll')
	return eltFilet,eltToScroll,eltVscroll;
}

function fermerZoom(){
	nomage();
	thumbEncours = '';
	eltFilet.style.display= 'none';
	for(i=1;i<=50;i++){
		if ($('thumb_'+i)){
			$('thumb_'+i).style.background="#b6e2f7 url(fileadmin/templates/images/bio_flech.gif) bottom right no-repeat";
		}
		if ($('conteneurZoom_'+i)){
			$('conteneurZoom_'+i).style.display="none";
		}
	}
}

function lienTextImage(image){
	elt = document.getElementsByName('link_'+image)[0];
	tmp = elt.id.split('_');
	eltId = tmp[1];
	afficherZoom(eltId);
}


function afficherZoom(num){
	fermerZoom();
	
	if (num<firstThumb){
		diff = firstThumb-num;
		pas = pas*diff;
		for (i=0;i<diff;i++){
			ToScroll('left');
		}
	} else if (num>lastThumb){
		diff = num-lastThumb;
		pas = pas*diff;
		for (i=0;i<diff;i++){
			ToScroll('right');
		}
	}




	eltThumb = $('thumb_'+num);
	
	eltThumbName = eltThumb.name;
	tmp = eltThumbName.split('_');
	
	if ($('lienImage_'+tmp[1])){
		VscrollValue = getOffsets($('lienImage_'+tmp[1]))[0];
		eltVscroll.scrollTop = VscrollValue-400;
	}
	
	thumbEncours = num;
	Largeur = (((num-1)*tmp_pas) + 80);
	eltFilet.style.width = Largeur+'px';
	eltFilet.style.display= 'block';
	//alert(num);
	//alert(Largeur);
	eltThumb.style.background= '#ef8739';
	
	eltConteneurZoom = $('conteneurZoom_'+num);
	eltConteneurZoom.style.display= 'block';
	
}

function ToScroll(sens){
	fermerZoom();
	if (sens=='left'){
		if (firstThumb>1){
			firstThumb-=1;
			lastThumb-=1;
			positionFilet+=tmp_pas;
		  if (navigator.appName != 'Microsoft Internet Explorer'){
			 eltFilet.style.left=positionFilet+'px';
			 }
			
			if (firstThumb==1){ $('carrousel_flecheG').style.display='none';}
			if (lastThumb<nbThumb){ $('carrousel_flecheD').style.display='block';}
			ToScrollLeft();
		}
	} else if (sens=='right'){
		if (lastThumb<nbThumb){
			firstThumb+=1;
			lastThumb+=1;
			positionFilet-=tmp_pas;
			if (navigator.appName != 'Microsoft Internet Explorer'){
			 eltFilet.style.left=positionFilet+'px';
			}
			if (firstThumb>1){ $('carrousel_flecheG').style.display='block'; }
			if (lastThumb==nbThumb){ $('carrousel_flecheD').style.display='none';}
			ToScrollRight();
		}
	}
}

function ToScrollLeft(){
	SvalueRight = 0;
	clearTimeout(timerLeft);
	clearTimeout(timerRight);
	if (SvalueLeft<(pas/2)){
		SvalueLeft++;
		eltToScroll.scrollLeft-=2;
		timerLeft=setTimeout("ToScrollLeft()",10)
	} else {
		SvalueLeft = 0;
		pas = tmp_pas;
	}
}

function ToScrollRight(){
	SvalueLeft = 0;
	clearTimeout(timerLeft);
	clearTimeout(timerRight);
	if (SvalueRight<(pas/2)){
		SvalueRight++;
		eltToScroll.scrollLeft+=2;
		timerRight=setTimeout("ToScrollRight()",10)
	} else {
		SvalueRight = 0;
		pas = tmp_pas;
	}
}

function rollOnThumb(id){
	if (id!=thumbEncours) $('thumb_'+id).style.background='#ef8739';
}
function rollOffThumb(id){
	if (id!=thumbEncours) $('thumb_'+id).style.background="#b6e2f7 url(fileadmin/templates/images/bio_flech.gif) bottom right no-repeat";
}