var currentSpotlight = 0;
var spotlightTitleWidth = 604;
var spotlightImageWidth = 720;
var spotlightSlideTime = 5;
var spotlightItemCount;
var spotlightSlides;
var spotlightSlidesRunning = 1;
var spotlight_playpause_MouseOutImg;

function spotlight(item_no) {
	var spotlight_titles = document.getElementById('spotlight_title_container');
	var spotlight_images = document.getElementById('spotlight_img_container');
	
	var titleStart = (currentSpotlight * spotlightTitleWidth * -1);
	var imageStart = (currentSpotlight * spotlightImageWidth * -1);
	
	currentSpotlight = item_no;
	
	var titleEnd = (currentSpotlight * spotlightTitleWidth * -1);
	var imageEnd = (currentSpotlight * spotlightImageWidth * -1);
	
	var slideTime = (Math.abs(titleEnd - titleStart) > spotlightTitleWidth)?2:0.8;

	titleTween = new Tween(spotlight_titles.style, 'left', Tween.regularEaseInOut, titleStart, titleEnd, slideTime, 'px');
	titleTween.start();
	
	imageTween = new Tween(spotlight_images.style, 'left', Tween.backEaseInOut, imageStart, imageEnd, slideTime, 'px');
	imageTween.start();
		//spotlight_titles.style.left = titleEnd + 'px';
		//spotlight_images.style.left = imageEnd + 'px';
	
	// alert(currentSpotlight * spotlightTitleWidth * -1);
}

function nextSpotlight() {
	(currentSpotlight < (spotlightItemCount - 1))?spotlight(currentSpotlight + 1):spotlight(0);
}

function prevSpotlight() {
	(currentSpotlight > 0)?spotlight(currentSpotlight - 1):spotlight(spotlightItemCount - 1);
}

function nextSpotlightClick() {
	stopSpotlightSlideshow();
	nextSpotlight();
}

function prevSpotlightClick() {
	stopSpotlightSlideshow();
	prevSpotlight();
}

function playpauseSpotlight() {
	if (spotlightSlidesRunning) {
		stopSpotlightSlideshow();
	} else {
		nextSpotlight();
		spotlightSlideshow();
	}
}

function stopSpotlightSlideshow() {
	clearTimeout(spotlightSlides);
	spotlightSlidesRunning = 0;
	var spotlight_playpause_img = document.getElementById('spotlight_playpause_img');
	spotlight_playpause_img.src = '/wp-content/themes/cloudyco/images/spotlight_pause.gif';
	spotlight_playpause_MouseOutImg = spotlight_playpause_img.src;
}

function spotlightSlideshow() {
	spotlightSlides = setInterval('nextSpotlight()', spotlightSlideTime * 1000);
	spotlightSlidesRunning = 1;
	var spotlight_playpause_img = document.getElementById('spotlight_playpause_img');
	spotlight_playpause_img.src = '/wp-content/themes/cloudyco/images/spotlight_play.gif';
	spotlight_playpause_MouseOutImg = spotlight_playpause_img.src;
}

