/* DATE DE CREATION: 15.03.2005 */
// Constante
function init() {

interv = setInterval ("ptite_photo(1)", 2000) ;
}

function diaporama( option, i, p) {
//var tMessage ;
if (i < 313) {
    document.getElementById("tiDiaporama").value = menuD[i][0] ;
    p = 0 ;
	paCourante = 0 ;
	albumCourant = i ;
  }
  else {
  i = albumCourant ;
  paCourante = paCourante + p ;
  p = paCourante ;
  }

selectPhoto(p, 4) ;

if (option == 0) {
  document.write('<TD align="Center" WIDTH=50 >') ;
  document.write(' <IMG SRC="image/prev_2.jpg" ONCLICK="diaporama(1, 313, -1)" BORDER=0 WIDTH=40 HEIGHT=44></TD>') ;
  document.write('</TD>') ;
  for(i=0; i<4; i++){
	document.write('<TD align="Center" width 100 heigth 100>') ;
//	document.write("Photo "+i) ;
    if (lph[i] >=0) {
  	  if (ph[lph[i]][0].length > 1) 
  	    document.write(' <IMG ID="image'+i+'" SRC="image/p/'+ph[lph[i]][0]+'" ONCLICK="viewPhoto(3,'+i+')" BORDER=1 WIDTH=100 HEIGHT=70>') ;
	  else  
	     document.write(' <IMG ID="image'+i+'" SRC="image/pasphoto.jpg" ONCLICK="viewPhoto(3,'+i+')" BORDER=1 WIDTH=100 HEIGHT=70>') ;
	  }	 
    else  
    document.write(' <IMG ID="image'+i+'" SRC="image/pasphoto.jpg" ONCLICK="viewPhoto(3,'+i+')" BORDER=1 WIDTH=100 HEIGHT=70>') ;
	document.write('</TD>') ; 
  }
  document.write('<TD align="Center" WIDTH=50 >') ;
  document.write(' <IMG SRC="image/next_2.jpg" ONCLICK="diaporama(1, 313, +1)" BORDER=0 WIDTH=40 HEIGHT=44></TD>') ;
  document.write('</TD>') ;
  
  if (lph[0] >=0) 
     photo = "image/"+ph[lph[0]][0] ;
  else  	 
	 photo = "image/pasphoto.jpg" ;
  largeur = 400, hauteur = 300 ;
  choixLargHaut(photo, 0, 300, 400) ;

//  alert(photo) ; 
  document.write('<TR><TD align="Center" width=50 >') ;
  document.write('<IMG SRC="image/prev_2.jpg" ONCLICK="defilementPhoto(-1)" BORDER=0 WIDTH=40 HEIGHT=44></TD>') ;
  document.write('<TD colspan="4">') ;
//  document.write('<DIV ALIGN="center"> <IMG ID="imageP" SRC="'+photo+'" WIDTH='+largeur+' HEIGHT='+hauteur+'></DIV>') ;
  document.write('<DIV ALIGN="center"> <IMG ID="imageP" SRC="'+photo+'" BORDER=0 WIDTH="'+largeur+'" HEIGHT="'+hauteur+'"></DIV>') ;
  document.write('</TD>') ;
  document.write('<TD align="Center" width=50 >') ;
  document.write('<IMG SRC="image/next_2.jpg" ONCLICK="defilementPhoto(+1)" BORDER=0 WIDTH=40 HEIGHT=44>') ;
  document.write('</TD>') ;
  document.write('</TR>') ;
  }
else { 
  for(i=0; i<4; i++){
    var image = "image"+i;
    if (lph[i] >=0) { 
      if (ph[lph[i]][0].length > 1) {
        if (document.getElementById(image) == null) 
          document.getElementById(image).src = "image/pasphoto.jpg" ;
	    else   
          document.getElementById(image).src = "image/p/"+ph[lph[i]][0] ;
	    }  
	  else
        document.getElementById(image).src = "image/pasphoto.jpg" ;
	  }	
    else
      document.getElementById(image).src = "image/pasphoto.jpg" ;
  }
//  document.getElementById("msgDiaporama").value = tMessage ;
  }	
}

