var $lis,$p,$n,timer;

function change() {
	$p = $lis.filter(':visible');
	var x = $lis.index($p);
	var i = (x < $lis.length-1) ? x+1 : 0;
	$n = $lis.eq(i);

	$p.css('z-index',94);
	$n.css('z-index',95);

	$p.find('p').hide();
	$n.find('p').hide();
	$n.find('img').css({opacity:0});
	$n.show();
	$n.find('img').animate({opacity:1},'slow',function() {
		$n.find('p').show();
		$p.hide();
	});
}

$(document).ready(function() {	
	$lis = $('div#banner li').css('position','absolute');
	if ($lis.length > 1) {
		timer = setInterval('change()',10000);
	}

	$('div#countdown').countdown({
		until:new Date(Date.UTC(2012, 6, 27, 20, 30, 0)),
		compact:true,
		layout:'<p class="days">{dn} days</p><p>until the 2012 Games</p>'
	});

	$('ul#a2z a').bind('click',function() {
		var a = this;
		document.body.style.cursor = 'wait';
		var $table = $('table#testList').fadeOut('fast');
		$.get(a + '&time=' + new Date().getTime(),
			function(html) {
				var table = $(html).find('table#testList').html();
				$table.html(table).fadeIn('fast');
				document.body.style.cursor = 'default';
			}
		);
		return false;
	});
});
