/**
 * @author jon
 * Enhancements, and additional transitions by Steve Bondy, www.highpointperformances.com
 * The names of the transitions indicate what happens to the old slide, and the new slide.
 * For example, fadeslideleft indicates that the old slide fades, and the new slide slides 
 * in to the left.
 * Slidedownfade would indicate that the old slide slides down, and the new one fades in, but 
 * I haven't implemented that one yet.
 */
gallery.Transitions.extend({
	fade_slideleft: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.Cubic.easeOut;
		oldFx.options.duration = newFx.options.duration = 1500;
		newFx.start({
			opacity: [0,1],
			left: [this.galleryElement.offsetWidth, 0]
		});
		oldFx.start({opacity: [1,0]});
	},
	fadeslideright: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.Cubic.easeOut;
		oldFx.options.duration = newFx.options.duration = 1500;
		newFx.start({
			opacity: [0,1],
			left: [this.galleryElement.offsetWidth * -1, 0]
		});
		oldFx.start({opacity: [1,0]});
	},
	fadeslideup: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
		oldFx.start({
			opacity: [1,0]
		});
		newFx.start({
			opacity: [0,1],
			top: [this.galleryElement.offsetHeight, 0]
		});
	},
	fadeslidedown: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
		oldFx.start({
			opacity: [1,0]
		});
		newFx.start({
			opacity: [0,1],
			top: [this.galleryElement.offsetHeight * -1, 0]
		});
	},
	continuousfadeslideleft: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.Cubic.easeOut;
		oldFx.options.duration = newFx.options.duration = 1500;
		if (newPos > oldPos) /* Not at last slide yet */
		{
			newFx.start({
				left: [this.galleryElement.offsetWidth, 0],
				opacity: 1
			});
			oldFx.start({opacity: [1,0]});
		} else { /* On last slide - slide out to the right instead of left */
			newFx.start({opacity: [0,1]});
			oldFx.start({
				left: [0, this.galleryElement.offsetWidth],
				opacity: 0
			}).chain(function(fx){fx.set({left: 0});}.pass(oldFx));
		}
	},
	continuoushorizontal: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
		if ( newPos > oldPos ){
			oldFx.set({opacity: 1});
			oldFx.start({
				left: [0, this.galleryElement.offsetWidth * -1]
			});
			newFx.set({opacity: 1, left: this.galleryElement.offsetWidth});
			newFx.start({
				left: [this.galleryElement.offsetWidth, 0]
			});
		} else  { /* Wrapping around from end back to beginning */
			oldFx.set({opacity: 1});
			oldFx.start({
				left: [0, this.galleryElement.offsetWidth]
			});
			newFx.set({opacity: 1, left: this.galleryElement.offsetWidth * -1});
			newFx.start({
				left: [this.galleryElement.offsetWidth * -1, 0]
			});
		}
	},
	continuousvertical: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
		if ( newPos > oldPos){
			oldFx.start({
				opacity: [1,0],
				top: [0, this.galleryElement.offsetHeight * -1]
			});
			newFx.start({
				opacity: [0,1],
				top: [this.galleryElement.offsetHeight, 0]
			});
		} else  { /* Wrapping around from end back to beginning */
			oldFx.start({
				opacity: [1,0],
				top: [0, this.galleryElement.offsetHeight]
			});
			newFx.start({
				opacity: [0,1],
				top: [this.galleryElement.offsetHeight * -1, 0]
			});
		}
	}
});