function defilementPhoto(option) {

var prefix = " " ;
var photo = document.getElementById("imageP").src ;
photo = photo.substr(photo.indexOf("/",12)+1) ;

if (albumCourant >= menuD.length ) 
 alert("Page de photos non définies :"+albumCourant) ; 
else 
   prefix = menuD[albumCourant][1] ; 

photo = photo.substr(photo.indexOf(prefix,12)) ;
  	  
var premier="", avant="", apres="", dernier="", temp="" ;
var trouve=false ;
for (i=0; i<ph.length;i++) {
//  alert(tPhotos[i].substring(0,tPhotos[i].indexOf(lieu)-1)) ;
  if (ph[i][0].indexOf(prefix) >= 0) {
     temp = ph[i][0] ;
	 if (temp.length > 1) {
       if (premier.length<1) premier = temp ;
	   if (trouve==true) if (apres.length<1) apres = temp ;
	   dernier = temp ;
       if (photo == temp)
         {
	     trouve = true ;
         }
	   if (trouve==false) avant = temp ;
	 }  
   }   
 }
// alert("flag : "+trouve+" "+premier+" "+avant+" "+apres+" "+dernier) ;
if (trouve==true) { 
  if (option == 1) { // On avance
    if (apres.length>1) photo = apres ;
	else photo = premier ;
    }
  else { // On recule
    if (avant.length>1) photo = avant ;
	else photo = dernier ;
    }
  }
else // Photo pas trouvé, on a du changer d'album
  photo = premier ;	   

viewPhoto(2, -1, photo) ;

}


function selectPhoto(p, nbr)
{
var prefix = " " ;

if (p<0) {alert("Pas de pages précédentes");paCourante=0;return} ;

var tph=new Array() ;
tph=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1] ;
if (albumCourant >= menuD.length ) 
 alert("Page de photos non définies :"+albumCourant) ; 
else {
 prefix = menuD[albumCourant][1] ;
 tMessage = menuD[albumCourant][2] ; }

if (prefix.length > 1)
  for (i=0,j=0,k=0; i<ph.length;i++) {
    if (ph[i][0].indexOf(prefix) >= 0) {
	   if (j>=p*nbr) {
	      tph[k] = i ;
		  k++ ;
		  } ;
	   j++ ;
	   if (k==nbr) break ;
	}   
  }
  if (k==0) { 
     if(p==0) {alert("Pas de photo pour cet album"); paCourante=0; lph = tph ;return } ;
	 else {alert("Pas de pages suivantes"); paCourante--; return } ;
	 }
  
  lph = tph ;
}


function haut() {
    document.write('<TD WIDTH=150 HEIGHT=150 VALIGN="TOP">') ;
    document.write('  <DIV ALIGN="center"><BR><IMG SRC="image/logo_fanfare.jpg" BORDER=0 WIDTH=200 HEIGHT=150></DIV><BR>' ) ;
    document.write('</TD>') ;
//	document.write('<TD BGCOLOR=#009933 WIDTH=5></TD>') ;
    document.write('<TD WIDTH=580 HEIGHT=150 VALIGN="MIDDLE" BGCOLOR="#33FFFF">') ;
    document.write('  <TABLE align="center" WIDTH=380 CELLPADDING=0 CELLSPACING=0 border=0>') ;
    document.write('  <TR>') ;
    document.write('    <TD align="center" class="txttitre"><BR>La Fleur des Neiges<BR>Verbier</B></TD>') ; 
    document.write('  </TR>') ;
    document.write('  </TABLE>') ;		
    document.write('</TD>') ;
//	document.write('<TD BGCOLOR=#009933 WIDTH=5></TD>') ;
    document.write('<TD WIDTH=150 HEIGHT=150 VALIGN="CENTER">') ;
	document.write('  <TABLE align="center" WIDTH=200 CELLPADDING=0 CELLSPACING=0 border=1>') ;
	document.write('    <DIV ALIGN="center"><IMG id=ptPhoto SRC="image/p/fanfare94_50.jpg" " ONCLICK="viewPhoto(0, 0)" ') ;
	document.write('    BORDER=0 WIDTH=150 HEIGHT=120></DIV><BR>' ) ;
	document.write('  </TABLE>') ;		
	document.write('</TD>') ;
	document.write('<TR><TD BGCOLOR=#009933 WIDTH=200 HEIGHT=3></TD>') ;
	document.write('<TD BGCOLOR=#009933 WIDTH=380 HEIGHT=3></TD>') ;
	document.write('<TD BGCOLOR=#009933 WIDTH=200 HEIGHT=3></TD></TR>') ;

	phCourante = "fanfare94_50.jpg" ;
}

