var tableauSlideShow = new Array(); var tableauIndiceSlideShow = new Array(); var tableauDescriptionSlideShow = new Array(); var tableauTitreSlideShow = new Array(); var opaciteFondSlideShow = 80; var ouvertureSlideShow = "non"; var caseGrandeWidth = 200; var caseGrandeHeight = 150; var etatExecution = "bypass"; var vistesseAnimSlideShow = 5; var etatSlideShow = "inactif"; var numTableauActif = 0; var timerDiaporamaSlideShow; var etatDiaporamaSlideShow = "stop"; document.onkeypress = actionTouche; function actionTouche(event) { if (etatSlideShow == "actif") { var code = event.keyCode ? event.keyCode : event.which; if ((code == 43) || (code == 39)) { deplacementSlideShow('avancer',numTableauActif); } else if ((code == 45) || (code == 37)) { deplacementSlideShow('reculer',numTableauActif); } else if (code == 27) { fermerSlideShow(); } else if (code == 13) { diaporamaSlideShow(numTableauActif); } else { //alert(code); } } } $(window).resize(function() { if (etatSlideShow == "actif") { calageSlideShow(); recentrageAuto(); } }); function chargementGrandePhotoSlide(option1,option2) { document.getElementById('caseGrande').innerHTML = "\"\""; } function zapperGrandePhotoSlide(option1,option2) { var nbMaxSlideShow = tableauSlideShow[option2].length; var indiceMaxSlideShow = nbMaxSlideShow - 1; var indiceSlideShow = tableauIndiceSlideShow[option2]; //window.alert(indiceSlideShow+" sur " +nbMax); if (option1 == "avancer") { indiceSlideShow = indiceSlideShow + 1; if (indiceSlideShow > indiceMaxSlideShow) { indiceSlideShow = 0; } } else if (option1 == "reculer") { indiceSlideShow = indiceSlideShow - 1; if (indiceSlideShow < 0) { indiceSlideShow = indiceMaxSlideShow; } } tableauIndiceSlideShow[option2] = indiceSlideShow; var fichierSuivant = tableauSlideShow[option2][indiceSlideShow]; //$('#imageGrande').fadeIn('fast'); document.getElementById('caseGrande').innerHTML = "\"\""; } function deplacementAuto(sens,numTableau) { if (etatDiaporamaSlideShow == "start") { var nbMaxSlideShow = tableauSlideShow[numTableau].length; var indiceMaxSlideShow = nbMaxSlideShow - 1; var indiceSlideShow = tableauIndiceSlideShow[numTableau]; //window.alert(indiceSlideShow+" sur " +nbMax); if (sens == "avancer") { indiceSlideShow = indiceSlideShow + 1; if (indiceSlideShow > indiceMaxSlideShow) { indiceSlideShow = 0; } } else if (sens == "reculer") { indiceSlideShow = indiceSlideShow - 1; if (indiceSlideShow < 0) { indiceSlideShow = indiceMaxSlideShow; } } tableauIndiceSlideShow[numTableau] = indiceSlideShow; var fichierSuivant = tableauSlideShow[numTableau][indiceSlideShow]; document.getElementById('caseGrandeTemp').innerHTML = "\"\""; //document.getElementById('caseGrande').innerHTML = "\"\""; } } function permuterSlideShow(numTableau) { $('#imageGrande').fadeOut('slow', function() { document.getElementById('imageGrande').src = document.getElementById('imageGrandeTemp').src; if (etatDiaporamaSlideShow == "start") { allumerSlideShowAuto('imageGrande',numTableau); } }); } function afficherGrandePhotoSlide(option1,option2) { $('#caseGrande').fadeIn('fast'); var hauteurPhoto = parseInt($("#"+option1).height()); var largeurPhoto = parseInt($("#"+option1).width()); var formatPhoto = "portrait"; if (largeurPhoto > hauteurPhoto) { formatPhoto = "paysage"; } else if (largeurPhoto == hauteurPhoto) { formatPhoto = "carre"; } var hauteurLimite = hautEcran - 150; var largeurLimite = largEcran - 100; //window.alert("largeurPhoto = "+largeurPhoto+" / hauteurPhoto = "+hauteurPhoto+" -> "+formatPhoto); if ((formatPhoto == "paysage") || (formatPhoto == "carre")) { var newLargeurPhoto = largeurLimite; var newHauteurPhoto = hauteurPhoto * newLargeurPhoto / largeurPhoto; } else { var newHauteurPhoto = hauteurLimite; var newLargeurPhoto = largeurPhoto * newHauteurPhoto / hauteurPhoto; } if (newLargeurPhoto > largeurLimite) { newLargeurPhoto = largeurLimite; newHauteurPhoto = hauteurPhoto * newLargeurPhoto / largeurPhoto; } if (newHauteurPhoto > hauteurLimite) { newHauteurPhoto = hauteurLimite; newLargeurPhoto = largeurPhoto * newHauteurPhoto / hauteurPhoto; } newHauteurPhoto = Math.round(newHauteurPhoto,0); newLargeurPhoto = Math.round(newLargeurPhoto,0); document.getElementById(option1).style.width = newLargeurPhoto+"px"; document.getElementById(option1).style.height = newHauteurPhoto+"px"; hauteurPhoto = parseInt($("#"+option1).height()); largeurPhoto = parseInt($("#"+option1).width()); hauteurPhoto = parseInt(hauteurPhoto); hauteurPhoto = hauteurPhoto + 4; largeurPhoto = parseInt(largeurPhoto); largeurPhoto = largeurPhoto + 4; if (largeurPhoto > caseGrandeWidth) { var directionLargeur = "augmenter"; } else { var directionLargeur = "diminuer"; } if (hauteurPhoto > caseGrandeHeight) { var directionHauteur = "augmenter"; } else { var directionHauteur = "diminuer"; } //window.alert("hauteurPhoto = "+hauteurPhoto+" / newHauteurPhoto = "+newHauteurPhoto+" -> "+directionHauteur); $('#caseGrande').fadeIn('slow', function() { animerCaseGrande('caseGrande',option2,largeurPhoto,hauteurPhoto,directionLargeur,directionHauteur); }); } function afficherGrandePhotoSlideAuto(option1,option2) { $('#caseGrande').fadeIn('slow'); var hauteurPhoto = parseInt($("#caseGrandeTemp").height()); var largeurPhoto = parseInt($("#caseGrandeTemp").width()); var formatPhoto = "portrait"; //window.alert(largeurPhoto+" X "+hauteurPhoto); if (largeurPhoto > hauteurPhoto) { formatPhoto = "paysage"; } else if (largeurPhoto == hauteurPhoto) { formatPhoto = "carre"; } var hauteurLimite = hautEcran - 150; var largeurLimite = largEcran - 100; //window.alert("largeurPhoto = "+largeurPhoto+" / hauteurPhoto = "+hauteurPhoto+" -> "+formatPhoto); if ((formatPhoto == "paysage") || (formatPhoto == "carre")) { var newLargeurPhoto = largeurLimite; var newHauteurPhoto = hauteurPhoto * newLargeurPhoto / largeurPhoto; } else { var newHauteurPhoto = hauteurLimite; var newLargeurPhoto = largeurPhoto * newHauteurPhoto / hauteurPhoto; } if (newLargeurPhoto > largeurLimite) { newLargeurPhoto = largeurLimite; newHauteurPhoto = hauteurPhoto * newLargeurPhoto / largeurPhoto; } if (newHauteurPhoto > hauteurLimite) { newHauteurPhoto = hauteurLimite; newLargeurPhoto = largeurPhoto * newHauteurPhoto / hauteurPhoto; } newHauteurPhoto = Math.round(newHauteurPhoto,0); newLargeurPhoto = Math.round(newLargeurPhoto,0); document.getElementById(option1).style.width = newLargeurPhoto+"px"; document.getElementById(option1).style.height = newHauteurPhoto+"px"; hauteurPhoto = parseInt($("#"+option1).height()); largeurPhoto = parseInt($("#"+option1).width()); hauteurPhoto = parseInt(hauteurPhoto); hauteurPhoto = hauteurPhoto + 4; largeurPhoto = parseInt(largeurPhoto); largeurPhoto = largeurPhoto + 4; if (largeurPhoto > caseGrandeWidth) { var directionLargeur = "augmenter"; } else { var directionLargeur = "diminuer"; } if (hauteurPhoto > caseGrandeHeight) { var directionHauteur = "augmenter"; } else { var directionHauteur = "diminuer"; } //window.alert("hauteurPhoto = "+hauteurPhoto+" / newHauteurPhoto = "+newHauteurPhoto+" -> "+directionHauteur); $('#caseGrande').fadeIn('slow', function() { animerCaseGrande('caseGrande',option2,largeurPhoto,hauteurPhoto,directionLargeur,directionHauteur); $("#imageGrande").fadeIn('slow', function() { setTimeout("deplacementAuto('avancer',numTableauActif)",7000); }); }); } function afficherGrandePhotoSlide2(option1,option2) { var hauteurPhoto = parseInt($("#"+option1).height()); var largeurPhoto = parseInt($("#"+option1).width()); var formatPhoto = "portrait"; var hauteurLimite = hautEcran - 150; var largeurLimite = largEcran - 100; if (largeurPhoto > hauteurPhoto) { formatPhoto = "paysage"; } else if (largeurPhoto == hauteurPhoto) { formatPhoto = "carre"; } //window.alert("largeurPhoto = "+largeurPhoto+" / hauteurPhoto = "+hauteurPhoto+" -> "+formatPhoto); if ((formatPhoto == "paysage") || (formatPhoto == "carre")) { var newLargeurPhoto = largeurLimite; var newHauteurPhoto = hauteurPhoto * newLargeurPhoto / largeurPhoto; } else { var newHauteurPhoto = hauteurLimite; var newLargeurPhoto = largeurPhoto * newHauteurPhoto / hauteurPhoto; } if (newLargeurPhoto > largeurLimite) { newLargeurPhoto = largeurLimite; newHauteurPhoto = hauteurPhoto * newLargeurPhoto / largeurPhoto; } if (newHauteurPhoto > hauteurLimite) { newHauteurPhoto = hauteurLimite; newLargeurPhoto = largeurPhoto * newHauteurPhoto / hauteurPhoto; } newHauteurPhoto = Math.round(newHauteurPhoto,0); newLargeurPhoto = Math.round(newLargeurPhoto,0); document.getElementById(option1).style.width = newLargeurPhoto+"px"; document.getElementById(option1).style.height = newHauteurPhoto+"px"; caseGrandeWidth = newLargeurPhoto + 4; caseGrandeHeight = newHauteurPhoto + 4; document.getElementById("caseGrande").style.width = caseGrandeWidth+"px"; document.getElementById("caseGrande").style.height = caseGrandeHeight+"px"; //window.alert("newLargeurPhoto = "+newLargeurPhoto+" / newHauteurPhoto = "+newHauteurPhoto+" -> "+formatPhoto); recentrage('caseGrande',caseGrandeWidth,caseGrandeHeight) var tableauPosition = recentrage(option1,newLargeurPhoto,newHauteurPhoto); var topCase = tableauPosition[0]; var leftCase = tableauPosition[1]; calageMenuSlideShow(numTableauActif,topCase,leftCase,caseGrandeHeight) } function calageSlideShow() { var d=dimension_detect(); largEcran = $(window).width(); hautEcran = $(window).height(); document.getElementById('fondOver').style.top = "0px"; document.getElementById('fondOver').style.left = "0px"; document.getElementById('fondOver').style.width = largEcran+"px"; document.getElementById('fondOver').style.height = hautEcran+"px"; } function recentrage(id,largeurObj,hauteurObj) { var d=dimension_detect(); var tableauPosition = new Array(); largEcran = $(window).width(); hautEcran = $(window).height(); var newTop = (hautEcran / 2) - (hauteurObj / 2); var newLeft = (largEcran / 2) - (largeurObj / 2); //window.alert("hautEcran = "+hautEcran+" / hauteurObj = "+hauteurObj); newTop = Math.round(newTop,0); newLeft = Math.round(newLeft,0); document.getElementById(id).style.top = newTop+"px"; document.getElementById(id).style.left = newLeft+"px"; //window.alert("newTop = "+newTop+" / newLeft = "+newLeft); tableauPosition[0] = newTop; tableauPosition[1] = newLeft; return tableauPosition; } function recentrageAuto() { afficherGrandePhotoSlide2("imageGrande",numTableauActif); } function fermerSlideShow() { clearInterval(timerDiaporamaSlideShow); etatDiaporamaSlideShow = "stop"; if (document.getElementById('boutonStartDiaporamaSlideShow')) { document.getElementById('boutonStartDiaporamaSlideShow').src = "/images/petiteFlecheLecture.png"; } etatSlideShow = "inactif"; $("#titreSlideShow").fadeOut('slow'); $("#menuSlideShow").fadeOut('slow'); $("#imageGrande").fadeOut('slow'); $("#caseGrande").fadeOut('slow'); $("#fondOver").fadeOut('slow'); } function openSlideShow(fichier,numTableau,numIndice) { //window.alert(numIndice); etatSlideShow = "actif"; numTableauActif = numTableau; tableauIndiceSlideShow[numTableau] = numIndice; recentrage('chargementOver',150,20); calageSlideShow(); $("#chargementOver").fadeIn('slow'); $('#fondOver').fadeTo('slow', 0.80, function() { chargementGrandePhotoSlide(fichier,numTableau); }); } function testJb(fichier,numTableau) { window.alert("Fichier = "+fichier+" numTableau = "+numTableau); } function allumerSlideShow(id,numTableau) { $("#chargementOver").fadeOut(); document.getElementById('caseGrande').style.width = caseGrandeWidth+"px"; document.getElementById('caseGrande').style.height = caseGrandeHeight+"px"; afficherGrandePhotoSlide(id,numTableau); } function allumerSlideShowAuto(id,numTableau) { $("#chargementOver").fadeOut(); document.getElementById('caseGrande').style.width = caseGrandeWidth+"px"; document.getElementById('caseGrande').style.height = caseGrandeHeight+"px"; afficherGrandePhotoSlideAuto(id,numTableau); } function animerCaseGrande(id,numTableau,largeurPhoto,hauteurPhoto,directionLargeur,directionHauteur) { var testDif = 0; if ((caseGrandeWidth != largeurPhoto) || (caseGrandeHeight != hauteurPhoto)) { if (directionLargeur == "diminuer") { if (caseGrandeWidth > largeurPhoto) { testDif = caseGrandeWidth - largeurPhoto; if (testDif > 50) { caseGrandeWidth = caseGrandeWidth - 50; } else if (testDif > 10) { caseGrandeWidth = caseGrandeWidth - 10; } else { caseGrandeWidth = caseGrandeWidth - 2; } } if (caseGrandeWidth < largeurPhoto) { caseGrandeWidth = largeurPhoto; } } else { if (caseGrandeWidth < largeurPhoto) { testDif = largeurPhoto - caseGrandeWidth; if (testDif > 50) { caseGrandeWidth = caseGrandeWidth + 50; } else if (testDif > 10) { caseGrandeWidth = caseGrandeWidth + 10; } else { caseGrandeWidth = caseGrandeWidth + 2; } } if (caseGrandeWidth > largeurPhoto) { caseGrandeWidth = largeurPhoto; } } if (directionHauteur == "diminuer") { if (caseGrandeHeight > hauteurPhoto) { testDif = caseGrandeHeight - hauteurPhoto; if (testDif > 50) { caseGrandeHeight = caseGrandeHeight - 50; } else if (testDif > 10) { caseGrandeHeight = caseGrandeHeight - 10; } else { caseGrandeHeight = caseGrandeHeight - 2; } } if (caseGrandeHeight < hauteurPhoto) { caseGrandeHeight = hauteurPhoto; } } else { if (caseGrandeHeight < hauteurPhoto) { testDif = hauteurPhoto - caseGrandeHeight; if (testDif > 50) { caseGrandeHeight = caseGrandeHeight + 50; } else if (testDif > 10) { caseGrandeHeight = caseGrandeHeight + 10; } else { caseGrandeHeight = caseGrandeHeight + 2; } } if (caseGrandeHeight > hauteurPhoto) { caseGrandeHeight = hauteurPhoto; } } document.getElementById(id).style.width = caseGrandeWidth+"px"; document.getElementById(id).style.height = caseGrandeHeight+"px"; var tableauPosition = recentrage(id,caseGrandeWidth,caseGrandeHeight); setTimeout("animerCaseGrande('"+id+"',"+numTableau+","+largeurPhoto+","+hauteurPhoto+",'"+directionLargeur+"','"+directionHauteur+"')",5); } else { var tableauPosition = recentrage(id,caseGrandeWidth,caseGrandeHeight); var topCase = tableauPosition[0]; var leftCase = tableauPosition[1]; $("#imageGrande").fadeIn('slow'); calageMenuSlideShow(numTableau,topCase,leftCase,caseGrandeHeight); $("#menuSlideShow").fadeIn('slow'); $("#titreSlideShow").fadeIn('slow'); } } function calageMenuSlideShow(numTableau,topCase,leftCase,caseGrandeHeight) { //CALAGE MENU topCase = parseInt(topCase); leftCase = parseInt(leftCase); var topCaseMenu = topCase + caseGrandeHeight + 8; document.getElementById("menuSlideShow").style.top = topCaseMenu+"px"; document.getElementById("menuSlideShow").style.left = leftCase+"px"; document.getElementById("menuSlideShow").style.width = caseGrandeWidth+"px"; var caseDescriptionSlideShow = caseGrandeWidth - 120; var nbPhotoSlideShow = tableauSlideShow[numTableau].length; var indiceActuel = tableauIndiceSlideShow[numTableau]; var numImageActuelle = indiceActuel + 1; var codeHtmlMenuSlideShow = "
"; if (tableauTitreSlideShow[numTableau][indiceActuel]) { codeHtmlMenuSlideShow += "
"+tableauTitreSlideShow[numTableau][indiceActuel]+"
"; } if (tableauDescriptionSlideShow[numTableau][indiceActuel]) { codeHtmlMenuSlideShow += "
"+tableauDescriptionSlideShow[numTableau][indiceActuel]+"
"; } else { codeHtmlMenuSlideShow += " "; } codeHtmlMenuSlideShow += "
"; codeHtmlMenuSlideShow += "
"; if (nbPhotoSlideShow > 1) { codeHtmlMenuSlideShow += ""; if ((etatDiaporamaSlideShow == "stop") || (etatDiaporamaSlideShow == "pause")) { codeHtmlMenuSlideShow += ""; } else { codeHtmlMenuSlideShow += ""; } codeHtmlMenuSlideShow += ""; } else { codeHtmlMenuSlideShow += " "; } codeHtmlMenuSlideShow += "
"; document.getElementById("menuSlideShow").innerHTML = codeHtmlMenuSlideShow; var topCaseTitre = topCase - 20; document.getElementById("titreSlideShow").style.top = topCaseTitre+"px"; document.getElementById("titreSlideShow").style.left = leftCase+"px"; document.getElementById("titreSlideShow").style.width = caseGrandeWidth+"px"; var codeHtmlTitreSlideShow = "
"; if (nbPhotoSlideShow > 1) { codeHtmlTitreSlideShow += "image "+numImageActuelle+" sur "+nbPhotoSlideShow; } else { codeHtmlTitreSlideShow += " "; } codeHtmlTitreSlideShow += "
Fermer
"; document.getElementById("titreSlideShow").innerHTML = codeHtmlTitreSlideShow; } function diaporamaSlideShow(numTableau) { if ((etatDiaporamaSlideShow == "stop") || (etatDiaporamaSlideShow == "pause")) { etatDiaporamaSlideShow = "start"; document.getElementById('boutonStartDiaporamaSlideShow').src = "/images/petiteFlechePause.png"; setTimeout("deplacementAuto('avancer',"+numTableau+")",3000); } else if (etatDiaporamaSlideShow == "start") { etatDiaporamaSlideShow = "stop"; document.getElementById('boutonStartDiaporamaSlideShow').src = "/images/petiteFlecheLecture.png"; } } function deplacementSlideShow(sens,numTableau) { $("#chargementOver").fadeIn('slow'); $("#titreSlideShow").fadeOut('slow'); $("#menuSlideShow").fadeOut('slow'); $("#imageGrande").fadeOut('slow'); $('#caseGrande').fadeOut('slow', function() { zapperGrandePhotoSlide(sens,numTableau); }); }