function switch_home_element(large_image_url) {
	//$('#background_image').hide('slide', {direction:'left'}, 1000, function() {
	$('#background_image').fadeOut(500, function() {
		$('#background_image').attr('src', large_image_url);
		setTimeout(function() {
			//$('#background_image').show('slide', {direction:'left'}, 1000);
			$('#background_image').fadeIn(500);
		}, 500);
	});
}

function home_images_rotation() {
	var home_image_count = 0;
	$.each(background_images, function(i, val) {
			setTimeout(
				function() {
					//$('#debug').html('Index: '+i+' Val: '+val);
					switch_home_element(val);
					home_image_count++;
					if (home_image_count == background_images.length) {
						home_images_rotation();
					}
				}, i*10000
			);
		}
	);
}

$(document).ready(function() {
	setInterval("switch_home_element_b()", 5000);
	logg(background_images);
	/*setTimeout(
		function() {
			home_images_rotation();
		}, 2000
	);*/
});

function switch_home_element_b() {
	if(typeof switch_home_element_b.home_image_count == 'undefined' || background_images.length == switch_home_element_b.home_image_count) {
		switch_home_element_b.home_image_count = 0;
	}	
	$('#background_image').fadeOut(500, function() {
		$('#background_image').attr('src', background_images[switch_home_element_b.home_image_count]);
		setTimeout(function() {
			$('#background_image').fadeIn(500);
			switch_home_element_b.home_image_count++;
		}, 50);
	});
}

function logg(info) {
	if(window.console) {
		console.log(info);
	}
}







