// Source code Copyright © vanAnnies.  All Rights Reserved.
// Contact GetTheGhost.com for Licensing
function vanGhostScrollImage(url,caption,link) { this.url = url; if(caption == undefined) this.caption = ''; else this.caption = caption; this.image = new Image(); this.image.src = this.url; if(link == undefined) this.link = url; else this.link = link; }; vanGhostScrollImage.randomize = function(images) { var L = images.length; for(ndx = L-1; ndx > 0; ndx--) { var rnd = Math.round((Math.random() * ndx)); var save = images[ndx]; images[ndx] = images[rnd]; images[rnd] = save; } return images; }; function vanGhostScroll(images,width,height,container,count,css,direction,speed,target) { this.images = null; this.imgndx = 0; this.imgcount = 0; this.direction = 'left'; this.count = 1; this.target = false; this.width = 100; this.height = 100; this.stepsize = 1; this.stop = false; this.step = vanGhostScroll.step; if(images !== undefined) { this.images = images; this.imgcount = images.length; } if(direction !== undefined) this.direction = direction; if(target !== undefined) this.target = target; if(width !== undefined) this.width = width; if(height !== undefined) this.height = height; if(count !== undefined) this.count = count; this.count++; if(speed !== undefined) this.stepsize = speed; this.twidth = 0; this.theight = 0; if(direction !== undefined) this.direction = direction; this.twidth = this.width * this.count; this.theight = this.height * this.count; this.container = document.getElementById(container); this.container.style.position = 'relative'; this.container.style.overflow = 'hidden'; this.container.innerHTML = ''; this.layers = new Array(); for(ndx = 0; ndx < this.count; ndx++) { var top = 0; var left = 0; switch(this.direction) { case 'left': left = ndx * this.width; break; case 'right': left = this.twidth - ((ndx+2) * this.width); break; case 'up': top = ndx * this.height; break; case 'down': top = this.theight - ((ndx+2) * this.height); break; } var layer = document.createElement('div'); layer.style.textAlign = 'left'; layer.style.position = 'absolute'; layer.style.top = top + 'px'; layer.style.left = left + 'px'; layer.style.width = this.width + 'px'; layer.style.height = this.height + 'px'; layer.style.cursor = 'pointer'; var image = document.createElement('img'); if(css !== undefined) image.className = css; layer.appendChild(image); this.container.appendChild(layer); var O = new Object(); O.layer = layer; O.image = image; O.top = top; O.left = left; O.width = this.width; O.height = this.height; O.target = this.target; layer.onclick = function(obj) { return function(evt) { if(obj.target) window.open(obj.link); else document.location = obj.link; } }(O); this.layers.push(O); } if(this.imgcount); { this.imgndx = 0; for(ndx = 0; ndx < this.count; ndx++) { if(this.imgndx >= this.imgcount) this.imgndx = 0; this.layers[ndx].image.src = this.images[this.imgndx].url; this.layers[ndx].image.title = this.images[this.imgndx].caption; this.layers[ndx].link = this.images[this.imgndx].link; this.imgndx++; } } this.container.onmouseover = function(obj) { return function(evt) { obj.stop = true; } }(this); this.container.onmouseout = function(obj) { return function(evt) { obj.stop = false; } }(this); }; vanGhostScroll.loadImage = function(obj, ndx) { if(obj.imgndx >= obj.imgcount) obj.imgndx = 0; obj.layers[ndx].image.src = obj.images[obj.imgndx].url; obj.layers[ndx].image.title = obj.images[obj.imgndx].caption; obj.layers[ndx].link = obj.images[obj.imgndx].link; obj.imgndx++; }; vanGhostScroll.step = function() { if(this.stop) return true; switch(this.direction) { case 'left': { for(ndx = 0; ndx < this.count; ndx++) { this.layers[ndx].left -= this.stepsize; if(this.layers[ndx].left + this.layers[ndx].width < 0) { vanGhostScroll.loadImage(this, ndx); this.layers[ndx].left = this.layers[ndx].left + this.twidth; } this.layers[ndx].layer.style.left = this.layers[ndx].left + 'px'; } break; } case 'right': { for(ndx = 0; ndx < this.count; ndx++) { this.layers[ndx].left += this.stepsize; if(this.layers[ndx].left > (this.twidth-this.width)) { vanGhostScroll.loadImage(this, ndx); this.layers[ndx].left = this.layers[ndx].left - this.twidth; } this.layers[ndx].layer.style.left = this.layers[ndx].left + 'px'; } break; } case 'up': { for(ndx = 0; ndx < this.count; ndx++) { this.layers[ndx].top -= this.stepsize; if(this.layers[ndx].top + this.layers[ndx].height < 0) { vanGhostScroll.loadImage(this, ndx); this.layers[ndx].top = this.layers[ndx].top + this.theight; } this.layers[ndx].layer.style.top = this.layers[ndx].top + 'px'; } break; } case 'down': { for(ndx = 0; ndx < this.count; ndx++) { this.layers[ndx].top += this.stepsize; if(this.layers[ndx].top > (this.theight-this.height)) { vanGhostScroll.loadImage(this, ndx); this.layers[ndx].top = this.layers[ndx].top - this.theight; } this.layers[ndx].layer.style.top = this.layers[ndx].top + 'px'; } break; } } return true; }; 