
// InfoConcept 2010



$(document).ready(function() {

document.photos = null;

   $.ajax({
        type: "GET",
        url: "slide_photos.xml",
        dataType: "xml",
        success: function(xml) {
		
			document.photos = $(xml).find('photo');
			document.photos_position = 0;
			
			setInterval(SlideChange, 4000);

        }
    });

});

function SlideChange() {
	document.photos_position = document.photos_position + 1;
	if(document.photos_position >= document.photos.length)
		document.photos_position = 0;

	var current = $(document.photos.get(document.photos_position));
	
	//fadeout
	$("#photo_top").fadeOut(500, function() {
		//nouveau alternate text
		$("#photo_top").attr("alt", current.find('alt').text() );
		//nouvelle image
		$("#photo_top").attr("src", current.find('source').text()).load(function() {
			//fadein
			$("#photo_top").fadeIn(500, function() {
				$("#photo_bottom").attr("src", $("#photo_top").attr("src"));
				$("#photo_bottom").attr("alt", $("#photo_top").attr("alt"));	
			});
		});
	});
}


