$(document).ready(function() {
	$('.image_slide img').fadeOut('slow');
	
	var slides = $('#image_slider').find('.image_slide').length;
	var html_to_add = '';
	for(var i=0; i<slides; i++){
		html_to_add = html_to_add+' <div class="image_index"></div>';
	}
	
	$('.fading_boxes').html(html_to_add);
	
	
	
	runIt(0);
	
	
	
	
});



function runIt(index) {
	var timeout = 8000;
	/*
	$('.qsearch').html(index+" "+$('#image_slider').find('.image_slide').length);
	
	$('.image_slide img').eq(index).fadeIn(timeout/3).delay(timeout/3).fadeTo(0, timeout/3, function(){
		//$('.image_slide img').not($(this)).fadeOut('slow');
	});
	
	index++;
	if(index == $('#image_slider').find('.image_slide').length){
		
		index =	0;
		$('.image_slide img').not($('.image_slide img').eq(index)).fadeOut('slow');
	}
	
	setTimeout("runIt("+index+")",timeout);
	
	*/
	
	
	//$(this).animate({ backgroundColor: "black" }, 1000);

	
	
	var priv = index-1;
	var zindex = $('#image_slider').find('.image_slide').length;
	zindex = zindex - index;
	//$('.qsearch').html(index+" "+priv+" "+$('#image_slider').find('.image_slide').length);
	$('.image_slide').eq(index).css('z-index', zindex);
	$('.image_slide img').not($('.image_slide img').eq(index)).fadeOut(500);
	$('.image_slide img').eq(index).fadeIn(500);
	
	$('.image_index').not($('.image_index').eq(index)).animate({ backgroundColor: "#a1c4cc" }, 500);
	$('.image_index').eq(index).animate({ backgroundColor: "#ba369c" }, 500);
	//alert($('.image_index').eq(index));
	index++;
	if(index == $('#image_slider').find('.image_slide').length){
		index =	0;
	}
	
	setTimeout("runIt("+index+")",timeout);
	
   }
