/*本图片切换类由超宝原创，请保留版权信息*/
/*感谢菜鸟吧提供js面向对象延时支持思路*/
window.objTimeoutFuncs  = [];
window.objTimeoutIds =  [];
function  objTimeout(obj,func,time,id){
	window.objTimeoutFuncs[id] = function(){
		func.apply(obj,arguments);
	}
	var argumentslist = "";
	for(var i=4;i<arguments.length;i++)
		argumentslist+=arguments[i]+",";
	if(argumentslist.length>1) argumentslist=argumentslist.substr(0,argumentslist.length-1);
	window.objTimeoutIds[id] =  setTimeout('objTimeoutFuncs[\''+ id +'\']('+ argumentslist+')',time);
}
function  clearObjTimeout(id){
	clearTimeout(window.objTimeoutIds[id]);
}
function SlideShow(pa,sp)
{
	var F_delay=10;
	var F_img=null;
	var F_temp_count=1;
	this.preload=new Array();
	var ThisObject = this;

	//图片信息数据
	this.photoarr = pa;
	//显示位置ID
	this.showplace = sp;

	this.PhotoArray = function(pa){
		this.photoarr = pa;
		this.LoadPic();
	}
	this.ShowPlace = function(sp){
		this.showplace = sp;
	}
	this.startSlideshow = function() {
	    var imgbarHTML = "";
	    imgbarHTML += "<ul class='button_image'>";
	    for (var i = 0; i < this.photoarr.length; i++) {
	        this.preload[i] = new Image();
	        this.preload[i].src = this.photoarr[i][0];
	        this.preload[i].alt = this.photoarr[i][1];
	        imgbarHTML += "<li id='i" + i + "'><a href='" + this.photoarr[i][2] + "' target='_blank'>" + (i + 1) + "</a></li>";
	    }
	    imgbarHTML += "</ul>";
	    //$("#" + this.showplace + " .Focus_Img").html($("#" + this.showplace + " .Focus_Img").html() + imgbarHTML);
	    $("#" + this.showplace + " .Focus_Img").after(imgbarHTML);
	    $("#" + this.showplace + " .Curr_image").html("<a href='" + this.photoarr[0][2] + "' target='_blank'><img src='" + this.photoarr[0][0] + "' width='100%' alt='" + this.photoarr[0][1] + "' class='photo' style='filter:revealtrans(duration=2,transition=23)' /></a>");
	    $("#" + this.showplace + " .Curr_text").html("<a href='" + this.photoarr[0][2] + "' target='_blank'>" + this.photoarr[0][1] + "</a>");
	    $("#" + this.showplace + " .button_image > li:eq(0)").addClass("selected");
	    F_img = $("#" + this.showplace + " .Curr_image img").get(0);
	    this.delayInfo(1);
	    $("#" + this.showplace + " .button_image > li").hover(
			function() {
			    clearObjTimeout(ThisObject.showplace);
			    ThisObject.cueNextSlide(this.id.substr(1, 1));
			}
			,
			function() {
			    clearObjTimeout(ThisObject.showplace);
			    ThisObject.delayInfo(F_temp_count);
			}
		);
	    F_img.onmouseover = function() {
	        clearObjTimeout(ThisObject.showplace);
	    };
	    F_img.onmouseout = function() {
	        ThisObject.delayInfo(F_temp_count);
	    };
	}

	this.cueNextSlide = function(){
		F_count = arguments[0];
		if ($.browser.msie&&$.browser.version<="7.0"){F_img.filters.revealtrans.transition=23;F_img.filters.revealtrans.Apply(); }
		F_img.src=this.preload[F_count].src;
		if ($.browser.msie && $.browser.version <= "7.0") { F_img.filters.revealtrans.Play(); }
		F_img.alt=this.preload[F_count].alt;
		$("#"+this.showplace+" .Curr_image a").get(0).href=this.photoarr[F_count][2];
		$("#"+this.showplace+" .Curr_text a").get(0).href=this.photoarr[F_count][2];
		$("#"+this.showplace+" .Curr_text > a").html(this.preload[F_count].alt);
		$("#"+this.showplace+" .button_image > li").removeClass("selected");
		$("#"+this.showplace+" .button_image > li:eq("+F_count+")").addClass("selected");
		if (++F_count==this.photoarr.length){F_count=0;}
		this.delayInfo(F_count);
		F_temp_count=F_count;
	}
	this.delayInfo = function(F_count){
		clearObjTimeout(F_count);
		objTimeout(this,this.cueNextSlide,F_delay*1000,this.showplace,F_count);
	};
}