$(function(){
	var elementSelectors = ['.promo', '.website-anim'];
	var duration = 300000;
	var imageWidth = 4800;
	var windowWidth = $(window).width();
	var halfWidth = Math.floor((imageWidth/2) - (windowWidth/2));
	var offsets = [
		0,
		Math.floor((windowWidth - 866)/2) + 564 //marginLeft + "distance from page center to elment center"
	];
	function go(elementSelector, offset){

		$(elementSelector).data('scrollEffect', function(){
			$(elementSelector).css({backgroundPosition: '-' + (halfWidth + offset) + 'px 0px'});
			$(elementSelector).stop(true);
			$(elementSelector).animate({backgroundPosition: ''+ (imageWidth + (halfWidth - offset)) +'px 0px'}, duration, 'linear');
		});
		setInterval(function(){$(elementSelector).data('scrollEffect')();}, duration);
		$(elementSelector).data('scrollEffect')();
	}	
	for (var i=0; i<elementSelectors.length; i++){
		go(elementSelectors[i], offsets[i]);
	}	
})

$(document).ready(function(){
			$("#myController").jFlow({
			slides: "#mySlides",
			width: "282px",
			height: "200px",
			duration: 400,
			auto:true
		});
	var timer = setInterval(function(){
 	$(".jFlowNext").trigger('click');
 	}, 18000);
});
