"use strict";
var Premium = Premium || {};

Premium.creative = {
	init: function() {
		/* START OF CUSTOM JS */

		JPCarousel.UseTouchEvents = true;

		var carouselHorizontalEl = document.getElementById("carousel-horizontal");
		var carouselHorizontalObj = JPCarousel.getObject(carouselHorizontalEl);
		JPCarousel.callOnReady(carouselHorizontalEl, function(el, obj){
			console.log("ready: ", obj.getCurrentItem());
		})
		carouselHorizontalObj.on("showitem", function(index) {
			console.log("showitem index: " + index, "current item:", carouselHorizontalObj.getCurrentItem());
		})
		carouselHorizontalObj.on("prepshowitem", function(index) {
			console.log("prepshowitem: " + index);
			var items = carouselHorizontalObj.getItems();
			for (var i = 0; i < items.length; i++) {
				if ("play" in items[i]) {
					if (i === index) {
						items[i].play();
					} else {
						items[i].pause();
					}

				}
			}
		})
		carouselHorizontalObj.on("swipeitem", function(direction){
			console.log("swipe direction:", direction);
		})
		// carouselHorizontalObj.setAutoDeacSensitivity(10);
		carouselHorizontalObj.setIsSwipeEnabled(true);
		// carouselHorizontalObj.setTweenTime(.2)
		carouselHorizontalObj.setTweenEase(Quad)
		// carouselHorizontalObj.autoShowTimer(3000)
		// carouselHorizontalObj.setAllowClickMidTransition(true)

		var carouselVerticalObj = JPCarousel.getObject("#carousel-vertical");
		carouselVerticalObj.setIsSwipeEnabled(false)
		carouselHorizontalObj.autoShowTimer(3000);

		/* END OF CUSTOM JS */
	}
}