var tab = new Array;
var txt = new Array;

tab[0] = 'Inde1937'
txt[0] = '[Inde] Tigre (parc de Ranthambore)'
tab[1] = 'Inde8016'
txt[1] = '[Inde] Taj Mahal (Agra)'
tab[2] = 'Inde1834'
txt[2] = '[Inde] Perruche à tête prune mâle (Psittacula cyanocephala)'
tab[3] = 'Inde2192'
txt[3] = '[Inde] Rollier indien (Coracias benghalensis)'
tab[4] = 'Inde7829'
txt[4] = '[Inde] Jeune singe langur (parc de Ranthambore)'
tab[5] = 'Mada2880'
txt[5] = '[Madagascar] Lézard'
tab[6] = 'Mada3014'
txt[6] = '[Madagascar] Baobab et mare fleurie'
tab[7] = 'Mada3175'
txt[7] = "[Madagascar] Courlis corlieu (Numenius phaeopus) à l'île St Marie"
tab[8] = 'Mada3229'
txt[8] = '[Madagascar] Tisserin sakalave (Ploceus sakalava)'
tab[9] = 'Mada3544'
txt[9] = '[Madagascar] Caméléon de Parson mâle'
tab[10] = 'Namib6628'
txt[10] = '[Namibie] Rufipenne nabouroup (Onychognathus nabouroup)'
tab[11] = 'Namib6631'
txt[11] = '[Namibie] Moineaux écaillés (Sporopipes squamifrons)'
tab[12] = 'Namib7122'
txt[12] = '[Namibie] Oryx gazella'
tab[13] = 'Namib6640'
txt[13] = '[Namibie] Amadine à tête rouge mâle (Amadina erythrocephala)'
tab[14] = 'Namib6822'
txt[14] = '[Namibie] Otarie à crinière de Cape Cross'
tab[15] = 'Namib7008'
txt[15] = '[Namibie] Outarde kori (Ardeotis kori)'
tab[16] = 'Namib7169'
txt[16] = '[Namibie] Elanion blanc (Elanus caeruleus)'
tab[17] = 'Namib7177'
txt[17] = '[Namibie] Rollier à longs brins (Coracias caudata)'
tab[18] = 'Namib7198'
txt[18] = '[Namibie] Grand Koudou mâle'
tab[19] = 'Namib7233'
txt[19] = '[Namibie] Jeune léopard'
tab[20] = 'Nam_6013'
txt[20] = '[Namibie] Dune de Sossusvlei'
tab[21] = 'Nam_6047'
txt[21] = '[Namibie] Dune de Sossusvlei'
tab[22] = 'Nam_6242'
txt[22] = '[Namibie] Petit-duc africain (Otus senegalensis)'
tab[23] = 'Bre0051'
txt[23] = '[Brésil] Toucans toco (Ramphastos toco) se passant un oeuf de cassique'
tab[24] = 'Bre0594'
txt[24] = '[Brésil] Troglodyte à miroir (Donacobius atricapillus)'
tab[25] = 'Bre1093'
txt[25] = '[Brésil] Martin-pêcheur vert mâle (Chloroceryle americana)'
tab[26] = 'Bre1019'
txt[26] = '[Brésil] Caracara huppé (Polyborus plancus)'
tab[27] = 'Bre1064'
txt[27] = '[Brésil] Toui à ailes jaunes (Brotogeris chiriri)'
tab[28] = 'Bre1484'
txt[28] = "[Brésil] Petite grenouille d'Amazonie"
tab[29] = 'Bre1488'
txt[29] = "[Brésil] Petite grenouille d'Amazonie"
tab[30] = 'ZaMa1631'
txt[30] = '[Zambie] Guibes harnachés'
tab[31] = 'ZaMa1795'
txt[31] = '[Zambie] Eléphants traversant la Luangwa'
tab[32] = 'ZaMa1846'
txt[32] = '[Zambie] Jabiru du Sénégal (Ephippiorhynchus senegalensis)'
tab[33] = 'ZaMa1993'
txt[33] = '[Malawi] Bec-ouvert africain (Anastomus lamelligerus)'
tab[34] = 'Zim3871'
txt[34] = '[Zimbabwe] Chûtes Victoria'
tab[35] = 'Zim4698'
txt[35] = '[Zimbabwe] Guêpiers carmins (Merops nubicoides)'
tab[36] = 'Zim4747'
txt[36] = '[Zimbabwe] Jeune babouin'
tab[37] = 'Zim4771'
txt[37] = '[Zimbabwe] Phacochère'
tab[38] = 'Zim4787'
txt[38] = '[Zimbabwe] Rollier à longs brins (Coracias caudata)'
tab[39] = 'Zim4814'
txt[39] = '[Zimbabwe] Calao leucomèle (Tockus leucomelas)'
tab[40] = 'Kenya2422'
txt[40] = "[Kenya] Tchitrec d'Afrique mâle (Terpsiphone viridis) variété blanche"
tab[41] = 'Kenya2823'
txt[41] = '[Kenya] Ombrette africaine (Scopus umbretta)'
tab[42] = 'Kenya2845'
txt[42] = '[Kenya] Choucador de Rüppell (Lamprotornis purpuropterus)'
tab[43] = 'Kenya4143'
txt[43] = '[Kenya] Lionne (parc Masaï Mara)'
tab[44] = 'Kenya8984'
txt[44] = '[Kenya] Vautour africain (Gyps africanus)'
tab[45] = 'Kenya9186'
txt[45] = '[Kenya] Souimanga de Hunter juvénil (Nectarinia hunteri)'
tab[46] = 'Ken2076'
txt[46] = '[Kenya] Léopard (parc de Samburu)'
tab[47] = 'Ken3003'
txt[47] = '[Kenya] Léopard'
tab[48] = 'Ken2582'
txt[48] = '[Kenya] Aigle martial (Polemaetus bellicosus) et pintade vulturine (Acryllium vulturinum)'
tab[49] = 'Ken4686'
txt[49] = '[Kenya] Guépard'
tab[50] = 'Ven1041'
txt[50] = '[Venezuela] Caracara huppé (Polyborus plancus)'
tab[51] = 'Ven1153'
txt[51] = '[Venezuela] Ani des palétuviers (Crotophaga major)'
tab[52] = 'Ven1209'
txt[52] = '[Venezuela] Spatules rosées en route pour le dortoir (Ajaia ajaja)'
tab[53] = 'Ven1218'
txt[53] = '[Venezuela] Tyran quiquivi ou licteur (Pitangus sulphuratus ou Philohydor lictor)'
tab[54] = 'Ven1275'
txt[54] = '[Venezuela] Alcyon (martin-pêcheur) vert (Chloroceryle amazona)'
tab[55] = 'Ven1323'
txt[55] = '[Venezuela] Cabiai (ou capybara), jacana et aigrette'
tab[56] = 'Costa0108'
txt[56] = '[Costa Rica] Ptilogon à longue queue (Ptilogonys caudatus)'
tab[57] = 'Costa2047'
txt[57] = '[Costa Rica] Lézard'
tab[58] = 'Annecy099'
txt[58] = "[Parapente] Couleurs d'automne au soleil couchant (lac d'Annecy)"
tab[59] = 'Annecy880'
txt[59] = "[Parapente] Bout du lac d'Annecy"
tab[60] = 'Oct2196'
txt[60] = '[Parapente] Plage au nord du Havre'
tab[61] = 'Oct9265'
txt[61] = '[Parapente] Au nord du Havre'
tab[62] = 'PDDome798'
txt[62] = '[Parapente] Au Puy-de-Dôme'
tab[63] = 'Maroc4206'
txt[63] = "[Parapente] Au sud d'Agadir (Maroc)"
tab[64] = 'Maroc4207'
txt[64] = "[Parapente] Au sud d'Agadir (Maroc)"
tab[65] = 'Maroc4273'
txt[65] = "[Parapente] A Sidi Ifni, sud d'Agadir (Maroc)"
tab[66] = 'Maroc4211'
txt[66] = "[Parapente] Au sud d'Agadir (Maroc)"
tab[67] = 'M0062'
txt[67] = '[Macro] Papillon'
tab[68] = 'M0077'
txt[68] = '[Macro] Frelon sur poire en Haute Savoie'
tab[69] = 'Mada3498'
txt[69] = '[Macro] Mouche sur frangipanier à Madagascar'
tab[70] = 'Barytine2641'
txt[70] = 'Barytine'
tab[71] = 'QFluoPyrite2668'
txt[71] = 'Quartz et pyrite sur fluorite'

