var current_menu=1;
function setTab(name,cursel,n){
	current_menu=cursel;
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById("con_"+name+"_"+i);
		menu.className=i==cursel?"on":"";
		con.style.display=i==cursel?"block":"none";
	}
}
function onover(name,cursel){
	if(current_menu!=cursel)document.getElementById(name+cursel).className="on";
}
function onout(name,cursel){
	if(current_menu!=cursel)document.getElementById(name+cursel).className="";
}
var cur_index=1;
var cur_index_bak=cur_index;
var num=5;
var isStoped=false;
function getObj(objName){
	if(document.getElementById){
		return eval("document.getElementById('" + objName + "')");
	}else if(document.layers){
		return eval("document.layers['" + objName +"']");
	}else{
		return eval('document.all.' + objName);
	}
}
function change_Menu(index){
	for(var i=1;i<=num;i++){
		if(getObj("con"+i)&&getObj("m"+i)){
			getObj("con"+i).style.display = index==i?"block":"none";
			getObj("m"+i).className = index==i?"menuOn":"menuOff";
		}
	}
	if(index<num){
	   index++;
	}else{
	    index=1;
	}
	cur_index=index;
}
var settime=setInterval("change_Menu(cur_index);",5000);
function Menu(c_index,isStop){
	if(isStop){
		isStoped=true;
		stopMemu();
		cur_index_bak=cur_index;
		change_Menu(c_index);
	}else{
		if(isStoped){
			isStoped=false;
			cur_index=cur_index_bak;
			settime=setInterval("change_Menu(cur_index);",5000);
		}
	}
}
function stopMemu(){
	clearInterval(settime);
}
function startMemu(){
	settime=setInterval("change_Menu(cur_index);",5000);
}

var speed = 10;
var space = 20;
var pageWidth = 100*1;
var interval = 5000;
var fill = 0;
var moveLock = false;
var moveTimeObj;
var moveWay="right";
var comp = 0;
var autoPlayObj=null;
function AutoPlay(){clearInterval(autoPlayObj);autoPlayObj=setInterval('startRight();setDisplayTime();stopRight();',interval)}
function startLeft(){
	if(moveLock)return;
	clearInterval(autoPlayObj);
	moveLock=true;
	moveWay="left";
	moveTimeObj=setInterval('ISL_ScrUp();',speed);
}
function stopLeft(){
	if(moveWay == "right")return;
	clearInterval(moveTimeObj);
	if((getObj('main_content').scrollLeft-fill)%pageWidth!=0){
		Comp=fill-(getObj('main_content').scrollLeft%pageWidth);
		CompScr()
	}else{moveLock=false;}
	AutoPlay()
}
function startRight(){
	clearInterval(moveTimeObj);
	if(moveLock)return;
	clearInterval(autoPlayObj);
	moveLock=true;
	moveWay="right";
	ISL_ScrDown();
	moveTimeObj=setInterval('ISL_ScrDown();',speed)
}
function stopRight(){
	if(moveWay == "left"){return};
	clearInterval(moveTimeObj);
	if(getObj('main_content').scrollLeft%pageWidth-(fill>=0?fill:fill+1)!=0){
		comp=pageWidth-getObj('main_content').scrollLeft%pageWidth+fill;
		CompScr()
	}else{
		moveLock=false
	}
	AutoPlay();
}
function ISL_ScrUp(){
	if(getObj('main_content').scrollLeft<=0){
		getObj('main_content').scrollLeft=getObj('main_content').scrollLeft+getObj('list1').offsetWidth
	}
	getObj('main_content').scrollLeft-=space
}
function ISL_ScrDown(){
	if(getObj('main_content').scrollLeft>=getObj('list1').scrollWidth){
		getObj('main_content').scrollLeft=getObj('main_content').scrollLeft-getObj('list1').scrollWidth
	}
	getObj('main_content').scrollLeft+=space;
}
function CompScr(){
	if(comp==0){moveLock=false;return}
	var num,TempSpeed=speed,TempSpace=space;
	if(Math.abs(comp)<pageWidth/2){
		TempSpace=Math.round(Math.abs(comp/space));
		if(TempSpace<1){TempSpace=1}
	}
	if(comp<0){
		if(comp<-TempSpace){
			comp+=TempSpace;
			num=TempSpace
		}else{num=-comp;comp=0
		}
		getObj('main_content').scrollLeft-=num;
		setTimeout('CompScr()',TempSpeed)
	}else{
		if(comp>TempSpace){
			comp-=TempSpace;
			num=TempSpace
		}else{
			num=comp;
			comp=0
		}
		getObj('main_content').scrollLeft+=num;
		setTimeout('CompScr()',TempSpeed)
	}
}
function picrun_ini(){
	getObj("list2").innerHTML=getObj("list1").innerHTML;
	getObj('main_content').scrollLeft=fill>=0?fill:getObj('list1').scrollWidth-Math.abs(fill);
	getObj("main_content").onmouseover=function(){clearInterval(autoPlayObj)}
	getObj("main_content").onmouseout=function(){AutoPlay()}
	for(var i =1;i<=listLength;i++){
		getObj("con_three_"+i).onmouseover=function(){clearInterval(autoPlayObj)}
		getObj("con_three_"+i).onmouseout=function(){AutoPlay()}
	}
	AutoPlay();
}

var hotMenu=null;
var listLength=6;
var hot_index=1;

function setTab3(name,cursel,n){
	for(i=1;i<=n;i++){
		var menu=document.getElementsByName(name+i);
		var con=document.getElementById("con_"+name+"_"+i);
		con.style.display=i==cursel?"block":"none";
	}
}
function setDisplayTime(){
	hot_index = hot_index+1;
	setTab3('three',hot_index,listLength);
	if(hot_index>=listLength) hot_index=0;
}
