(function($){
	mySlidePlayer = function(object,config){
		
			//定义全局变量
			this.obj = object;
			var t;
			this.n =0;
			this.j =0;
			var _this = this;	
			this.count = $(this.obj + " .focusData li").size();
			var defaults = {width:"300px",height:"200px",time:"5000"}; 
        	this.config = $.extend(defaults,config);  
			var linkArry = {};
			var picArry = {};
			var titleArry = {};
			
			$(this.obj + " .focusData li").each(function(i){
				linkArry[i] = $(_this.obj + " li:eq("+i+") span:eq(0)").text();
				picArry[i] = $(_this.obj + " li:eq("+i+") span:eq(1)").text();
				titleArry[i] = $(_this.obj + " li:eq("+i+") span:eq(2)").text();
			});
			
			//主事件
			this.factory = function(){
			
				$(this.obj + " .focusData li").each(function(i){
					$(_this.obj + " .focusPic").append("<a href='"+linkArry[i]+"' target='_blank'><img src='"+picArry[i]+"' width='"+_this.config.width+"' height='"+_this.config.height+"'></a>");
					$(_this.obj + " .focusContent").append("<a rel='"+i+"' href='"+linkArry[i]+"' target='_blank'>"+titleArry[i]+"</a>");
					if(i!= 0){$(_this.obj + " .focusPic a:eq("+i+")").hide()};
					if(i == 0){$(_this.obj + " .focusContent a:eq("+i+")").addClass("even")};
				});
				
				$(this.obj + " .loading").hide();
				$(this.obj + " .focusPic").show();
				$(this.obj + " .focusTitle").show();
				$(this.obj + " .focusContent").show();
				
				this.slide();
				this.addhover();
				t = setInterval(this.autoplay,_this.config.time);
				
			};
			
			//渐隐事件
			this.slide = function(){
				$(this.obj + " .focusContent a").mouseover(function(){
					_this.j = $(this).attr("rel");
					_this.n = _this.j; 
					if (_this.j >= _this.count){return;}
					$(this).addClass("even").siblings().removeClass("even")
					$(_this.obj + "  .focusPic a:eq(" + _this.j + ")").fadeIn("800").siblings().fadeOut("800"); 						   
				});		
			};
			
			//滑过事件
			this.addhover = function(){
				$(this.obj).hover(function(){clearInterval(t);}, function(){t = setInterval(_this.autoplay,_this.config.time)});
        	}
			
			//自动播放事件
			this.autoplay = function(){
				_this.n = _this.n >= (_this.count - 1) ? 0 : ++_this.n;
				$(_this.obj + " .focusContent a").eq(_this.n).triggerHandler('mouseover');
			}
			
			this.factory();
			
    }
})(jQuery)


