/*
$(document).ready(function ()
{
	preloadImages();
	alert();
	$('#cycle_hp').cycle({ 
	    fx:     'fade', 
	    timeout: 3000, 
	    after:   onAfter, 
	    next: '#backward',
	    prev: '#forward'
	});
});

function onAfter() {
    $('#output').html(this.alt);
}

function preloadImages(){
	$("#cycle_hp img").each(function ()
	{
		var image = new Image();	
		image.src = this.src;
	});
		
}
*/

$(document).ready(function ()
{
 
	var nb_counted=0;
	$("#cycle_hp img").each(function ()
	{		
		nb_counted++;
		var image = new Image();	
		image.src = this.src;
		checkCycle();
	});
	
 	$('#cycle_hp').cycle({ 
	    fx:     'fade', 
	    timeout: 3000,
	    after:   onAfter, 
	    next: '#backward',
	    prev: '#forward'
	});

    // add images to slideshow 
        
 	function checkCycle() {
 		
 		var nb_pix = $("#cycle_hp img").size();
 		
 	    if(nb_counted==nb_pix){    	
 	    	$('#cycle_hp').cycle({ 
 	    	    fx:     'fade', 
 	    	    timeout: 3000, 
 	    	    after:   onAfter, 
 	    	    next: '#backward',
 	    	    prev: '#forward'
 	    	});    	
 	    }
 	}
}); 



function onAfter() {
    $('#output').html(this.alt);
}