var startsignal = 0; var global_pause = 0; var global_direction = 'forward'; var global_interrupt = 0; var global_delay = 0; var global_getimage = -1; var slideshow = Class.create(); slideshow.prototype = { initialize: function(element, data, delay, preflist, pause){ this.element = element; this.data = data; this.delay = delay; this.preflist = preflist; global_pause = pause; this.currentItem = 0; this.lastItem = 0; this.maxItem = 0; this.init = 1; this.timelock = 1; this.slideElements = Array(); for(i = 0; i < data.length; i++){ var currentImg = document.createElement('div'); currentImg.style.position = "absolute"; if (data[i][2]){ var articleLink = document.createElement('a'); articleLink.href = data[i][2]; var showImg = document.createElement('img'); showImg.style.border = "none"; showImg.src = data[i][0]; articleLink.appendChild(showImg); currentImg.appendChild(articleLink); } else{ var showImg = document.createElement('img'); showImg.style.border = "none"; showImg.src = data[i][0]; currentImg.appendChild(showImg); } element.appendChild(currentImg); currentImg.currentOpacity = new fx.Opacity(currentImg, {duration: 2000}); currentImg.setStyle('opacity', 0); this.slideElements[parseInt(i)] = currentImg; } this.maxItem = data.length; this.doSlideShow(); }, startSlideShow: function(){ if (this.init == 1){ this.lastItem = this.maxItem - 1; this.currentItem = 0; this.init = 0; this.slideElements[parseInt(this.currentItem)].setStyle('opacity', 1); setTimeout(this.showInfoSlideShow.bind(this)); } if (startsignal) setTimeout(this.nextSlideShow.bind(this)); else setTimeout(this.startSlideShow.bind(this), 100); }, nextSlideShow: function(){ if ((global_pause == 0) && (this.timelock <= 0)){ if (this.timelock == 0){ setTimeout(this.nextSlideShow.bind(this), 2000); setTimeout(this.hideInfoSlideShow.bind(this)); this.timelock = -1; } else{ this.timelock = 1; this.lastItem = this.currentItem; if (global_interrupt) this.preflist = undefined; global_interrupt = 0; if (this.preflist > 0){ if (global_direction == 'forward') this.currentItem = (this.currentItem < this.preflist) ? this.currentItem + 1 : 0; else this.currentItem = (this.currentItem == 0) ? this.preflist : this.currentItem - 1; } else{ if (global_direction == 'forward') this.currentItem = (this.currentItem < this.maxItem - 1) ? this.currentItem + 1 : 0; else this.currentItem = (this.currentItem == 0) ? this.maxItem - 1 : this.currentItem - 1; } if (global_getimage > -1){ if (global_getimage != this.lastItem){ if ((global_getimage < this.lastItem) && (global_direction == 'forward')) this.reverseImg = 1; else if ((global_getimage > this.lastItem) && (global_direction == 'backwards')) this.reverseImg = 1; this.currentItem = global_getimage; } global_getimage = -1; } setTimeout(this.doSlideShow.bind(this)); } } else{ if (this.timelock){ if (this.timelock == 1){ this.timelock = 2; var active_delay = this.delay; if (global_delay) active_delay = global_delay; global_delay = 0; this.timelockTimer = setTimeout(this.setTimelock.bind(this), (active_delay - 2000)); } if ((global_interrupt) || (global_getimage > -1)){ clearTimeout(this.timelockTimer); this.timelock = 0; } } setTimeout(this.nextSlideShow.bind(this), 100); } }, setTimelock: function(){ this.timelock = 0; }, doSlideShow: function(){ if (this.init == 1) setTimeout(this.startSlideShow.bind(this)); else{ if (global_direction == 'forward'){ if ((this.currentItem != 0) && (!this.reverseImg)){ this.slideElements[parseInt(this.currentItem)].currentOpacity.options.onComplete = function(){ this.slideElements[parseInt(this.lastItem)].setStyle('opacity', 0); if (window.prepare_hotelView) rotatehotel(); }.bind(this); this.slideElements[parseInt(this.currentItem)].currentOpacity.custom(0, 1); } else{ this.reverseImg = 0; this.slideElements[parseInt(this.currentItem)].setStyle('opacity', 1); this.slideElements[parseInt(this.lastItem)].currentOpacity.options.onComplete = function(){ if (window.prepare_hotelView) rotatehotel(); }.bind(this); this.slideElements[parseInt(this.lastItem)].currentOpacity.custom(1, 0); } } else{ if ((this.currentItem != this.maxItem - 1) && (!this.reverseImg)){ this.slideElements[parseInt(this.currentItem)].setStyle('opacity', 1); this.slideElements[parseInt(this.lastItem)].currentOpacity.options.onComplete = function(){ if (window.prepare_hotelView) rotatehotel(); }.bind(this); this.slideElements[parseInt(this.lastItem)].currentOpacity.custom(1, 0); } else{ this.reverseImg = 0; this.slideElements[parseInt(this.currentItem)].currentOpacity.options.onComplete = function(){ this.slideElements[parseInt(this.lastItem)].setStyle('opacity', 0); if (window.prepare_hotelView) rotatehotel(); }.bind(this); this.slideElements[parseInt(this.currentItem)].currentOpacity.custom(0, 1); } } setTimeout(this.showInfoSlideShow.bind(this)); setTimeout(this.nextSlideShow.bind(this)); } }, showInfoSlideShow: function(){ if (this.slideInfo) this.element.removeChild(this.slideInfo); this.slideInfo = document.createElement('div'); this.slideInfo.className = "image_text"; this.slideInfo.style.top = "268px"; this.slideInfo.style.width = "438px"; this.slideInfo.currentOpacity = new fx.Opacity(this.slideInfo, {duration: 2000}); this.slideInfo.setStyle('opacity', 0); if (this.data[this.currentItem][2]){ var imgText = document.createElement('a'); imgText.className = "title_text"; imgText.innerHTML = this.data[this.currentItem][1]; imgText.href = this.data[this.currentItem][2]; } else{ var imgText = document.createElement('div'); imgText.className = "title_text"; imgText.innerHTML = this.data[this.currentItem][1]; } this.slideInfo.appendChild(imgText); this.element.appendChild(this.slideInfo); this.slideInfo.currentOpacity.custom(0, 0.75); }, hideInfoSlideShow: function(){ if (!global_pause) this.slideInfo.currentOpacity.custom(0.75, 0); } } function loadImage(imageid, no_interrupt){ if (document.getElementById('movie')) document.getElementById('movie').style.visibility = 'hidden'; global_delay = 15000; global_pause = 0; if (!no_interrupt) global_interrupt = 1; global_getimage = imageid; } function playback_button(){ if (window.prepare_hotelView) playback_button_map(); global_pause = 0; global_interrupt = 1; global_direction = 'backwards'; } function pause_button(){ global_pause = 1; } function play_button(){ if (window.prepare_hotelView) play_button_map(); global_pause = 0; global_interrupt = 1; global_direction = 'forward'; }