function About(){
 s=document.getElementById('about').style
 s.display=(s.display=='block')?'none':'block'
}

var TFade=0;
var TNav=0;
var Auto=0;
var NImg=0; // Nombre de photos avant la vignette 1
var NThm=1; // Numéro de vignette active
 NbImg=tab.length;  // Nombre total de photos
 NbThm=6;   // Nombre de vignettes

function Page(){ // Affiche NbThm vignettes à partir de NImg+1
 var N=NImg
 for (I=1;I<=NbThm;I++){
  document.getElementById('img'+I).src=tab[N++]+'_.jpg'
  // preload photos ?
 }
}

function Tag(N){
 if (N<0) {N=-N; Color='#6ac250'}
 else {Color=(N==NThm?'#ddd9bd':'#3e5c00')}
 document.getElementById('img'+N).style.borderColor=Color
}

function Select(N){ // Active la vignette N
 var I=NThm
 NThm=N
 Tag(I)
 Tag(N)
}

function Nav(N){ // Active une vignette, scroll possible
 if (Auto>0)  Diapo()  // Stoppe
 var I=N+NThm
 if (I<=0){
   NImg-=NbThm
   I+=NbThm
   if (NImg<0){I+=NImg+1; NImg=0}
   if (I<=0) I=1
   Page()
 } else if (I>NbThm){
   NImg+=NbThm
   I-=NbThm
   if (NImg+NbThm>NbImg){I+=NImg+NbThm-NbImg; NImg=NbImg-NbThm}
   if (I>NbThm) I=NbThm
   Page()
 }

 Select(I)
 TNav=setTimeout(function() {Nav(N);}, 400)
}

