// JavaScript Document
/* jQuery图片预加载插件。 */
jQuery.fn.loadthumb = function(options) {
	options = $.extend({
		 src : ""
	},options);
	var _self = this;
	_self.hide();
	var img = new Image();
	$(img).load(function(){
		_self.attr("src", options.src);
		_self.fadeIn("slow");
	}).attr("src", options.src);  //.atte("src",options.src)要放在load后面，
	return _self;
}

$(document).ready(function(){
	var $img = $("#indexSlide img");
	var i = 1;
	var max = 1; //图片的最大数 (总数减1)
	var slide_delay = 5000;
	$.getJSON('images/slide/data.txt', function(data) {
		max = parseInt(data['total']) ;
		
		function showImg() {
			i++;
			if(i > max ){
				i = 1;
			}
			$img.loadthumb({"src":"images/slide/img_"+i+".jpg"});//应用图片预加载技术
		}

		slideTimer = setInterval(showImg,5000);
	});
});
