// JavaScript Document

function showNthImage(e, n) {
	var $obj = $(e+':nth-child('+n+')');
	
	$(e+'.active').removeClass('active').fadeOut('250');
	$obj.addClass('active').fadeIn('250');
}

function playGallery(g, a, count) {
	var n = parseInt($(a+'.active').find('cufon').attr('alt'));
	n = ((n+1)%count==0)?count:(n+1)%count;
	showNthImage(g, n);
	$(a+'.active').removeClass('active');
	$(a+':nth-child('+n+')').addClass('active');
	
	setTimeout(function() { playGallery(g, a, count); }, 10000);
}
