var dododo = {
	init:function(tabInfo){
		this.tabInfo = tabInfo;
		for(var i = 0; i < this.tabInfo.length; i++){
			//alert(this.tabInfo[i].invervalTime);
			
			this.tabInfo[i].autoRun = this.tabInfo[i].autoRun ? this.tabInfo[i].autoRun:false;
			this.tabInfo[i].invervalTime = this.tabInfo[i].invervalTime ? this.tabInfo[i].invervalTime:1000;
			
			this.tabInfo[i].action = this.tabInfo[i].action ? this.tabInfo[i].action:"mouseover";
			this.tabInfo[i].actionDelay = this.tabInfo[i].actionDelay ? this.tabInfo[i].actionDelay:100;
			
			this.tabInfo[i].menuActiveClass = this.tabInfo[i].menuActiveClass ? this.tabInfo[i].menuActiveClass:"activity";
			this.tabInfo[i].menuSlientClass = this.tabInfo[i].menuSlientClass ? this.tabInfo[i].menuSlientClass:"slient";
			
			
			
			
			//
			var handle = function(e){
				//var tag = Event.element(e).tagName.toLowerCase();
				
				var data = $A(arguments);
				
				setTimeout(function(){
					doChange(data[1],data[2],data[3],data[4]);
				},data[5]);

			};
			
			//
			
			doChange = function(eleArr,curId,activeClass,slientClass){
				try{
					for(var k = 0; k < eleArr.length; k++){
						if(eleArr[k].menuId === curId){
							if($(eleArr[k].menuId).lang){
								$(eleArr[k].menuId).removeClassName(slientClass+"_"+$(eleArr[k].menuId).lang);
								$(eleArr[k].menuId).addClassName(activeClass+"_"+$(eleArr[k].menuId).lang);
							}else {
								$(eleArr[k].menuId).removeClassName(slientClass);
								$(eleArr[k].menuId).addClassName(activeClass);
							}
							$(eleArr[k].contentId).style.display = "block";
						}else {
							if($(eleArr[k].menuId).lang){
								$(eleArr[k].menuId).removeClassName(activeClass+"_"+$(eleArr[k].menuId).lang);
								$(eleArr[k].menuId).addClassName(slientClass+"_"+$(eleArr[k].menuId).lang);
							}else{
								$(eleArr[k].menuId).removeClassName(activeClass);
								$(eleArr[k].menuId).addClassName(slientClass);
							}
							$(eleArr[k].contentId).style.display = "none";
						}
					}
				} catch (e){
				
				}
			};
			
			for(var j = 0; j< this.tabInfo[i].element.length; j++){
				//alert(this.tabInfo[i].element[j].menuId);
				try{
					$(this.tabInfo[i].element[j].menuId).observe(this.tabInfo[i].action,
					handle.bindAsEventListener(
						"E",
						this.tabInfo[i].element,
						this.tabInfo[i].element[j].menuId,
						this.tabInfo[i].menuActiveClass,
						this.tabInfo[i].menuSlientClass,
						this.tabInfo[i].actionDelay
					));
				} catch (e){
					//alert(e);
				}
			}
		}
	}
}

var toggleClass = function(idArr,className){
	for(var i = 0; i < idArr.length; i++){
		/*
			alert($("list_a"));
			
		*/	
		var tempElementArr = $(idArr[i]).childElements();
		
		for(var j = 0; j < tempElementArr.length; j++){
			if(tempElementArr[j].lang !== "zh"){
				tempElementArr[j].observe("mouseover",function(){
					this.addClassName(className);
				});
				tempElementArr[j].observe("mouseout",function(){
					this.removeClassName(className);
				});				
			}
		}
		
	}
}





