
/* Gestion du livre de la page d'accueil*/
var book="suite";

var biographie="suite";

/*var preloadTabSize = 41;
var preloadTab= new Array(preloadTabSize);	
var preloadImgTab= new Array(preloadTabSize);	
preloadTab[0] = "../images/book.png";
preloadTab[1] = "../images/book2.png";
preloadTab[2] = "../images/livreblanc.png";
preloadTab[3] = "../images/background.png";
preloadTab[4] = "../images/photoBakst.png";
preloadTab[5] = "../images/collection.png";
preloadTab[6] = "../images/presentation/1.png";
preloadTab[7] = "../images/interview/photo.png";
preloadTab[8] = "../images/interview/links.png";
preloadTab[9] = "../images/chapeaux/1.gif";
preloadTab[10] = "../images/fondbleu.png";
preloadTab[11] = "../images/cadrebleu.png";
preloadTab[12] = "../images/portraitsNus/1.png";
preloadTab[13] = "../images/motifs/1.png";
preloadTab[14] = "../images/paysages/dessins/1.png";
preloadTab[15] = "../images/paysages/peintures/1.png";
preloadTab[16] = "../images/decors/peintures/1.png";
preloadTab[17] = "../images/decors/dessins/1.png";
preloadTab[18] = "../images/costumes/1.png";
preloadTab[19] = "../images/famille.png";
preloadTab[20] = "../images/famille/1.png";
preloadTab[21] = "../images/livres/photobakst.png";
preloadTab[22] = "../images/biographie/correspondance_photo.jpg";
preloadTab[23] = "../images/biographie/correspondance_liens.png";
preloadTab[24] = "../images/biographie/bioSaVie.png";
preloadTab[25] = "../images/biographie/bioBallet1.png";
preloadTab[26] = "../images/biographie/bioBallet2.png";
preloadTab[27] = "../images/biographie/peintures/1.png";

preloadTab[28] = "../images/biographie/gallerie/sm1.png";
preloadTab[29] = "../images/biographie/gallerie/sm2.png";
preloadTab[30] = "../images/biographie/gallerie/sm3.png";
preloadTab[31] = "../images/biographie/gallerie/sm4.png";
preloadTab[32] = "../images/biographie/gallerie/sm5.png";
preloadTab[33] = "../images/biographie/gallerie/sm6.png";
preloadTab[34] = "../images/biographie/gallerie/sm7.png";
preloadTab[35] = "../images/biographie/gallerie/sm8.png";
preloadTab[36] = "../images/biographie/gallerie/sm9.png";
preloadTab[37] = "../images/biographie/gallerie/sm10.png";
preloadTab[38] = "../images/biographie/gallerie/sm11.png";
preloadTab[39] = "../images/biographie/gallerie/sm12.png";
preloadTab[40] = "../images/biographie/gallerie/1.png";

var loaded=false;
if(loaded==false){
	for (i = 0; i < preloadTabSize; i++) { 
		preloadImgTab[i] = new Image;
		preloadImgTab[i].src = preloadTab[i];
	}
	loaded=true;
}
*/


/*Gestion de la photo courante de l'album pour la rubrique famille*/
var currentImgAlbum = 1;


var decors_peintures_album  = new Array(5);
decors_peintures_album [0]="Daphnis et Chloé et leur troupeau";
decors_peintures_album [1]="La pisanelle";
decors_peintures_album [2]="Paysage de Daphnis et Chloé";
decors_peintures_album [3]="Le Martyre de Sain-Sébastien";
decors_peintures_album [4]="La Fée des Lilas";

/*var collection_portraitsnus  = new Array(11);
collection_portraitsnus[0] = "Miss Garrett, amie de Léon Bakst";
collection_portraitsnus[1] = "Maroussia, notre mère, nièce de Léon Bakst";
collection_portraitsnus[2] = "Issaï, frère de Léon Bakst";
collection_portraitsnus[3] = "Sophie, soeur de Léon Bakst";
collection_portraitsnus[4] = "";
collection_portraitsnus[5] = "";
collection_portraitsnus[6] = "";
collection_portraitsnus[7] = "";
collection_portraitsnus[8] = "";
collection_portraitsnus[9] = "";
collection_portraitsnus[10] = "";
collection_portraitsnus[11] = "";
*/

function changeBackground(){
	
	playSound('../sounds/pageflip.mp3')
	if(book=="suite"){
		document.getElementById("book").style.background= "url('/images/book2_" + lang + ".png')";
		book="retour";
	}else{
		document.getElementById("book").style.background= "url('/images/book_" + lang + ".png')";
		book="suite";
	}
}

function playSound(sonALire)
{
	var divContent = "";
	
	divContent += "<object type='application/x-shockwave-flash' data='/sounds/dewplayer.swf?mp3=/sounds/" + sonALire + "&autoplay=1' width=0 height=0 bgcolor=#FFFFFF>";
	divContent += "<param name=movie value='dewplayer.swf?mp3=" + sonALire + "&autoplay=1' />";
	divContent += "<param name=bgcolor value=#FFFFFF>";
	divContent += "</object>";
	document.getElementById("lecteurMP3").innerHTML = divContent;
}