function ptite_photo(option) { 
  
var i=Math.round(Math.random()*(ph.length-1)) ;
 
if (option == 0) {
// première fois 
 phCourante = ph[i][0] ;
 document.write('<BR>') ;
 document.write('<TR> <TD align="center" WIDTH=200 VALIGN="BOTTOM">') ;
 document.write('  <DIV ALIGN="center">Clicker pour aggrandir<BR> ');
 document.write(' <IMG id=ptPhoto SRC="'+ph[i][0]+'" ONCLICK="viewPhoto(0, 0)" BORDER=1 WIDTH=100 HEIGHT=93 ></DIV>') ;
 document.write('</A>') ;
 document.write('</TD> </TR>') ; }
 else {
 phCourante = ph[i][0] ;
 if (document.getElementById("ptPhoto") != null) 
     document.getElementById("ptPhoto").src = "image/p/"+ph[i][0] ;
// alert("dans bloc "+phG[i]+ph[i]) ;
 }
	
}


function bas() {
//    document.write('<BR><DIV ALIGN="center"><B>Nombre de visiteurs : ') ;
//    document.write('<BR><img src=\"http://zulu.worldcom.ch/count/Count.exe?df=jcmvFa1.dat&dd=sgrey&ft=0&incr=n&sh=y\" align=\"center\">') ;
      document.write('<DIV ALIGN="center"><BR><FONT COLOR="#669900">Mise à jour - '+dateMaj+'</FONT></DIV><BR>' ) ;
      document.write('<DIV ALIGN="left"><B>Copyright <FONT COLOR="#CC0000">JCMichaud V.</FONT></B></DIV>') ;

}


function menuMembre() { 
 document.write('<BR><BR>') ;
 for(i=0; i<menuM.length; i++){
     document.write('<TR><TD align="center" WIDTH=150 HEIGHT=20 BORDER=1>') ;
     document.write('<A HREF="javascript:listeMembre(1, '+i+') " class=\"menu\">'+menuM[i]+'</A><BR>');
	 document.write('</TD></TR>') ;
 } 	 
}

function menuDiaporama() { 
 document.write('<BR><BR>') ;
 for(i=0; i<menuD.length; i++){
     document.write('<TR><TD align="center" WIDTH=150 HEIGHT=20 BORDER=1>') ;
     document.write('<A HREF="javascript:diaporama(1, '+i+') " class=\"menu\">'+menuD[i][0]+'</A><BR>');
	 document.write('</TD></TR>') ;
 } 	 
}