//图片轮换
var Interval = {}
Interval.init = function(obj){
	//元素个数、宽度、父元素
	obj.eleNum = $(obj.ele).childElements().length;
	obj.eleWidth = $(obj.ele).childElements()[0].getWidth();
	obj.father = $(obj.ele).parentNode;

	//复制现有元素
	$(obj.ele).insert($(obj.ele).innerHTML);
	
	//当前元素索引号
	if(obj.goLeft){
		obj.currentNum = 0;
	} else {
		obj.currentNum = obj.eleNum;
		obj.father.scrollLeft = obj.eleNum*(obj.eleWidth + obj.marginLeft);
	}
	
	
	$(obj.ele).onmouseover = new Function("Interval.pause("+obj.objName+");");
	$(obj.ele).onmouseout = new Function("Interval.auto("+obj.objName+");");
	$(obj.leftPointer).onclick = new Function("Interval.gotoLeft("+obj.objName+");");
	$(obj.rightPointer).onclick = new Function("Interval.gotoRight("+obj.objName+");");
	
	Interval.auto(obj);
}
Interval.pause = function(obj){
	clearInterval(obj.autoScroller);
}

Interval.gotoLeft = function(obj){
	clearInterval(obj.autoScroller);

	if(!obj.goLeft){
		obj.goLeft = true;
		if (obj.currentNum === obj.eleNum) {
			obj.currentNum = obj.eleNum-obj.currentNum;
			obj.father.scrollLeft = obj.father.scrollLeft - obj.eleNum*(obj.eleWidth + obj.marginLeft);
		}
	} 

	clearInterval(obj.sonScrollInterval);
	Interval.change(obj,obj.currentNum+1);
	Interval.auto(obj);
}

Interval.gotoRight = function(obj){ 
	clearInterval(obj.autoScroller);
	//alert(obj.currentNum);
	if(obj.goLeft){
		obj.goLeft = false;
		//obj.currentNum = obj.eleNum - obj.currentNum;
		if (obj.currentNum === 0) {		
			obj.currentNum = obj.eleNum-obj.currentNum;
			//alert(obj.father.scrollLeft); 
			obj.father.scrollLeft = obj.eleNum*(obj.eleWidth + obj.marginLeft);
		}       
	}
	
	clearInterval(obj.sonScrollInterval);
	Interval.change(obj,obj.currentNum-1);
	Interval.auto(obj);
}
Interval.auto = function(obj){
	clearInterval(obj.autoScroller);
	obj.autoScroller = setInterval(function(){
		//$("cn").innerHTML=obj.currentNum;
		if(obj.goLeft){
			Interval.change(obj,obj.currentNum+1);
		} else {
			Interval.change(obj,obj.currentNum-1);
		}
	},obj.intervalTime);
}
Interval.change = function(obj,index){
	if(index==obj.currentNum){
		return;
	}
	var count=0;
	var duration=30;
	
	var begin_value = obj.father.scrollLeft;
	//alert(begin_value);
	var eleWidth = obj.eleWidth + obj.marginLeft;
	var spanNum = index-obj.currentNum;
	var chang_in_value=spanNum*eleWidth+(obj.currentNum*eleWidth-begin_value);
	
	obj.sonScrollInterval=setInterval(function(){doit(begin_value,chang_in_value)},10);
	function doit(b,c){
		obj.father.scrollLeft=cpu(count,b,c,duration);
		count++;
		if(count==duration){
			clearInterval(obj.sonScrollInterval);
			sonScrollInterval=0;
			count=0;
			if(obj.goLeft){
				if (obj.currentNum === obj.eleNum-1) {
					obj.father.scrollLeft=0;
					obj.currentNum=0;
				} else {
					obj.father.scrollLeft=b+c;
					obj.currentNum=index;
				}
			} else {
				if (obj.currentNum === 1) {						
					obj.currentNum = obj.eleNum;
					obj.father.scrollLeft = obj.eleNum*(obj.eleWidth + obj.marginLeft);
				} else {
					obj.father.scrollLeft=b+c;
					obj.currentNum=index;
				}
			}
			
		}
	}
	function cpu(t,b,c,d) {return c*((t=t/d-1)*t*t+1)+b;};
}

