var header_timeout = 5000;
var header_images = 0;
var header_cur_image = 0;
var header_fade = 2000;

jQuery(document).ready(function(){
	header_images = jQuery(".header-images img").length
	
	if(header_images > 1){
		setTimeout('runSlideShow()',header_timeout);
	}
});

function runSlideShow(){
	var next_image;
	
	//get the next image
	if(header_cur_image + 1 >= header_images){
		next_image = 0;
	} else {
		next_image = header_cur_image + 1;
	}
	
	//fadeout current image and fade in next image
	jQuery(".header-images img").eq(header_cur_image).fadeOut(header_fade);
	jQuery('.header-images img').eq(next_image).fadeIn(header_fade,function(){
		//set the header current image
		header_cur_image = next_image;
		
		//set the timeout
		setTimeout('runSlideShow()',header_timeout);
	});
}

