function SuperViewer(){this.minHeight = 250;this.imgAction = null; this.imgs= null; this.imgIndex= 0;this.fom = new FormObjectsManager();this.nextImage = 0;this.handleEvent = handleEvent;this.init= init;this.preload = preload;this.preloadAll= preloadAll; this.preloadQueue= preloadQueue; this.show= show;this.toBack= toBack;this.toNext= toNext;this.setMinHeight= setMinHeight;this.setImageAction= setImageAction;this.setSuperTitle = setSuperTitle;this.setImageIndex = setImageIndex;this.showController= showController;this.getImageIndex = getImageIndex;this.getImageCount = getImageCount;function init(imgs){this.imgs = imgs;navPrev = new ClickeableTarget("NavegadorPrev");navNext = new ClickeableTarget("NavegadorNext");svImage = new ClickeableTarget("SuperViewerImage"); navPrev.addEventListener("onclick",this,true);navNext.addEventListener("onclick",this,true);svImage.addEventListener("onclick",this,true);this.showController();this.show();this.preload(+2);this.preload(-2);}function preloadQueue(){img = new Image();img.imgs = this.imgs;if(this.nextImage < this.imgs.length){img.nextImage = this.nextImage + 1;}img.onload = this.preloadQueue;alert("Por precargar Nro.: " + this.nextImage);img.src = this.imgs[this.nextImage][2]; }function preloadAll(){for(i=0;i < this.imgs.length; i++){if(!this.imgs[i][0]){this.preload(i);}}}function preload(sOffset){preloadIndex = this.imgIndex;if(sOffset){uOffset = sOffset < 0 ? sOffset * -1 : sOffset;for(i=0; i < uOffset; i++){preloadIndex = sOffset < 0 ? --preloadIndex : ++preloadIndex;if(preloadIndex < 0){preloadIndex = this.imgs.length - 1;}else if(preloadIndex > this.imgs.length - 1){preloadIndex = 0;}if(!this.imgs[preloadIndex][0]){img = new Image();img.src = this.imgs[preloadIndex][2]; this.imgs[preloadIndex][0] = true;}} } }function show(){this.fom.setImageSrc("SuperViewerImage",this.imgs[this.imgIndex][2]);this.imgs[this.imgIndex][0] = true;this.fom.setStringDisplay("titulo",this.imgs[this.imgIndex][3]); this.fom.setStringDisplay("epigrafe",this.imgs[this.imgIndex][4]); if(this.imgs.length > 1){this.showController();this.fom.setStringDisplay("NavegadorText",(this.imgIndex + 1) + " de " + this.imgs.length);}}function showController(){if(this.getImageCount() > 1){this.fom.setObjectVisibility("Navegador",true);}}function toBack(){if(this.imgIndex > 0){this.imgIndex--;}else{this.imgIndex = this.imgs.length - 1;}this.show();this.preload(-2);}function toNext(){if(this.imgIndex < this.imgs.length - 1){this.imgIndex++;}else{this.imgIndex = 0;}this.show();this.preload(+2);}function setMinHeight(minHeight){this.minHeight = minHeight;}function setImageAction(newAction){this.imgAction = newAction;}function setSuperTitle(newTitle) {this.fom.setStringDisplay("supertitle",newTitle); }function setImageIndex(imageIndex){this.imgIndex = imageIndex;}function getImageIndex(){return this.imgIndex;}function getImageCount(){return this.imgs.length;} function handleEvent(evt){if(evt.type){if(evt.target.id == "NavegadorPrev"){this.toBack();}else if(evt.target.id == "NavegadorNext"){this.toNext();}else if(evt.target.id == "SuperViewerImage"){if(this.imgAction != null){eval(this.imgAction);}else{if(this.getImageCount() > 1){this.toNext();}else{window.close();}}}}else{alert("No es un Event: ".evt);}}}
