var ModernGallery = function(elementId, transition, interval) { var gallery = { frames : null, selectors : new Array(), prevIndex : 0, slideTimer : 0, slideIndex : 0, slideInterval : 7000, element : $(elementId), timer : 0, container : null, d : new Array(), padding : new Array(), multiplier : 0.5, sliderArrowLeft : null, sliderArrowRight : null, start : function() { this.frames = this.element.getElementsBySelector('div.moderngalleryframe'); this.dimensions = this.element.getDimensions(); this.padding = { left : parseInt(this.element.getStyle("paddingLeft")), bottom : parseInt(this.element.getStyle("paddingBottom")), top : parseInt(this.element.getStyle("paddingTop")), right : parseInt(this.element.getStyle("paddingRight")) } var container = this.container = $(document.createElement("div")); container.setStyle( { width : (this.dimensions.width - this.padding.left - this.padding.right) + 'px', height : (this.dimensions.height - this.padding.top - this.padding.bottom) + 'px', position : 'relative', overflow : 'hidden' }); this.element.insert(container); this.element.addClassName(transition); var _gallery = this; var sc = this.selectorContainer = $(document.createElement('div')); var ul = this.sliderSelector = $(document.createElement("ul")); this.frames.each(function(e, i) { e.setStyle( { position : 'absolute', left : '0px', top : '0px', width : (_gallery.dimensions.width - _gallery.padding.right - _gallery.padding.left) + 'px', height : (_gallery.dimensions.height - _gallery.padding.top - _gallery.padding.bottom) + 'px', }); if(i > 0) { e.hide(); } e.setStyle( { visibility : '' }); container.insert(e); // selector var li = $(document.createElement("li")); li.setAttribute("frameindex", i); li.onclick = function() { _gallery.gotoIndex(this.getAttribute("frameindex")); } _gallery.selectors.push(li); if(e.visible()) li.addClassName("current"); ul.insert(li); }); _gallery.slideIndex = _gallery.prevIndex = 0; // set transition this.setFuncForTransition(this.element); this.defaultSlideNextFunc = this.slideNextFunc; this.defaultSlidePrevFunc = this.slidePrevFunc; // if(interval != "") this.slideInterval = parseInt(interval); this.setGotoFunc(transition); if(this.frames.length > 1) this.slideTimer = setTimeout(function() { _gallery.onNextSlide(); }, this.slideInterval); // create selector container.insert(sc); sc.addClassName("selector_container"); sc.setStyle( { position : 'absolute', left : '0px', //top : (container.getDimensions().height - sc.getDimensions().height) + 'px' top : (container.getDimensions().height) + 'px' }); Event.observe(container, 'mouseover', function() { _gallery.onMouseOver(); }); Event.observe(container, 'mouseout', function() { _gallery.onMouseOut(); }); var sal = this.sliderArrowLeft = $(document.createElement("div")); sal.addClassName("slider_arrow_left"); sal.onclick = function() { gallery.onPrevSlide(); } var sar = this.sliderArrowRight = $(document.createElement("div")); sar.addClassName("slider_arrow_right"); sar.onclick = function() { gallery.onNextSlide(); } sc.insert(sal); sc.insert(sar); // ul selector ul.addClassName("slider_selector"); sc.insert(ul); ul.setStyle( { left : (container.getDimensions().width - ul.getDimensions().width - 30) + 'px', top : '13px', width : (ul.getDimensions().width + 30) + 'px' }); } , onMouseOver : function() { this.selectorContainer.setStyle( { top : (this.container.getDimensions().height - this.selectorContainer.getDimensions().height) + 'px' }); } , onMouseOut : function() { this.selectorContainer.setStyle( { top : (this.container.getDimensions().height) + 'px' }); } , setFuncForTransition : function(transition) { if(transition.hasClassName("slide")) { this.slidePrevFunc = this.slideSlowStartL2RFunc; this.slideNextFunc = this.slideSlowStartR2LFunc; } else if(transition.hasClassName("dissolvesmooth")) { this.slideNextFunc = this.slidePrevFunc = this.fadeSmooth; } else if(transition.hasClassName("fade")) { this.slideNextFunc = this.slidePrevFunc = this.fadeToWhite; } else if(transition.hasClassName("toptobottom")) { this.slideNextFunc = this.slidePrevFunc = this.slideSlowStartT2BFunc; } else if(transition.hasClassName("toptobottomlinear")) { this.slideNextFunc = this.slidePrevFunc = this.slideSlowStartT2BFuncLinear; } else if(transition.hasClassName("curtain")) { this.slideNextFunc = this.slidePrevFunc = this.slideCurtain; } else if(transition.hasClassName("drop")) { this.slideNextFunc = this.slidePrevFunc = this.slideDrop; } else if(transition.hasClassName("dissolverandom")) { this.slideNextFunc = this.slidePrevFunc = this.slideVerticalFadeRandom; } else if(transition.hasClassName("verticalfade")) { this.slideNextFunc = this.slidePrevFunc = this.slideVerticalFade; } else if(transition.hasClassName("dissolve")) { this.slideNextFunc = this.slidePrevFunc = this.slideVerticalFadeMove; } else if(transition.hasClassName("verticaldrape")) { this.slideNextFunc = this.slidePrevFunc = this.slideVerticalDrape; } else if(transition.hasClassName("horizontalstripes")) { this.slideNextFunc = this.slidePrevFunc = this.slideHorizontalstripes; } else if(transition.hasClassName("horizontaldrape")) { this.slideNextFunc = this.slidePrevFunc = this.slideHorizontalDrape; } else { this.slideNextFunc = this.defaultSlideNextFunc; this.slidePrevFunc = this.defaultSlidePrevFunc; } } , setGotoFunc : function(transition) { if(transition == "slide") { this.slideGotoFunc = this.slideSlowStartR2LFunc; } else if(transition == "dissolvesmooth") { this.slideGotoFunc = this.fadeSmooth; } else if(transition == "fade") { this.slideGotoFunc = this.fadeToWhite; } else if(transition == "toptobottom") { this.slideGotoFunc = this.slideSlowStartT2BFunc; } else if(transition == "toptobottomlinear") { this.slideGotoFunc = this.slideSlowStartT2BFuncLinear; } else if(transition == "curtain") { this.slideGotoFunc = this.slideCurtain; } else if(transition == "drop") { this.slideGotoFunc = this.slideDrop; } else if(transition == "dissolverandom") { this.slideGotoFunc = this.slideVerticalFadeRandom; } else if(transition == "verticalfade") { this.slideGotoFunc = this.slideVerticalFade; } else if(transition == "dissolve") { this.slideGotoFunc = this.slideVerticalFadeMove; } else if(transition == "verticaldrape") { this.slideGotoFunc = this.slideVerticalDrape; } else if(transition == "horizontalstripes") { this.slideGotoFunc = this.slideHorizontalstripes; } else if(transition == "horizontaldrape") { this.slideGotoFunc = this.slideHorizontalDrape; } else { this.slideGotoFunc = this.defaultSlideNextFunc; } } , stop : function() { this.isSliding = false; clearInterval(this.timer); } , updateSelectors : function() { for(var i = 0; i < this.selectors.length; i++) this.selectors[i].removeClassName("current"); this.selectors[this.slideIndex].addClassName("current"); } , gotoIndex : function(index) { if(this.isSliding) return; this.isSliding = true; clearTimeout(this.slideTimer); this.prevIndex = this.slideIndex; this.slideIndex = index; this.updateSelectors(); this.slideGotoFunc(this.prevIndex, this.slideIndex); } , onNextSlide : function() { if(this.isSliding) return; this.isSliding = true; clearTimeout(this.slideTimer); this.prevIndex = this.slideIndex; this.slideIndex++; if(this.slideIndex >= this.frames.length) this.slideIndex = 0; this.updateSelectors(); this.setFuncForTransition(this.frames[this.slideIndex]); this.slideNextFunc(this.prevIndex, this.slideIndex); } , onPrevSlide : function() { if(this.isSliding) return; this.isSliding = true; clearTimeout(this.slideTimer); this.prevIndex = this.slideIndex; this.slideIndex--; if(this.slideIndex < 0) this.slideIndex = this.frames.length - 1; this.updateSelectors(); this.setFuncForTransition(this.frames[this.slideIndex]); this.slidePrevFunc(this.prevIndex, this.slideIndex); } , slideNextFunc : function(p, n) { this.frames[p].hide(); this.frames[n].show(); this.stop(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); } , slidePrevFunc : function(p, n) { this.frames[p].hide(); this.frames[n].show(); this.stop(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); } , defaultSlidePrevFunc : function(p, n) { this.frames[n].setStyle({left : '0px', top : '0px'}); this.frames[n].setStyle({opacity : 1.0}); this.frames[p].hide(); this.frames[n].show(); this.stop(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); } , defaultSlideNextFunc : function(p, n) { this.frames[n].setStyle({left : '0px', top : '0px'}); this.frames[n].setStyle({opacity : 1.0}); this.frames[p].hide(); this.frames[n].show(); this.stop(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); } , fadeFunc : function(p, n) { var gallery = this; gallery.frames[p].setStyle({opacity : 1.0}); gallery.frames[n].setStyle({opacity : 0.0}); gallery.frames[p].show(); gallery.frames[n].show(); this.timer = setInterval( function() { var po = parseFloat(gallery.frames[p].getStyle("opacity")) - 0.05; var no = parseFloat(gallery.frames[n].getStyle("opacity")) + 0.05; gallery.frames[p].setStyle({opacity : po}); gallery.frames[n].setStyle({opacity : no}); if(no >= 1.0) { gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } }, 10); } , slideSlowStartR2LFunc : function(p, n) { var gallery = this; gallery.frames[p].setStyle({left : '0px', top : '0px'}); gallery.frames[n].setStyle({left : (gallery.dimensions.width - gallery.padding.left - gallery.padding.right) + 'px', top : '0px'}); gallery.frames[p].show(); gallery.frames[n].show(); gallery.multiplier = 0.02; this.timer = setInterval( function() { var cx = parseInt(gallery.frames[n].getStyle("left")); var px = parseInt(gallery.frames[p].getStyle("left")); var x = Math.max((cx / 2) * gallery.multiplier, 1); var nx = cx - x; var px = nx - gallery.frames[n].getDimensions().width; gallery.frames[p].setStyle({left : px + 'px'}); gallery.frames[n].setStyle({left : nx + 'px'}); if(nx <= 0) { gallery.frames[n].setStyle({left : 0}); gallery.frames[p].hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } gallery.multiplier = Math.min(gallery.multiplier + 0.01, 0.5); }, 15); } , slideSlowStartL2RFunc : function(p, n) { var gallery = this; gallery.frames[p].setStyle({left : '0px', top : '0px'}); gallery.frames[n].setStyle({left : -(gallery.dimensions.width - gallery.padding.left - gallery.padding.right) + 'px', top : '0px'}); gallery.frames[p].show(); gallery.frames[n].show(); gallery.multiplier = 0.02; this.timer = setInterval( function() { var cx = parseInt(gallery.frames[n].getStyle("left")); var px = parseInt(gallery.frames[p].getStyle("left")); var x = Math.min((cx / 2) * gallery.multiplier, -1); var nx = cx - x; var px = nx + gallery.frames[n].getDimensions().width; gallery.frames[p].setStyle({left : px + 'px'}); gallery.frames[n].setStyle({left : nx + 'px'}); if(nx >= 0) { gallery.frames[n].setStyle({left : 0}); gallery.frames[p].hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } gallery.multiplier = Math.min(gallery.multiplier + 0.01, 0.5); }, 15); } , slideSlowStartT2BFunc : function(p, n) { var gallery = this; gallery.frames[p].setStyle({left : '0px'}); gallery.frames[n].setStyle({left : '0px'}); gallery.frames[p].setStyle({top : '0px'}); gallery.frames[n].setStyle({top : -(gallery.frames[n].getDimensions().height) + 'px'}); gallery.frames[p].show(); gallery.frames[n].show(); gallery.multiplier = 0.02; this.timer = setInterval( function() { var cy = parseInt(gallery.frames[n].getStyle("top")); var py = parseInt(gallery.frames[p].getStyle("top")); var y = Math.max((-cy / 2) * gallery.multiplier, 1); var ny = cy + y; var py = ny + gallery.frames[n].getDimensions().height; gallery.frames[p].setStyle({top : py + 'px'}); gallery.frames[n].setStyle({top : ny + 'px'}); if(ny > 0) { gallery.frames[n].setStyle({top : 0}); gallery.frames[p].hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } gallery.multiplier = Math.min(gallery.multiplier + 0.01, 0.5); }, 15); } , slideSlowStartT2BFuncLinear : function(p, n) { var gallery = this; gallery.frames[p].setStyle({left : '0px'}); gallery.frames[n].setStyle({left : '0px'}); gallery.frames[p].setStyle({top : '0px'}); gallery.frames[n].setStyle({top : -(gallery.frames[n].getDimensions().height) + 'px'}); gallery.frames[p].show(); gallery.frames[n].show(); gallery.multiplier = 0.02; this.timer = setInterval( function() { var cy = parseInt(gallery.frames[n].getStyle("top")); var py = parseInt(gallery.frames[p].getStyle("top")); var y = Math.max(10 * gallery.multiplier, 1); var ny = cy + y; var py = ny + gallery.frames[n].getDimensions().height; gallery.frames[p].setStyle({top : py + 'px'}); gallery.frames[n].setStyle({top : ny + 'px'}); if(ny > 0) { gallery.frames[n].setStyle({top : 0}); gallery.frames[p].hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } gallery.multiplier = Math.min(gallery.multiplier + 0.01, 0.5); }, 15); } , fadeSmooth : function(p, n) { var gallery = this; gallery.frames[n].show(); gallery.frames[n].setStyle({left : '0px', top : '0px', opacity : 0}); gallery.frames[p].setStyle({left : '0px', top : '0px', opacity : 1}); this.timer = setInterval( function() { var co = parseFloat(gallery.frames[n].getStyle("opacity")) + 0.03; var cop = parseFloat(gallery.frames[p].getStyle("opacity")) - 0.03; gallery.frames[n].setStyle({opacity : co}); gallery.frames[p].setStyle({opacity : cop}); if(co >= 1.0) { gallery.frames[p].hide(); gallery.frames[n].show(); gallery.frames[n].setStyle({ opacity : 1, left : '0px', top : '0px'}); gallery.frames[p].setStyle({ opacity : 1, left : '0px', top : '0px'}); clearInterval(gallery.timer); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } }, 5); } , fadeToWhite : function(p, n) { var gallery = this; if(!gallery.fadeToWhiteContainer) { var c = gallery.fadeToWhiteContainer = $(document.createElement("div")); c.setStyle( { background : 'white', position : 'absolute', left : '0px', top : '0px', width : (gallery.dimensions.width - gallery.padding.left - gallery.padding.right) + 'px', height : (gallery.dimensions.height - gallery.padding.top - gallery.padding.bottom) + 'px', opacity : 0 }); gallery.container.getElementsBySelector("div.selector_container")[0].insert({before : c}); } gallery.frames[n].setStyle({left : '0px', top : '0px'}); gallery.frames[p].setStyle({left : '0px', top : '0px'}); gallery.fadeToWhiteContainer.show(); gallery.fadeToWhiteContainer.setStyle({ opacity : 0}); this.timer = setInterval( function() { var co = parseFloat(gallery.fadeToWhiteContainer.getStyle("opacity")) + 0.1; gallery.fadeToWhiteContainer.setStyle({opacity : co}); if(co >= 1.0) { gallery.frames[p].hide(); gallery.frames[n].show(); gallery.frames[n].setStyle({ opacity : 1, left : '0px', top : '0px'}); clearInterval(gallery.timer); gallery.timer = setInterval( function() { var co = parseFloat(gallery.fadeToWhiteContainer.getStyle("opacity")) - 0.02; gallery.fadeToWhiteContainer.setStyle({opacity : co}); if(co <= 0) { gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.fadeToWhiteContainer.hide(); gallery.stop(); } }, 10); } }, 5); } , slideDrop : function(p, n) { var gallery = this; if(!gallery.dropFrames) { gallery.dropFrames = new Array(); // containers gallery.nextsdContainer = $(document.createElement("div")); gallery.container.getElementsBySelector("div.selector_container")[0].insert({before : gallery.nextsdContainer}); // gallery.nextsdContainer.setStyle( { background : 'transparent', position : 'absolute', left : '0px', top : '0px', width : gallery.container.getDimensions().width + 'px', height : gallery.container.getDimensions().height + 'px' }); gallery.v = new Array(); gallery.numsdFrames = 10; gallery.frameWidth = gallery.dimensions.width / 10; for(var i = 0; i < gallery.numsdFrames; i++) { var f = $(document.createElement("div")); var l = (i * gallery.frameWidth); var h = gallery.container.getDimensions().height; var w = gallery.container.getDimensions().width; f.setStyle( { position : 'absolute', left : '0px', top : -h + 'px', width : w + 'px', height : h + 'px', clip : 'rect(0, ' + (l + gallery.frameWidth) + 'px, ' + h + 'px, ' + l + 'px)', background : 'transparent' }); gallery.nextsdContainer.insert(f); gallery.dropFrames.push(f); } } for(var i = 0; i < gallery.numsdFrames; i++) { var f = gallery.dropFrames[i]; f.setStyle({top : -gallery.container.getDimensions().height + 'px'}); f.innerHTML = gallery.frames[n].innerHTML; } gallery.frames[n].setStyle({left : '0px', top : '0px'}); gallery.frames[p].setStyle({left : '0px', top : '0px'}); gallery.nextsdContainer.show(); this.timer = setInterval( function() { var h = gallery.container.getDimensions().height; var isDone = false; for(var i = 0; i < gallery.numsdFrames; i++) { var f = gallery.dropFrames[i]; var ct = parseInt(f.getStyle("top")); var t = Math.min(0, ct + (-ct / 2 * 0.4)); f.setStyle({top : t + 'px'}); isDone = false; if(t >= 0 && i == (gallery.numsdFrames - 1)) isDone = true; if(t < -(h * 0.65)) break; } if(isDone) { clearInterval(gallery.timer); gallery.frames[n].show(); gallery.frames[p].hide(); gallery.nextsdContainer.hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } }, 30); } , slideVerticalFade : function(p, n) { var gallery = this; if(!gallery.vfFrames) { gallery.vfFrames = new Array(); // containers gallery.nextvfContainer = $(document.createElement("div")); gallery.container.getElementsBySelector("div.selector_container")[0].insert({before : gallery.nextvfContainer}); // gallery.nextvfContainer.setStyle( { background : 'transparent', position : 'absolute', left : '0px', top : '0px', width : gallery.container.getDimensions().width + 'px', height : gallery.container.getDimensions().height + 'px' }); gallery.vfFrames = new Array(); gallery.numTilesX = 10; gallery.numTilesY = 3; gallery.frameWidth = Math.floor(gallery.dimensions.width / gallery.numTilesX); gallery.frameHeight = gallery.dimensions.height / gallery.numTilesY; gallery.numvfFrames = 0; for(var i = 0; i < gallery.numTilesX; i++) { for(var ii = 0; ii < gallery.numTilesY; ii++) { var f = $(document.createElement("div")); var l = parseInt(i * gallery.frameWidth); var t = parseInt(ii * (gallery.frameHeight)); var b = parseInt(t + gallery.frameHeight); var r = parseInt(l + gallery.frameWidth); f.setStyle( { position : 'absolute', left : '0px', top : '0px', width : gallery.container.getDimensions().width + 'px', height : gallery.container.getDimensions().height + 'px', clip : 'rect(' + t + 'px, ' + r + 'px, ' + b + 'px, ' + l + 'px)' }); gallery.nextvfContainer.insert(f); gallery.vfFrames.push(f); gallery.numvfFrames++; } } } for(var i = 0; i < gallery.numvfFrames; i++) { var f = gallery.vfFrames[i]; f.innerHTML = gallery.frames[p].innerHTML; f.setStyle({opacity : 1, left : '0px', top : '0px'}); } gallery.frames[n].setStyle({left : '0px', top : '0px'}); gallery.frames[p].setStyle({left : '0px', top : '0px'}); gallery.frames[p].hide(); gallery.frames[n].show(); gallery.nextvfContainer.show(); this.timer = setInterval( function() { var isDone = false; for(var i = 0; i < gallery.numvfFrames; i++) { var f = gallery.vfFrames[i]; var o = parseFloat(f.getStyle("opacity")) - 0.05; f.setStyle({opacity : o}); isDone = false; if(o <= 0 && i == (gallery.numvfFrames - 1)) isDone = true; if(o > 0.8) break; } if(isDone) { clearInterval(gallery.timer); gallery.frames[n].show(); gallery.frames[p].hide(); gallery.nextvfContainer.hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } }, 15); } , slideVerticalFadeRandom : function(p, n) { var gallery = this; if(!gallery.vfrFrames) { gallery.vfrFrames = new Array(); // containers gallery.nextvfrContainer = $(document.createElement("div")); gallery.container.getElementsBySelector("div.selector_container")[0].insert({before : gallery.nextvfrContainer}); // gallery.nextvfrContainer.setStyle( { background : 'transparent', position : 'absolute', left : '0px', top : '0px', width : gallery.container.getDimensions().width + 'px', height : gallery.container.getDimensions().height + 'px' }); gallery.vfrFrames = new Array(); gallery.numTilesX = 10; gallery.numTilesY = 3; gallery.frameWidth = Math.floor(gallery.dimensions.width / gallery.numTilesX); gallery.frameHeight = gallery.dimensions.height / gallery.numTilesY; gallery.numvfrFrames = 0; for(var i = 0; i < gallery.numTilesX; i++) { for(var ii = 0; ii < gallery.numTilesY; ii++) { var f = $(document.createElement("div")); var l = parseInt(i * gallery.frameWidth); var t = parseInt(ii * (gallery.frameHeight)); var b = parseInt(t + gallery.frameHeight); var r = parseInt(l + gallery.frameWidth); f.setStyle( { position : 'absolute', left : '0px', top : '0px', width : gallery.container.getDimensions().width + 'px', height : gallery.container.getDimensions().height + 'px', clip : 'rect(' + t + 'px, ' + r + 'px, ' + b + 'px, ' + l + 'px)' }); gallery.nextvfrContainer.insert(f); gallery.vfrFrames.push(f); gallery.numvfrFrames++; } } } for(var i = 0; i < gallery.numvfrFrames; i++) { var f = gallery.vfrFrames[i]; f.innerHTML = gallery.frames[p].innerHTML; f.setStyle({opacity : 1, left : '0px', top : '0px'}); } gallery.frames[n].setStyle({left : '0px', top : '0px'}); gallery.frames[p].setStyle({left : '0px', top : '0px'}); gallery.frames[p].hide(); gallery.frames[n].show(); gallery.nextvfrContainer.show(); gallery.firstPassDone = false; this.timer = setInterval( function() { var isDone = false; for(var i = 0; i < gallery.numvfrFrames; i+=2) { var f = gallery.vfrFrames[i]; var o = parseFloat(f.getStyle("opacity")) - 0.05; f.setStyle({opacity : o}); if(o <= 0.6 && i == 2) gallery.firstPassDone = true; if(o > 0.8) break; } if(gallery.firstPassDone) { for(var i = 1; i < gallery.numvfrFrames; i+=2) { var f = gallery.vfrFrames[i]; var o = parseFloat(f.getStyle("opacity")) - 0.05; f.setStyle({opacity : o}); isDone = false; if(o <= 0 && i == (gallery.numvfrFrames - 1)) isDone = true; if(o > 0.8) break; } } if(isDone) { clearInterval(gallery.timer); gallery.frames[n].show(); gallery.frames[p].hide(); gallery.nextvfrContainer.hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } }, 15); } , slideVerticalDrape : function(p, n) { var gallery = this; var nf = gallery.frames[n]; var pf = gallery.frames[p]; var l = parseInt(gallery.dimensions.width / 2) - 1; var r = l + 1; var t = 0; var b = gallery.dimensions.height; var a = 1; nf.setStyle({left : '0px', top : '0px'}); pf.setStyle({left : '0px', top : '0px'}); nf.show(); nf.setStyle( {clip : 'rect(' + t + 'px, ' + r + 'px, ' + b + 'px, ' + l + 'px)'}); pf.insert({after : nf}); gallery.timer = setInterval(function() { nf.setStyle({clip : 'rect(' + t + 'px, ' + r + 'px, ' + b + 'px, ' + l + 'px)'}); if(l <= 0) { clearInterval(gallery.timer); gallery.frames[n].show(); gallery.frames[p].hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } l -= a; r += a; a++; }, 10); } , slideHorizontalstripes : function(p, n) { var gallery = this; var nf = gallery.frames[n]; var pf = gallery.frames[p]; if(!gallery.hsFrames) { gallery.hsFrames = new Array(); // containers gallery.nexthsContainer = $(document.createElement("div")); gallery.container.getElementsBySelector("div.selector_container")[0].insert({before : gallery.nexthsContainer}); // gallery.nexthsContainer.setStyle( { background : 'transparent', position : 'absolute', left : '0px', top : '0px', width : gallery.container.getDimensions().width + 'px', height : gallery.container.getDimensions().height + 'px' }); gallery.hsFrames = new Array(); gallery.numStripes = 3; gallery.frameWidth = parseInt(gallery.dimensions.width); gallery.frameHeight = parseInt(gallery.dimensions.height / gallery.numStripes); gallery.numvhsFrames = 0; for(var i = 0; i < gallery.numStripes; i++) { var f = $(document.createElement("div")); var l = parseInt(0); var t = parseInt(i * gallery.frameHeight); var b = parseInt(t + gallery.frameHeight); var r = parseInt(gallery.frameWidth); f.setStyle( { position : 'absolute', left : '0px', top : '0px', width : gallery.container.getDimensions().width + 'px', height : gallery.container.getDimensions().height + 'px', clip : 'rect(' + t + 'px, ' + r + 'px, ' + b + 'px, ' + l + 'px)' }); gallery.nexthsContainer.insert(f); gallery.hsFrames.push(f); gallery.numvhsFrames++; } } for(var i = 0; i < gallery.numvhsFrames; i++) { var f = gallery.hsFrames[i]; f.innerHTML = gallery.frames[n].innerHTML; var l = ((i % 2) ? 1 : -1) * gallery.container.getDimensions().width; f.setStyle({opacity : 1, left : l + 'px', top : '0px', opacity : 0}); } gallery.nexthsContainer.show(); var amplifier = 0.15; gallery.timer = setInterval(function() { for(var i = 0; i < gallery.numvhsFrames; i++) { var f = gallery.hsFrames[i]; var o = parseFloat(f.getStyle("opacity")) + 0.1; var l = parseInt(f.getStyle("left")) - (parseInt(f.getStyle("left")) / 2 * amplifier); f.setStyle({left : l + 'px', opacity : o}); if(l >= 0 && i == 0) { gallery.frames[n].show(); gallery.frames[p].hide(); gallery.nexthsContainer.hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } } amplifier += 0.01; }, 30); } , slideHorizontalDrape : function(p, n) { var gallery = this; var nf = gallery.frames[n]; var pf = gallery.frames[p]; var t = parseInt(gallery.dimensions.height / 2) - 1; var b = t + 1; var l = 0; var r = gallery.dimensions.width; var a = 1; nf.setStyle({left : '0px', top : '0px'}); pf.setStyle({left : '0px', top : '0px'}); nf.show(); nf.setStyle( {clip : 'rect(' + t + 'px, ' + r + 'px, ' + b + 'px, ' + l + 'px)'}); pf.insert({after : nf}); gallery.timer = setInterval(function() { nf.setStyle({clip : 'rect(' + t + 'px, ' + r + 'px, ' + b + 'px, ' + l + 'px)'}); if(t <= 0) { clearInterval(gallery.timer); gallery.frames[n].show(); gallery.frames[p].hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } t -= a; b += a; a++; }, 10); } , slideVerticalFadeMove : function(p, n) { var gallery = this; if(!gallery.vfmFrames) { gallery.vfmFrames = new Array(); // containers gallery.nextvfmContainer = $(document.createElement("div")); gallery.container.getElementsBySelector("div.selector_container")[0].insert({before : gallery.nextvfmContainer}); // gallery.nextvfmContainer.setStyle( { background : 'transparent', position : 'absolute', left : '0px', top : '0px', width : gallery.container.getDimensions().width + 'px', height : gallery.container.getDimensions().height + 'px' }); gallery.vfmFrames = new Array(); gallery.numTilesX = 10; gallery.numTilesY = 3; gallery.frameWidth = Math.floor(gallery.dimensions.width / gallery.numTilesX); gallery.frameHeight = gallery.dimensions.height / gallery.numTilesY; gallery.numvfmFrames = 0; for(var i = 0; i < gallery.numTilesY; i++) { for(var ii = 0; ii < gallery.numTilesX; ii++) { var f = $(document.createElement("div")); var l = parseInt(ii * gallery.frameWidth); var t = parseInt(i * (gallery.frameHeight)); var b = parseInt(t + gallery.frameHeight); var r = parseInt(l + gallery.frameWidth); f.setStyle( { position : 'absolute', left : '0px', top : '0px', width : gallery.container.getDimensions().width + 'px', height : gallery.container.getDimensions().height + 'px', clip : 'rect(' + t + 'px, ' + r + 'px, ' + b + 'px, ' + l + 'px)' }); f.setAttribute("ptop", t); f.setAttribute("pleft", l); gallery.nextvfmContainer.insert(f); gallery.vfmFrames.push(f); gallery.numvfmFrames++; } } } for(var i = 0; i < gallery.numvfmFrames; i++) { var f = gallery.vfmFrames[i]; f.innerHTML = gallery.frames[p].innerHTML; f.setStyle({opacity : 1, left : '0px', top : '0px'}); } gallery.frames[n].show(); gallery.frames[p].hide(); gallery.frames[n].setStyle({left : '0px', top : '0px'}); gallery.frames[p].setStyle({left : '0px', top : '0px'}); gallery.nextvfmContainer.show(); var theFrames = new Array(); for(var x = 0; x < gallery.numTilesX; x++) { theFrames.push(x); } for(var y = 1; y < gallery.numTilesY; y++) { theFrames.push(y * gallery.numTilesX + gallery.numTilesX - 1); } gallery.timer = setInterval(function() { for(var i = 0; i < theFrames.length; i++) { for(var ii = 0; ii < gallery.numTilesY && ii <= i; ii++) { var frameIndex = theFrames[i] + (ii * (gallery.numTilesX - 1)); if(frameIndex > gallery.vfmFrames.length) continue; var f = gallery.vfmFrames[frameIndex]; var y = f.getAttribute("ptop"); var x = f.getAttribute("pleft"); var t = parseInt(f.getStyle("top")) - (y / gallery.dimensions.height * 5) - 2; var l = parseInt(f.getStyle("left")) - (x / gallery.dimensions.width * 20) - 3; var o = parseFloat(f.getStyle("opacity")) - 0.05; f.setStyle({top : t + 'px', left : l + 'px', opacity : o}); if(o > 0.90) return; if(frameIndex == gallery.vfmFrames.length - 1 && o <= 0) { clearInterval(gallery.timer); gallery.frames[n].show(); gallery.frames[p].hide(); gallery.nextvfmContainer.hide(); gallery.slideTimer = setTimeout(function() { gallery.onNextSlide(); }, gallery.slideInterval); gallery.stop(); } } } }, 20); } }; gallery.start(); }