function listeMembre(option, liste) {

var voir=false ;
var listeHTML = "";

document.getElementById("tiMembre").value = menuM[liste] ;
meCourante = liste ;
  
switch (liste) {
  case 0 : msg = "Membres effectifs de la fanfare"; break ;  
  case 1 : msg = alert("Page de membres en construction :"+meCourante) ; return ;
  case 2 : msg = alert("Page de membres en construction :"+meCourante) ; return ;
  case 3 : msg = alert("Page de membres en construction :"+meCourante) ; return ;
  default : alert("Page de membres pas définie :"+meCourante) ; return ; }

 var oldI="" ;		
 for(i=0; i<membre.length; i++){
     var m = lireChamp(membre[i], "") ;
	 var c = lireChamp(membre[i], ";C;") ;
	 var instr = lireChamp(membre[i], ";I;") ;
	 voir = false ;
     switch (liste) {
      case 0 : voir = true ; break ;
      case 1 : voir = true ; break ;
      case 2 : voir = true ; break ;
      case 3 : voir = true ; break ;
     default : alert("Page de membres pas définie :"+meCourante) ; return ; }
    
     if (voir == true ) {
	   if (instr != oldI) {
	      listeHTML = listeHTML+'<TR><TD class=\"titmembre\" colspan=2><U>'+instr+'</U></TD></TR>' ;
		  }
		  
	   oldI = instr ;
   	   if (c.length>1)
		  listeHTML = listeHTML+'<TR><TD class=\"txtmembre\">'+m+'</TD><TD class=\"txtmembre\"> '+c+'</TD></TR>' ;
	   else	  
          listeHTML = listeHTML+'<TR><TD class=\"txtmembre\"colspan=2>'+m+'</TD></TR>' ;
	 }
    }
	
if (listeHTML.length > 0)
   if(option ==0)
      document.write(listeHTML) ;
   else {
      listeHTML='<TABLE HEIGHT=50 ALIGN="center" BORDER=1>'+listeHTML ;
      listeHTML=listeHTML+'</TABLE>' ;
      document.getElementById("lMembre").innerHTML = listeHTML ;
	  document.getElementById("mMessage").innerHTML = msg ;
	}

}



function programme() { 
		
 for(i=0; i<prg.length; i++){
     var texte = lireChamp(prg[i], ""),
	 date = lireChamp(prg[i], ";D;"),
         lieu = lireChamp(prg[i], ";L;"),
         adr = lireChamp(prg[i], ";A;") ,
		 img = lireChamp(prg[i], ";I;") ;
		 
// document.write(' <IMG id=ptPhoto SRC="'+ph[i]+'" ONCLICK="viewPhoto(0, 0)" BORDER=1 WIDTH=100 HEIGHT=93 ></DIV>') ;
     
     if (adr.length > 1)
       document.write('<TR><TD><A HREF=\"'+adr+'\" TARGET=\"_blank\" class=\"menu\"><U>'+texte+'</U></A></TD><TD>'+date+'</TD><TD>'+lieu+'</TD></TR>') ;
     else      
     if (img.length > 1) {
       document.write('<TR><TD><A ONCLICK="viewPhoto(2, 1, '+img+')" class=\"menu\"><U>'+texte+'</U></A></TD><TD>'+date+'</TD><TD>'+lieu+'</TD></TR>') ;
	   }
	 else
       document.write('<TR><TD>'+texte+'</TD><TD>'+date+'</TD><TD>'+lieu+'</TD></TR>') ;
    }
}


function liens() { 
		
 for(i=0; i<li.length; i++){
     document.write('<BR><BR><A HREF="'+lien[i]+'\" TARGET=\"_blank\" >'+li[i]+'</A>') ;
    }
}


function menuHori() { 
		
 for(i=0; i<meH.length; i++){
     document.write('<TD align="center" WIDTH=30 HEIGHT=20 BORDER=0>') ;
     document.write('<A HREF=\"'+meHLi[i]+'\" TARGET=\"_self\" class=\"menu\">'+meH[i]+'</A>') ;
	 document.write('</TD>') ;
    }
}  