function Out(){
 if (TNav!=0 && Auto==0) Show()
}

function Thumb(N){
 if (Auto>0)  Diapo()  // Stoppe
 Select(N)
 Show()
}

function Fade(N){ // Variation de transparence
 if (N>0.98){
  TFade=0
  document.getElementById('photo').style.backgroundImage = 'url(' +tab[NImg+NThm-1] + '.jpg)'
  N=0
 }

 var fs = document.getElementById('fade').style
  fs.opacity = N
  fs.MozOpacity = N
  fs.KhtmlOpacity = N
  fs.filter = 'alpha(opacity=' + N*100 + ')'
  if (N>0){
   N+=0.02
   TFade=setTimeout('Fade(' + N + ')', 25)
 }
}

function Cancel(){ // Stoppe action en cours
 if (TNav!=0 && Auto==0){
   clearTimeout(TNav)
   TNav=0
 }
}

function Show(){ // Affiche la photo sélectionnée
 Cancel()
 if (TFade!=0)
   clearTimeout(TFade) // Fade(1) ?
 N=NImg+NThm
 document.getElementById('legend').firstChild.nodeValue = N+'/'+NbImg+' - '+txt[N-1]
 document.getElementById('fade').src=tab[N-1]+'.jpg'
 Fade(0.2)
}

function Next(){
 var I=NThm+1
 if (I>NbThm) {
   NImg+=NbThm
   I=1
   if (NImg+NbThm>NbImg) {I=NImg+NbThm-NbImg+1; NImg=NbImg-NbThm}
   Page()
 }

 Select(I)
 Show()
 if (NImg+I==NbImg)
   Diapo() // Stoppe
 else
   TNav=setTimeout('Next()', 5500)
}

function Diapo(){
 document.getElementById('diapo').style.backgroundImage = (Auto>0)?'url(Right.gif)':'url(Right2.gif)'
 if (Auto>0){
  Auto=0
  Cancel()
 }
 else{
  if (NImg+NThm==NbImg){
    NImg=-NbThm
    NThm=NbThm
  }  
  Auto=1
  Next()
 }
}
