function SuperViewer2(targetNode){this.targetNode= targetNode; this.nextImage = 0;this.obj = null; this.updateTime= 0;this.styleClass= null; this.minHeight = 250;this.imgs= null; this.imgIndex= 0;this.imgAction = null; this.fom = new FormObjectsManager();this.actNavigator= null;this.actImage= null;this.actImageContainer = null;this.actTitle= null;this.actContainer= null;this.handleEvent = handleEvent;this.init= init; this.update= update;this.deploy= deploy;this.preload = preload;this.preloadAll= preloadAll; this.preloadQueue= preloadQueue; this.show= show;this.toBack= toBack;this.toNext= toNext;this.showController= showController;this.setStyleClass = setStyleClass;this.setUpdateTime = setUpdateTime;this.setMinHeight= setMinHeight;this.setImages = setImages;this.setImageIndex = setImageIndex;this.setImageAction= setImageAction;this.setTitle= setTitle;this.setEpigrafeTitle= setEpigrafeTitle;this.setEpigrafeText = setEpigrafeText;this.getObject = getObject;this.getImageIndex = getImageIndex;this.getImageCount = getImageCount;function init(){this.actNavigator = new ActiveNavigator();this.actNavigator.addEventListener("onclick",this,true);this.actImage = new ActiveObject("img");this.actImage.setId("SuperViewerImage");this.actImage.addEventListener("onclick",this,true);this.actImageContainer = new ActiveObject("div");this.actImageContainer.setClass("SuperViewer2ImageContainer");this.actImageContainer.appendChild(this.actNavigator); this.actImageContainer.appendChild(this.actImage); this.actTitle = new ActiveObject("div");this.actTitle.setClass("SuperViewer2TituloContainer");this.actContainer = new ActiveObject("div");this.actContainer.setClass("SuperViewer2Container");this.actContainer.appendChild(this.actTitle);this.actContainer.appendChild(this.actImageContainer); this.obj = this.actContainer; this.update();}this.init();function deploy(){tagStyleClass = this.targetNode.getAttribute("class");tagTitle= this.targetNode.getAttribute("title");tagUpdateTime = parseInt(this.targetNode.getAttribute("update"));tagImageIndex = parseInt(this.targetNode.getAttribute("index"));this.setStyleClass(tagStyleClass);this.targetNode.parentNode.replaceChild(this.getObject(),this.targetNode);this.show();this.showController();this.preload(+2);this.preload(-2);}function update(){ajax = new Ajax();ajax.addEventListener('onreadystatechange',this,true);tagSrc = this.targetNode.getAttribute("src");tagProc = this.targetNode.getAttribute("proc");ajax.open('POST','/api/get/sv.do?src='+tagSrc+'&proc='+tagProc,false,null,null);ajax.send('');}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(){img = this.imgs[this.imgIndex];imgUrl = "/"+img.source+"/"+img.type+"/"+img.imgCat+"/"+img.procId+"/"+img.fileName;this.actImage.setSrc(imgUrl);this.imgs[this.imgIndex].preloaded = true; if(this.imgs.length > 1){this.showController();this.actNavigator.setTexto((this.imgIndex + 1) + " de " + this.imgs.length);}}function showController(){if(this.getImageCount() > 1){this.actNavigator.show();}}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 setImages(imgs){this.imgs = imgs;}function setImageAction(newAction){this.imgAction = newAction;}function setImageIndex(imageIndex){this.imgIndex = imageIndex;}function setTitle(newTitle){this.actTitle.setText(newTitle); }function setUpdateTime(newTime){this.updateTime = newTime;}function setStyleClass(newStyleClass){this.styleClass = newStyleClass;}function setEpigrafeTitle(newTitle){this.actEpigrafe.setTitulo(newTitle); }function setEpigrafeText(newText){this.actEpigrafe.setTexto(newText); }function getObject(){return this.obj.getObject();}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{ajax = evt;if(ajax.getReadyState() == 4){jsonResult = ajax.getResponseText();result = eval('('+jsonResult+')');this.setTitle(result.svTitle);this.setUpdateTime(result.svUpdate);this.setImageIndex(result.svStart);this.setImages(result.svImages);}else{}}}}function ActiveNavigator(){var thisInstance = this; this.listeners = new Array();this.obj = null;this.actPrev = null;this.actText = null;this.actNext = null;this.getObject = getObject;this.init= init;this.handleEvent = handleEvent;this.setTexto= setTexto;this.show= show;function init(){this.obj = new ActiveObject("ul");this.obj.setId("Navegador");this.obj.setClass("Navegador SuperViewerBotones");this.obj.setDisplay("none"); actLi = new ActiveObject(); this.actPrev = new ActiveObject("a");this.actPrev.setId("NavegadorPrev");this.actPrev.setClass("NavegadorPrev");this.actPrev.addEventListener("onclick",this,true);this.actText = new ActiveObject("a");this.actText.setId("NavegadorText");this.actText.setClass("NavegadorText");this.actNext = new ActiveObject("a");this.actNext.setId("NavegadorNext");this.actNext.setClass("NavegadorNext");this.actNext.addEventListener("onclick",this,true);actLi.appendChild(this.actPrev);actLi.appendChild(this.actText);actLi.appendChild(this.actNext);this.obj.appendChild(actLi);} this.init();function setTexto(texto){this.actText.setText(texto);}function show(){this.obj.setDisplay("block");}function getObject(){return this.obj.getObject();}function handleEvent(evt){this.dispatchEvent(evt);}} ActiveNavigator.inherits(DOMEventTarget);
