		
		var touchX = null;	
		var touchY = null;
		var touchIsSwipe = null;
		var touchSwipeDirection = null;

		var o = document.getElementById("carousel");

		o.addEventListener('touchstart', function(event) { 
			event.preventDefault();
			if(event.targetTouches.length == 1) {
				touchIsSwipe = true;
				touchX = event.targetTouches[0].pageX;
				touchY = event.targetTouches[0].pageY;
			} else if(event.targetTouches.length > 1) {
				touchIsSwipe = false;
			}
		}, false);

		o.addEventListener('touchmove', function(event) { 
			event.preventDefault();
			if(touchIsSwipe && event.targetTouches.length == 1) {
				event.preventDefault();
				var dx = event.targetTouches[0].pageX - touchX;
				var dy = event.targetTouches[0].pageY - touchY;

				// make sure we're moving along the x-axis
				if( Math.abs(dx) > 1.5*Math.abs(dy) ) {

					var dir = (dx > 0) ? 'right' : 'left';

					// verify same direction
					if( touchSwipeDirection == null || touchSwipeDirection == dir ) {
						touchX = event.targetTouches[0].pageX;
						touchY = event.targetTouches[0].pageY;
						touchSwipeDirection = dir;
					} else {
						touchIsSwipe = false;
					}
	
				} else {
					touchIsSwipe = false;
				}

			} else if(event.targetTouches.length > 1) {
				touchIsSwipe = false;
			}
		}, false);


		o.addEventListener('touchend', function(event) { 
			if(touchIsSwipe) {
				if(touchSwipeDirection == 'left') {
					// swipe left executed
					slideCarousel(1); // defined elsewhere, the slideCarousel executes the carousel slide
				} else if(touchSwipeDirection == 'right') {
					// swipe right executed
					slideCarousel(-1);
				}
			}

			touchX = null;
			touchY = null;
			touchIsSwipe = null;
			touchSwipeDirection = null;
		}, false);