function viewPhoto(option, i, image)
{

// alert(option+" "+i+" "+image) ;

var photo = 'image/pasphoto.jpg' ;
if (option==0) 
  photo = "image/"+phCourante ;
if (option==1 ) {
 var img = lireChamp(prg[i], ";I;") ;
 if (img.length <1) { alert("pas de photo"); return; } ;
 photo = "image/"+img ;
 }
if (option==2) photo = "image/"+image ;
if (option==3) {  
 selectPhoto(paCourante, 4) ;
 if (lph[i]>=0)
   photo = "image/"+ph[lph[i]][0] ;
 else   
   photo = "image/pasphoto.jpg" ;
//alert("view "+photo+" "+albumCourant+" "+paCourante) ;
 }

if (option <= 1) {
  if (photo.length > 1) {                        
    largeur = 600, hauteur = 600 ;
    choixLargHaut(photo, 600, 0, 600) ;
//alert("viewPhoto "+largeur+" "+hauteur) ;

    fenetre=open("", "", "width="+largeur+",height="
    +hauteur+"titlebar=no,top=10,left=10,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no");
    fenetre.document.write("<TITLE>Photos</TITLE>");
    fenetre.document.write("<BODY><CENTER>");
    fenetre.document.write("<INPUT TYPE=BUTTON VALUE='Fermer' NAME='fermer' OnClick='self.close()' >");
    fenetre.document.write("<BR><CENTER><IMG SRC='"+photo+"'><BR>");
    fenetre.document.write("</CENTER></BODY>");
    fenetre.document.close(); }
  else alert("Pas de photo") ;
  }
else {
  if (document.getElementById("imageP") == null) 
     alert("Pas de photo") ;
  else {
    largeur = 400, hauteur = 300 ;
    choixLargHaut(photo, 0, 300, 400) ;
//alert("viewPhoto "+largeur+" "+hauteur) ;

	document.getElementById("imageP").setAttribute('width', largeur.toString()) ;
	document.getElementById("imageP").setAttribute('heigth',hauteur.toString()) ;
    document.getElementById("imageP").src = photo ;
	 }
  }  

}

function affichePhotos()
{
  for(i=0; i<lph.length; i++){
    if (Math.round(i/2) == i/2) document.write('<TR>') ;
	if (lph[i] >= 0)
  	  if (ph[lph[i]][0].length > 1)  
	  document.write('<TD><A HREF="'+lphG[i]+'" TARGET="_blank">') ;
	  document.write(' <IMG ID="Image'+i+'" SRC="'+ph[lph[i]][0]+'" BORDER=0 WIDTH=139 HEIGHT=93>') ;
	  document.write('</A></TD>') ;
	  if (Math.round((i+1)/2) == i/2) document.write('</TR>') ; 
	}

}

function AfficheImage(image, largeur, hauteur)
{
fenetre=open("", "", "width="+largeur+",height="
+hauteur+"titlebar=no,top=10,left=10,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no");
fenetre.document.write("<TITLE>Photos</TITLE>");
fenetre.document.write("<BODY><CENTER>");
fenetre.document.write("<INPUT TYPE=BUTTON VALUE='Fermer' NAME='fermer' OnClick='self.close()' >");
fenetre.document.write("<BR><CENTER><IMG SRC='"+image+"'><BR>");
fenetre.document.write("</CENTER></BODY>");
fenetre.document.close();

}
  
   

function news() { 
		
document.write('<DIV> <IMG SRC="image/white.gif" BORDER=0 WIDTH=5 HEIGHT=1>') ;
document.write('Mises à jour : '+dateMajNews+'<BR><BR>') ;

for(i=tNews.length-1; i>=0; i--){
    document.write('<DIV> <IMG SRC="image/white.gif" BORDER=0 WIDTH=5 HEIGHT=1>') ;
 	document.write(tNews[i][1]+' : <B>'+tNews[i][0]+'</B> : ') ;
	document.write('<IMG SRC="image/ptpoints.gif" OnMouseOver="affiNews('+i+')" OnMouseOut="effNews()"HEIGHT=5></DIV>' ) ; 
    }
	
}

