$(document).ready( $(function() {
	var pointer = 0;
	
	$('img.slideShow').each( function(){
		
		var img = new Image();

		$(img).load( function(){
			if( $(this).attr( "src" ) ) document.slideShow.photos.push( $(this) );
		})
		.attr( 'src', $(this).attr( "src" ) );
	});

	$('#slideShow').everyTime( document.slideShow.interval, 'slideshow', function() {

		$(this).fadeOut(document.slideShow.fadeSpeed, function() {
		    if( $(this).children().filter('img').attr('src') == $(document.slideShow.photos[ pointer ]).attr('src')) {
		      pointer++;
            }
			$(this).children().remove().end().append( document.slideShow.photos[ pointer ] ).fadeIn(document.slideShow.fadeSpeed);
		});				

		pointer++;
		if( pointer >= document.slideShow.photos.length ) pointer = 0;
	});
}) );

document.slideShow = {
    fadeSpeed : 'slow',
    interval : 5000,
    photos : new Array()
};
