Hi there,

I'm writing a simple image fader using jQuery. I create an array of images on $(document).ready, and then access it on $(window).load. Only the array appears empty. Is this something to do with the array's scope? (Presumably I wouldn't appear at all if this were the case?)

Here's my code:
Code:
$(document).ready(function(){
	$('#main_img').append('<div id="top_img"></div><div id="next_img"></div>');

	var images = [];
	$('#main_img img').each(function(){
		var src = $(this).attr('src');
		images.push(src);
	}).remove();
	$('#top_img').hide().css({backgroundImage:"url(" + images[0] + ")"});

	$(window).load(function(){
		console.log(images); //output: []
		$('#top_img').fadeIn();
		t = setTimeout(function(){cycle(images)}, delay);
	});
		
	console.log(images); //output: ["/images/lazarus_glass_4f97eef5e60ca.jpeg", "/images/lazarus_glass_4f97ef5354142.jpeg"]
}
Any ideas how I can get the filled array within the $(window).load() block?

Cheers,
Mike