// JavaScript Document

var currentLockupId = '1';
var switchSpeed     = 6000;
var animateSpeed    = 800;
var timeoutId       = 0;

$(function() {
	$('.lockup-selector span').click(function() {
		//
		//alert(this.id);
		var index = this.id.lastIndexOf('-');
		var id    = this.id.substr(index + 1);
		
		switchLockup(id);
	});
	
	timeoutId = setTimeout("showNextLockup()", switchSpeed);
});

function showNextLockup()
{
	var id = parseInt(currentLockupId) + 1;
	if (id > 3) id = 1;
	
	switchLockup(id);
}

function switchLockup(id)
{
	if (currentLockupId == id) return;
	clearTimeout(timeoutId);
	
	fadeLockup(currentLockupId);
	showLockup(id);
	
	$('#selectlockup-' + id).removeClass('off');
	$('#selectlockup-' + currentLockupId).removeClass('on');
	
	$('#selectlockup-' + id).addClass('on');
	$('#selectlockup-' + currentLockupId).addClass('off');
	
	currentLockupId = '' + id;
	timeoutId = setTimeout("showNextLockup()", switchSpeed);
}

function fadeLockup(id)
{
	$('.lockup' + id).fadeOut(animateSpeed);
}

function showLockup(id)
{
	$('.lockup' + id).fadeIn(animateSpeed);
}