function affiNews(indice) {

//var objCit="cit"+indice ;
var element = "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=#000000> " ;
element = element+"<TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1>" ;
element = element+"<TR><TD BGCOLOR='#33FFFF'><FONT COLOR=#000000 SIZE=1 FACE='Verdana'>" ;
element = element+"<CENTER><B>"+tNews[indice][2]+"</B></CENTER>" ;
element = element+"</TD></TR></TABLE></TD></TR></TABLE>" ;

//alert(element) ;
//alert(tCit[indice][2]) ;
if (document.getElementById)
  {
  document.getElementById("detail").innerHTML = element ;
  document.getElementById("detail").style.left = x+20 ;
  document.getElementById("detail").style.top = y ;
  document.getElementById("detail").style.visibility = "visible" ;
  }

}
function affiTexte(texte) {

//var objCit="cit"+indice ;
var element = "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=#000000> " ;
element = element+"<TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1>" ;
element = element+"<TR><TD BGCOLOR='#33FFFF'><FONT COLOR=#000000 SIZE=1 FACE='Verdana'>" ;
element = element+"<CENTER><B>"+texte+"</B></CENTER>" ;
element = element+"</TD></TR></TABLE></TD></TR></TABLE>" ;

//alert(element) ;
//alert(tCit[indice][2]) ;
if (document.getElementById)
  {
  document.getElementById("detail").innerHTML = element ;
  document.getElementById("detail").style.left = x+20 ;
  document.getElementById("detail").style.top = y ;
  document.getElementById("detail").style.visibility = "visible" ;
  }

}

function effNews() {

if (document.getElementById)
  {
  document.getElementById("detail").innerHTML = "" ;
  document.getElementById("detail").style.visibility = "hidden" ;
  }
}


function choixLargHaut(photo, dimL, dimH, max)
{

// Recherche photo
var dim = "" ;
var temp = photo.substr(6, 12) ;
//alert("Photo "+photo+" temp "+temp+" nombres "+ph.length) ;

if (temp.length <1) temp = photo ;
 
for (i=0; i<ph.length;i++) {
  if (ph[i][0].indexOf(temp) > -1) 
      dim = ph[i][1] ;
  }   

if (dimL > 0) {
  switch (dim) {
    case "D1" : largeur = dimL ; hauteur = 1.33 * dimL ; break ;
    case "D2" : largeur = dimL ; hauteur = 1.66 * dimL ; break ;
    case "D3" : largeur = dimL ; hauteur = 0.66 * dimL ; break ;
    case "D4" : largeur = dimL ; hauteur = 1.20 * dimL ; break ;
    default : break ;
    }
  if (max < hauteur)
    switch (dim) {
      case "D1" : largeur = max / 1.33 ; hauteur = max ; break ;
      case "D2" : largeur = max / 1.66 ; hauteur = max ; break ;
      case "D3" : largeur = max / 0.66 ; hauteur = max ; break ;
      case "D4" : largeur = max / 1.20 ; hauteur = max ; break ;
      default : break ;
    }
  }
else {
  switch (dim) {
    case "D1" : largeur = dimH / 1.33 ; hauteur = dimH ; break ;
    case "D2" : largeur = dimH / 1.66 ; hauteur = dimH ; break ;
    case "D3" : largeur = dimH / 0.66 ; hauteur = dimH ; break ;
    case "D4" : largeur = dimH / 1.20 ; hauteur = dimH ; break ;
    default : break ;
    }
  if (max < largeur)
  switch (dim) {
    case "D1" : largeur = max ; hauteur = 1.33 * max ; break ;
    case "D2" : largeur = max ; hauteur = 1.66 * max ; break ;
    case "D3" : largeur = max ; hauteur = 0.66 * max ; break ;
    case "D4" : largeur = max ; hauteur = 1.20 * max ; break ;
    default : break ;
    }
  }

//alert("Dim : "+dim+" : "+largeur+" "+hauteur+" "+max) ;
 
}