var preImages=new Array;
var current;
var next;
function precharge(path,count,_current,_next) { 
  
  for (i = 1; i <= count; i++) { 
    preImages[i] = new Image();
	if(path=="../images/chapeaux/"){
    	preImages[i].src = path + i +'.gif';
	}else{
		preImages[i].src = path + i +'.png';
	}
  }
  current=_current;
  next=_next;
  
}

var opcurrent=100;
var opnext=0;
var lock=0;
function changeBackgroundAlbum(elt, name, path, i, nbPages){
	if(lock==1){
		return;
	}
	lock=1;
	if(name!="collection_biographie_galerie"){ //exception pour la galerie des ballets
		document.getElementById(name + "_"  + currentImgAlbum).style.color = "#2764F3";
	}
	if ((i == 0) && (currentImgAlbum > 1)) currentImgAlbum -= 1;
	else if ((i == 100) && (currentImgAlbum < nbPages)) currentImgAlbum += 1;
	else currentImgAlbum = i;
	if (currentImgAlbum <= 0) currentImgAlbum = 1;
	if (currentImgAlbum > nbPages) currentImgAlbum = nbPages;
	
	/*img = new Image; 
	if(elt=="whiteBookChapeauxContent"){
		img.src = path + currentImgAlbum + ".gif";
	}else{
		img.src = path + currentImgAlbum + ".png";
	}*/
	img = preImages[currentImgAlbum];

	document.getElementById(next).style.background = "url("+ img.src+") center center no-repeat";
	
	if(name!="collection_biographie_galerie"){//exception pour la galerie des ballets
		document.getElementById(name + "_"  + currentImgAlbum).style.color = "white";
	}
	
	
	if (elt == "albumfamillecontent"){
		var currentAlbum = famille_album;	
		document.getElementById("albumfamillecomment").innerHTML=currentAlbum[currentImgAlbum-1];
	}else if(elt == "presentationcontent"){
		var currentAlbum = presentation_album;
		document.getElementById("blackBoxPresentationComment").innerHTML=currentAlbum[currentImgAlbum-1];
	}else if(elt == "decorspeinturescontent"){
		var currentAlbum = decors_peintures_album;
		document.getElementById("blackBoxHeaderComment").innerHTML=currentAlbum[currentImgAlbum-1];
	}else if(elt=="biographiepeinturescontent"){
    var currentAlbum = biographie_peintures;
		document.getElementById("bioSubTxt").innerHTML=currentAlbum[currentImgAlbum-1];
	} else if(elt=="portraitsNuscontent"){
		var currentAlbum = collection_portraitsnus;
		document.getElementById("portraitsnusCommentLine").innerHTML=currentAlbum[currentImgAlbum-1];
		
		// Actuellement seuls les 4 premières images ont un commentaire, pour le reste on cache le cadre noir
		if (currentImgAlbum > 4) {
			document.getElementById("portraitsnusCommentBox").style.visibility = "hidden";
		}
		else {
			document.getElementById("portraitsnusCommentBox").style.visibility = "visible";
		}
	} else if(elt=="costumescontent"){
		if (currentImgAlbum < 6) {
			document.getElementById("costumeZoomBox").style.visibility = "hidden";
			document.getElementById("costumeZoomLine").style.visibility = "hidden";
		}
		else {
			zoomImg = new Image;
			zoomImg.src = "zoom/" + currentImgAlbum + ".jpg";
			document.getElementById("zoomCostumeLink").href=zoomImg.src;
			document.getElementById("costumeZoomBox").style.visibility = "visible";
			document.getElementById("costumeZoomLine").style.visibility = "visible";
		}
		
	} else if(elt=="motifscontent"){
		if ((currentImgAlbum != 6) && (currentImgAlbum != 7) && (currentImgAlbum != 11)) {
			document.getElementById("motifsZoomBox").style.visibility = "hidden";
			document.getElementById("motifsZoomLine").style.visibility = "hidden";
		}
		else {
			zoomImg = new Image;
			zoomImg.src = path + "zoom/" + currentImgAlbum + ".jpg";
			document.getElementById("zoomMotifsLink").href=zoomImg.src;
			document.getElementById("motifsZoomBox").style.visibility = "visible";
			document.getElementById("motifsZoomLine").style.visibility = "visible";
		}
		
	}
	
	if((elt == "decorspeinturescontent")){
		zoomImg = new Image;
		zoomImg.src = path + "zoom/" + currentImgAlbum + ".jpg";
		document.getElementById("zoomLink").href=zoomImg.src;
	}
	
	if(navigator.appVersion.indexOf("MSIE 6.0")<0){
		defilmage();
	}else{
		document.getElementById(current).style.background = "none";
		lock=0;
	}
}


