var int = 0;
var total = 0;

function animate_home_fader(){
	
	if ( int >= total ) { int = 0; 	$('div#home_fader ul li:eq('+(total-1)+')').fadeOut(1500); }
	$('div#home_fader ul li:eq('+int+') p').css({'opacity':'0'});
	$('div#home_fader ul li:eq('+(int-1)+')').fadeOut(1500);
	$('div#home_fader ul li:eq('+int+')').fadeIn(1500, function(){
	
		$('div#home_fader ul li p').css({'margin-top':'70','opacity':'0'}).animate({'margin-top':'50','opacity':'1'}, 1500);
	
	});
}

function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;
        // Alternatively you could use:
        // (new Image()).src = this;
    });
}


preload([
    '/images/home_fader/home_fade_01.jpg',
    '/images/home_fader/home_fade_02.jpg',
    '/images/home_fader/home_fade_03.jpg',
    '/images/home_fader/home_fade_04.jpg',
    '/images/home_fader/home_fade_05.jpg',
    '/images/home_fader/home_fade_06.jpg',
    '/images/home_fader/home_fade_07.jpg'
]);


$(document).ready(function(){

	animate_home_fader();
		
	var home_faders_bol = $('div#home_fader').length;
	
	if(home_faders_bol){
	
		total = $('div#home_fader ul li').length;
		
		setInterval(function(){
		
			int++;
			animate_home_fader();
		
		}, 7000);
		
		
		var textshadow = $("div#home_fader ul li p"); //replace with your own!
		textshadow.append("<em></em> ");
		textshadow.each(function() { var dupeText = $(this).html(); $(this).find("em").html(dupeText); });
	
	} // if home_faders_bol

});
