+ display: function(cachel){
+ var newimg = cachel.img.clone().
+ set('class', 'mainformat').
+ setProperty('alt', 'Current Image').
+ setStyles(this.calcsize(cachel)).
+ setStyles({
+ zIndex: 3,
+ opacity: 0
+ });
+ this.ondisplay.replaces(this.prevdisplay).
+ setProperty('alt', 'Previous Image').
+ setStyle('zIndex', 2);
+ this.prevdisplay = this.ondisplay;
+ this.ondisplay = newimg;
+ this.container.grab(this.ondisplay);
+ this.effect();
+ },
+
+ effect: function(){
+ this.fx = new Fx.Tween(this.ondisplay, {
+ duration: this.options.fxduration
+ });
+ this.fx.addEvent('complete',this.displaycomplete.bind(this));
+ this.fx.start('opacity', 0, 1);
+ },
+
+ displaycomplete: function(){
+ this.prevdisplay.setStyle('display', 'none');
+ if (this.isplaying) {
+ this.timer = this.autonext.delay(this.delay,this);
+ }
+ },
+
+ autonext: function(){
+ if (this.isplaying) {
+ if (this.currentid < this.vimgs.length-1) {
+ this.show(this.currentid+1);
+ } else {
+ this.exit();
+ }
+ }
+ },
+
+ calcsize: function(cachel){
+ if (! cachel.url) {
+ return {
+ position: 'absolute',
+ top: 0+'px',
+ left: 0+'px',
+ width: this.coords.width,
+ height: this.coords.height
+ };
+ }
+ var factor = 1;
+ var candidate;
+ candidate = this.target.width /
+ this.vimgs[cachel.id][2][cachel.vi][0];
+ if (factor > candidate) { factor = candidate; }
+ candidate = this.target.height /
+ this.vimgs[cachel.id][2][cachel.vi][1];
+ if (factor > candidate) { factor = candidate; }
+ var w = Math.round(this.vimgs[cachel.id][2][cachel.vi][0] *
+ factor);
+ var h = Math.round(this.vimgs[cachel.id][2][cachel.vi][1] *
+ factor);
+ var t = Math.round((this.coords.height-h)/2);
+ var l = Math.round((this.coords.width-w)/2);
+ /* alert('new size: '+w+'x'+h+'+'+l+'+'+t); */
+ return {
+ position: 'absolute',
+ top: t+'px',
+ left: l+'px',
+ width: w,
+ height: h
+ };
+ },
+
+ showloading: function(){
+ this.loadingdiv.setStyles({
+ display: 'block',
+ width: this.coords.width,
+ height: this.coords.height
+ });
+ },
+
+ hideloading: function(){
+ this.loadingdiv.setStyle('display', 'none');
+ },
+
+ cleartimer: function(){
+ if (this.isplaying) { $clear(this.timer); }
+ },
+
+ stopfx: function(){
+ if (this.fx) this.fx.cancel();
+ },
+
+ updatecoords: function(){
+ this.coords = this.container.getCoordinates();
+ this.target = {
+ width: Math.round(this.coords.width *
+ this.options.percentage / 100),
+ height: Math.round(this.coords.height *
+ this.options.percentage / 100)
+ };
+ /* alert('coords: '+this.coords.width+'x'+this.coords.height+
+ ', target: '+this.target.width+'x'+this.target.height); */
+ }
+