var lang_p = "fr"; /*creating the bridge object model*/ bridge = function(pic,lgnd) { var image = pic; var legende = lgnd; this.getImage = function(){ return image;}; this.getLegend = function(){ return legende;} } ponts = new Array(); var legendeRecup; if (lang_p === 'fr') { legendeRecup ='Pont Chaban-Delmas'; } else if (lang_p === 'gb') { legendeRecup ='Chaban-Delmas bridge'; } else if (lang_p === 'es') { legendeRecup = 'Puente Chaban Delmas'; } ponts.push(new bridge('/perch/resources/pont-chaban-lavigne-cheron.jpg',legendeRecup)); if (lang_p === 'fr') { legendeRecup ='Passerelle suspendue de Decines - LYON'; } else if (lang_p === 'gb') { legendeRecup ='Decines footbrige - LYON'; } else if (lang_p === 'es') { legendeRecup = 'Pasarela de Decines - LYON'; } ponts.push(new bridge('/perch/resources/grande-passerelle-1.jpg',legendeRecup)); if (lang_p === 'fr') { legendeRecup ='Pont de Terenez'; } else if (lang_p === 'gb') { legendeRecup ='Terenez bridge'; } else if (lang_p === 'es') { legendeRecup = 'Puente de Terenez'; } ponts.push(new bridge('/perch/resources/pont-haubans-1.jpg',legendeRecup)); if (lang_p === 'fr') { legendeRecup ='Pont des docks'; } else if (lang_p === 'gb') { legendeRecup ='Docks bridge'; } else if (lang_p === 'es') { legendeRecup = 'Puente de los Docks'; } ponts.push(new bridge('/perch/resources/pont-des-docks-paul-vatine-1.jpg',legendeRecup)); if (lang_p === 'fr') { legendeRecup ='Pole d échanges multimodal de Morlaix - Projet lauréat'; } else if (lang_p === 'gb') { legendeRecup ='Morlaix station'; } else if (lang_p === 'es') { legendeRecup = 'Estacion de Morlaix'; } ponts.push(new bridge('/perch/resources/gare-de-morlaix-2.jpg',legendeRecup)); if (lang_p === 'fr') { legendeRecup ='Passerelle du pole multimodal - Angouleme'; } else if (lang_p === 'gb') { legendeRecup ='Angouleme station footbridge'; } else if (lang_p === 'es') { legendeRecup = 'Pasarela de la estacion Angouleme'; } ponts.push(new bridge('/perch/resources/pem-angouleme.jpg',legendeRecup)); if (lang_p === 'fr') { legendeRecup ='Pont Confluences - Angers'; } else if (lang_p === 'gb') { legendeRecup ='Confluences bridges - Angers'; } else if (lang_p === 'es') { legendeRecup = 'Puente de las confluencias - Angers'; } ponts.push(new bridge('/perch/resources/diapo/pont-confluences-1.jpg',legendeRecup)); if (lang_p === 'fr') { legendeRecup ='Pont Vasco de Gama'; } else if (lang_p === 'gb') { legendeRecup ='Vasco de Gama bridge'; } else if (lang_p === 'es') { legendeRecup = 'Puente Vasco de Gama'; } ponts.push(new bridge('/perch/resources/0575-pont-vasco-de-gama-accueil-1.jpg',legendeRecup)); if (lang_p === 'fr') { legendeRecup ='Passerelle du PEM de Saint Brieuc'; } else if (lang_p === 'gb') { legendeRecup ='Saint Brieuc station footbridge'; } else if (lang_p === 'es') { legendeRecup = 'Pasarela de la estacion de Saint Brieuc'; } ponts.push(new bridge('/perch/resources/pem-saint-brieuc-lavigne-cheron.jpg',legendeRecup)); if (lang_p === 'fr') { legendeRecup ='Réhabilitation du PONT EIFFEL - Cubzac les ponts'; } else if (lang_p === 'gb') { legendeRecup ='EIFFEL bridge rehabilitation - Cubzac les ponts'; } else if (lang_p === 'es') { legendeRecup = 'Rehabilitacion del puente EIFFEL - Cubzac les ponts'; } ponts.push(new bridge('/perch/resources/pont-eiffel.jpg',legendeRecup)); imagesS = new Array (); for (tousSesPonts in ponts) { imagesS[tousSesPonts] = new Image(); imagesS[tousSesPonts].src=ponts[tousSesPonts].getImage(); } /*initializing the variables*/ var pontActif; // index of the bridges displayed var nombrePonts = ponts.length; // the total number of bridges to display var lesDivs; var lElement; var lImage; var zeDelay = 4000; // delay before changing the pic (in ms) var fadeTime = 750; // time for fading the bridge (in ms) /*functions to image replacement*/ function setOpacity (opa) { lElement.style.opacity = opa; lElement.style.filter = "alpha(opacity=" + (opa * 100) + ");"; // for our beloved ie } function toBlack() { // fade out for (a = 0;a <= 1;a = a+0.05 ) { setTimeout("setOpacity(" + (1-a) + ")", a * fadeTime);} } function toPic() { // fade in lImage.src = ponts[pontActif].getImage(); laLegende.innerHTML = ponts[pontActif].getLegend(); for (b = 0;b <= 1;b = b+0.05 ) { setTimeout("setOpacity(" + b + ")", b * fadeTime);} }; var looper = function (){ if (nombrePonts > 1){ goNext(); zeLoop = setTimeout(looper,zeDelay); } }; bridgeChange = function () { toBlack(); var imgLdr = new Image (); imgLdr.src= ponts[pontActif].getImage(); imgLdr.onload = function () { setTimeout(toPic,fadeTime); } }; /* back and forth */ function goNext() { if (pontActif === nombrePonts-1) { pontActif = 0; } else { pontActif++; } bridgeChange(); } function goPrev() { if (pontActif === 0) { pontActif = nombrePonts-1; } else { pontActif--; } bridgeChange(); } /* function called when body is loaded to launch the process */ window.onload = function() { lesDivs = document.getElementsByTagName('div'); for (vals in lesDivs) { if (lesDivs[vals].className === 'element') { lElement = lesDivs[vals]; lImage = lElement.getElementsByTagName('img')[0]; laLegende = lElement.getElementsByTagName('p')[0]; for (items in ponts){ if (ponts[items].getImage() === lImage.src) {// récupération de l’index de l’image par défaut ans le tableau ponts pontActif = ponts.indexOf(items); } else { pontActif = 0; } } } } autoplay = setTimeout(looper,zeDelay); }