var PIX_PER_PAGE=10; var LOADING_ANIMATION_TIME=5 ;var TIME_PER_IMAGE=3 ;var RELOAD_LIMIT=15 ; function MAImage(src, width, height, label, originalFileName, originalWidth, originalHeight){ this.src=src; this.width=width; this.height=height; this.label=label; this.loader=null; this.originalFileName=originalFileName; this.originalWidth=originalWidth; this.originalHeight=originalHeight; this.timer=null; this.load=load; this.isLoaded=isLoaded; this.free=free; } function load(){ if((this.loader==null) || (this.loader.src==this.src)){ this.loader=new Image(); this.loader.src=this.src; } } function isLoaded(){ return (this.loader!=null) && this.loader.complete; } function free(){ clearTimeout(this.timer); this.timer=null; } var loadingPix=new MAImage('./skins/default/images/loading.gif',0,0,'','','',''); loadingPix.load(); function displayImage(imgHTMLObjectId, imgIndex, time){ if(!document.getElementById(imgHTMLObjectId)) return; if(!pixList[imgIndex]){ document.getElementById(imgHTMLObjectId).style.width=0; document.getElementById(imgHTMLObjectId).style.height=0; document.getElementById(imgHTMLObjectId).style.visibility='hidden'; document.getElementById(imgHTMLObjectId).src=null; document.getElementById(imgHTMLObjectId).imgIndex=null; return; } if(document.getElementById(imgHTMLObjectId).imgIndex==imgIndex) return; clearTimeout(pixList[imgIndex].timer); pixList[imgIndex].load(); document.getElementById(imgHTMLObjectId).style.width=pixList[imgIndex].width; document.getElementById(imgHTMLObjectId).style.height=pixList[imgIndex].height; document.getElementById(imgHTMLObjectId).style.visibility='visible'; if(pixList[imgIndex].isLoaded() || (time>LOADING_ANIMATION_TIME)){ document.getElementById(imgHTMLObjectId).src=pixList[imgIndex].src; document.getElementById(imgHTMLObjectId).imgIndex=imgIndex; } else { if(document.getElementById(imgHTMLObjectId).imgIndex!='loading'+imgIndex){ document.getElementById(imgHTMLObjectId).src=loadingPix.src; document.getElementById(imgHTMLObjectId).imgIndex='loading'+imgIndex; } pixList[imgIndex].timer=setTimeout("if(document.getElementById('"+imgHTMLObjectId+"').imgIndex=='loading"+imgIndex+"') displayImage('"+imgHTMLObjectId+"',"+imgIndex+","+(time+0.5)+")",500); } } function showPage(){ for(i=0;i=RELOAD_LIMIT) window.location=currentPage+'&picture='+index+(diaporamaMode?'&diaporama=true':'')+'&scroll='+document.body.scrollTop; if(diaporamaMode && (2*index==pixList.length-2)){ setDiaporamaMode(false); } currentPixIndex=index; displayImage('currentPix',2*currentPixIndex,0); displayImage('previousPix',2*(currentPixIndex-1)+1,0); displayImage('nextPix',2*(currentPixIndex+1)+1,0); if(currentPixIndex>0){ if(!pixList[2*(currentPixIndex-1)].isLoaded()) totalPixLoaded++; pixList[2*(currentPixIndex-1)].load(); } if(2*currentPixIndex0){ if(2*currentPixIndex0){ pixList[2*(currentPixIndex-1)].free(); pixList[2*(currentPixIndex-1)+1].free(); } setCurrentPix(currentPixIndex+1); } } function setDiaporamaMode(value){ diaporamaMode=value; document.getElementById('diaporamaButton').src='./skins/default/images/'+(diaporamaMode?'pause':'lecture')+'.gif'; setCurrentPix(currentPixIndex); }