function defilmage(reg){
	var imgcurrent=document.getElementById(current);
	var imgnext=document.getElementById(next);
	opcurrent-=3;
	opnext+=3;
	if(document.all && !window.opera){ 
		imgcurrent.style.filter = 'alpha(opacity=' + opcurrent + ');' ;
		imgnext.style.filter = 'alpha(opacity=' + opnext + ');';
	} 
	else{ 
		imgcurrent.style.opacity = opcurrent/100;
		imgnext.style.opacity = opnext/100;
	}
	if(opcurrent<=0){
		opcurrent=100;
		opnext=0;;
		var tmp
		tmp=current;
		current=next;
		next=tmp;
		lock=0;
		return false;
	}
	setTimeout("defilmage()",25);
}

function changeBackgroundAlbumBook(name, i, page){
	var currentAlbum = famille_album;
	document.getElementById(name + "_"  + currentImgAlbum).style.color = "#2764F3";
	if ((i == 0) && (currentImgAlbum > 1)) currentImgAlbum -= 1;
	else if ((i == 100) && (currentImgAlbum < 17)) currentImgAlbum += 1;
	else currentImgAlbum = i;
	if (currentImgAlbum <= 0) currentImgAlbum = 1;
	if (currentImgAlbum > 17) currentImgAlbum = 17;
	img = new Image; 
	img.src = path + currentImgAlbum + ".png";
	document.getElementById("whiteBookChapeauxContent").style.background= "url(" + img.src + ") center no-repeat";
	document.getElementById(name + "_"  + currentImgAlbum).style.color = "white";
}

function changeSlide(name, i, size){
	document.getElementById(name + "_"  + currentImgAlbum).style.color = "#2764F3";
	if (i == 0) currentImgAlbum -= 1;
		else if (i == 100) currentImgAlbum += 1;
		else currentImgAlbum = i;
	if (currentImgAlbum > size) currentImgAlbum = 1;
	if (currentImgAlbum < 1) currentImgAlbum = size;
	myGallery.goTo(currentImgAlbum - 1);
	document.getElementById(name + "_"  + currentImgAlbum).style.color = "white";
}

function popup(URL,title,height,width) {
	/*var left;
	var top;
	top = ((screen.height -400) / 2);
	left = ((screen.width - 550) / 2);
	win  = window.open(URL, title, "toolbar=0,scrollbars=0,location=0,status=0,menubar=0,directories=0,resizable=0,width="+width+",height="+height+",left="+left+",top="+top+"");*/
	var PosX = ( screen.availWidth - height) / 2; 
	var PosY = ( screen.availHeight - width ) / 2; 
	var option = "resizable=yes,toolbar=no,scrollbars=yes,menubar=yes,top="+PosY+",left="+PosX+",width="+width+",height="+height; 
	window.open(URL,title,option); 	
}

function blurLink(elt) {
	elt.blur();
}





/****************changeSaViePage*****************/
var biographie_peintures = new Array(8)
biographie_peintures[0]="A  gauche : le dîner"
biographie_peintures[1]="A  gauche : <span class='white'>Mme Grichenko</span><br/><span style='padding-left:60px'>(Epouse de Léon Bakst,</span><br/><span style='padding-left:60px'>fille de Pavel Tretyakov)</span>"
biographie_peintures[2]="A  gauche : <span class='white'>Diaghilev et sa nourrice</span>"
biographie_peintures[3]="A  gauche : <span class='white'>Alexandre Benois</span><br /><span class='white' style='padding-left:60px'>dans son bureau</span>"
biographie_peintures[4]="A  gauche : Sans titre – Détails"
biographie_peintures[5]="A  gauche : Sans titre"
biographie_peintures[6]="A  gauche : <span class='white'>André Bakst</span>, fils de Léon Bakst"
biographie_peintures[7]="A  gauche : <span class='white'>Paysage Ain – Zainfour -</span> détail"


/*Animation images*/
var imgPath = new Array(6);

function startAnim(min,max,previous,next){ 
  var i;
  for(i=0;i<6;i++){
   var img = new Image;
   img.src= '/images/presentation_anim/'+(i+1)+'.png';
   imgPath[i] = img.src;  
  }  
  defilimg(min,max,min,previous,next); 
} 

function defilimg(min,max,a,previous,next){ 
  if (a == max) { 
    a = min; 
  } 
  img = document.getElementById(previous);
  imgNext = document.getElementById(next);
  if(img && img.filters && img.filters[0]){ 
    img.filters[0].apply(); 
    img.filters[0].play(); 
  }
	
  img.src = imgPath[a]; 
  img.style.display = 'block';
 
  changeOpacity(next,100,-3);  
  changeOpacity(previous,0,3);  
  a++; 
  
  tempo3 = setTimeout("defilimg("+min+","+max+","+a+",'"+next+"','"+previous + "')",4000); 
}  

function changeOpacity(name,opacity,val){
	imgcurrent = document.getElementById(name);
	if(document.all && !window.opera){ 
		imgcurrent.style.filter = 'alpha(opacity=' + opacity + ');' ;
	} 
	else{ 
		imgcurrent.style.opacity = opacity/100;
	}
	if(opacity>=0&&opacity<=100){	
		opacity = opacity + val
		setTimeout("changeOpacity('"+ name + "'," + opacity + "," + val + ")",55);
	}
}



	