/**
	标签
*/
function turn(n,m,x){
	for(i=1;i<=m;i++){
		if(i==n){
			jQuery('#lm'+x+'_'+i).addClass("now");
			jQuery('#content'+x+'_'+i).css("display","block");
		}else{
			jQuery('#lm'+x+'_'+i).removeClass("now");
			jQuery('#content'+x+'_'+i).css("display","none");
		}
	}
}
/**
	焦点图
*/
var MDC_FocusImage=function(){
	var FocusImage=arguments[0];
	this.id=jQuery(FocusImage.id);
	this.imgW=parseInt(FocusImage.imgW);
	this.imgH=parseInt(FocusImage.imgH);
	this.speed=parseInt(FocusImage.speed)||5000;
	this.focusData=arguments;
	this.autoPlay;
};
MDC_FocusImage.prototype={	
	init:function(){
		var that=this;		
		that.id.append(
			jQuery("<img>",{
				width:this.imgW,
				height:this.imgH
			})
		).append(
			jQuery("<div>",{
				className:"cover"
			}).append(
				jQuery("<img>",{
					width:this.imgW,
					height:this.imgH,
					src:"http://images.sohu.com/ccc.gif"
				})
			)		
		).append(
			jQuery("<div>",{
				className:"tab"
			})
		)
		for(var i=1;i<that.focusData.length;i++){
			that.id.find(".tab").append(
				jQuery("<span>",{
					text:i
				})
			)
		};
		this.spring();
	},
	spring:function(){
		var that=this,_tab=that.id.find(".tab span");
		var gogo=function(i){
			var _index=i||1;
			that.alternation(_index);
			that.autoPlay=setInterval(function(){
				that.alternation(_index==that.focusData.length-1?_index=1:++_index);
			},that.speed);
		};
		gogo();		
		_tab.each(function(i){
			(function(i){
				_tab.eq(i).click(function(){
					if(jQuery(this)[0].className!="now"){
						clearTimeout(that.autoPlay);
						gogo(i+1)
					}
				})
			})(i)
		});
		this.id.find(".cover").click(function(){
			window.open(that.id.find("img:eq(0)").attr("link"));
		})
	},
	alternation:function(i){
		var that=this;
		that.id.find(".tab span.now").removeClass();
		that.id.find(".tab span").eq(i-1).addClass("now");
		that.id.find("img:eq(0)").attr({
			"src":that.focusData[i][0],
			"link":that.focusData[i][1]
		}).css({
			display:"block",
			opacity:0
		}).stop().animate({opacity:1},300);		
	}
};
jQuery(function(jQ){	
	/**
		列表滚动
	*/
	var scrollList=function(id,ddWidth,ddShowNum){
		this.id=jQ(id);
		this.ddWidth=parseInt(ddWidth);
		this.ddShowNum=parseInt(ddShowNum);
	};
	scrollList.prototype={
		init:function(){
			var that=this;
			this.id.find("dl").width(this.id.find("dd").length*this.ddWidth);
			var ambit=this.id.find("dd").length*this.ddWidth-this.ddShowNum*this.ddWidth;
			var that=this;
			var list=that.id.find("dl");
			var lButton=that.id.find(".l");
			var rButton=that.id.find(".r");
			if(this.id.find("dd").length>that.ddShowNum){				
				function buttonShow(){
					if(list.position().left<0){
						lButton.css({"opacity":1,"cursor":"pointer"})						
					}else{
						lButton.css({"opacity":.5,"cursor":"auto"})
					};
					if(list.position().left>-(ambit-2)){
						rButton.css({"opacity":1,"cursor":"pointer"})	
					}else{
						rButton.css({"opacity":.5,"cursor":"auto"})
					};
				};
				buttonShow();
				rButton.mousedown(function(){
					if(!list.is(":animated")){
						if(list.position().left>-(ambit-2)){
							list.stop().animate({left:"-="+that.ddWidth},200,function(){
								buttonShow();
							});							
						}
					}		
				});
				lButton.mousedown(function(){
					if(!list.is(":animated")){
						if(list.position().left<0){
							list.stop().animate({left:"+="+that.ddWidth},200,function(){
								buttonShow();
							});
						}
					}
				})
			}else{
				lButton.css({"opacity":.5,"cursor":"auto"});
				rButton.css({"opacity":.5,"cursor":"auto"})
			}
		}
	};
	var scrollList_1=new scrollList("#scrollListA","85","4");
	scrollList_1.init();
	var scrollList_2=new scrollList("#scrollListB","90","7");
	scrollList_2.init();
	var scrollList_3=new scrollList("#scrollListC","103","6");
	scrollList_3.init();
	/**
		大视野
	*/
	var eyeshot={
		id:jQ("#eyeshot"),
		init:function(){
			this.id.find("span").css("opacity",.5);
			this.id.find(".box").each(function(){
				jQ(this).find("> *").css("bottom",-30)
			});
			this.id.find(".box").hover(function(){
				jQ(this).find("> *").stop().animate({bottom:-1},200)
			},function(){
				jQ(this).find("> *").stop().animate({bottom:-30},200)
			});
		}
	}.init()
})

