var current_img = 0;
var last_index = 0;
var delay = 5;
var speed = 1200;

$(document).ready(function(){
	$('#header').css('backgroundImage', 'none');
	last_index = $('#header img').length - 1;
	$('#header img:gt(0)').hide();
	window.setTimeout("tweenit()", delay * 1000);
});

function tweenit()
{
	$('#header img:eq('+current_img+')').fadeOut(speed);
	$('#header img:eq('+nextIndex()+')').fadeIn(speed, function(){
		current_img = nextIndex();
		window.setTimeout("tweenit()", delay * 1000);
	});
}

function nextIndex()
{
	return current_img + 1 > last_index ? 0 : current_img + 1;
}
