$(function(){
	setIntroductionImage();
});

var _loopImageNumber = 2;
var _maxImageNumber = 4;
function startLoopImage(){
	var imageSrc = "'content/images/home/index/loop_image_0" + _loopImageNumber + ".jpg'";
	$("#header_loop_image img").before("<img src=" + imageSrc + " alt='' />");
	$("#header_loop_image img:last").fadeOut(1500, function(){
		$(this).remove();
	});
	_loopImageNumber++;
	if(_loopImageNumber > _maxImageNumber){
		_loopImageNumber = 1;
	}
}

function setIntroductionImage(){
	$("#header_loop_image img").before("<img src='content/images/home/index/introduction_image_01.jpg' alt='' />");
	$("#header_loop_image img:last").fadeOut(1000, function(){
		$(this).remove();
    	$("#header_loop_image img").before("<img src='content/images/home/index/introduction_image_02.jpg' alt='' />");
    	$("#header_loop_image img:last").fadeOut(2000, function(){
    		$(this).remove();
	    	$("#header_loop_image img").before("<img src='content/images/home/index/introduction_image_03.jpg' alt='' />");
	    	$("#header_loop_image img:last").fadeOut(2000, function(){
	    		$(this).remove();
		    	$("#header_loop_image img").before("<img src='content/images/home/index/blank_image.jpg' alt='' />");
		    	$("#header_loop_image img:last").fadeOut(6000, function(){
		    		$(this).remove();
			    	$("#header_loop_image img").before("<img src='content/images/home/index/blank_image.jpg' alt='' />");
			    	$("#header_loop_image img:last").fadeOut(500, function(){
			    		$(this).remove();
				    	$("#header_loop_image img").before("<img src='content/images/home/index/loop_image_01.jpg' alt='' />");
				    	$("#header_loop_image img:last").fadeOut(2000, function(){
				    		$(this).remove();
				    		setInterval(startLoopImage, 4000);
				    	});
			    	});
		    	});
	    	});
    	});
	});
}


