function SuperViewer(){this.imgs = null; this.imgIndex = 0;this.fom= new FormObjectsManager();this.nextImage = 0;this.init= init;this.preload = preload;this.preloadAll= preloadAll; this.preloadQueue= preloadQueue; this.show= show;this.toBack= toBack;this.toNext= toNext;this.setImageLink= setImageLink;this.setSuperTitle = setSuperTitle;this.setImageIndex = setImageIndex;this.showController= showController;this.getImageIndex = getImageIndex;this.getImageCount = getImageCount;function init(imgs){this.imgs = imgs;this.showController();this.show();this.preload(+1);this.preload(-1);}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("foto",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("contador",(this.imgIndex + 1) + " de " + this.imgs.length);}}function showController(){if(this.getImageCount() > 1){this.fom.setObjectVisibility("controller",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 setImageLink(newLink){obj = this.fom.getObject("link");obj.href = newLink;}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;}}