//鼠标经过变换层
function swap_tab(_this,n){ 
for(var i=1;i<=6;i++){ 
var curC=document.getElementById("tab_"+i); 
var curB=document.getElementById("tab_t"+i); 

if(n==i){ 
curC.style.display="block"; 
curB.className="over"

}else{ 
curC.style.display="none"; 
curB.className=""

} 
} 
} 

//鼠标经过变换层2
function swap_pdtab(_this,n){ 
for(var i=1;i<=12;i++){ 
var curC=document.getElementById("pdtab_"+i); 
var curB=document.getElementById("pdtab_t"+i); 

if(n==i){ 
curC.style.display="block"; 
curB.className="over"

}else{ 
curC.style.display="none"; 
curB.className=""

} 
} 
} 

//关于我们鼠标经过变换层
function swap_atab(_this,n){ 
for(var i=1;i<=4;i++){ 
var curC=document.getElementById("atab_"+i); 
var curB=document.getElementById("atab_t"+i); 

if(n==i){ 
curC.style.display="block"; 
curB.className="over"

}else{ 
curC.style.display="none"; 
curB.className=""

} 
} 
} 

//帮助页鼠标经过变换层
function swap_htab(_this,n){ 
for(var i=1;i<=3;i++){ 
var curC=document.getElementById("htab_"+i); 
var curB=document.getElementById("htab_t"+i); 

if(n==i){ 
curC.style.display="block"; 
curB.className="over"

}else{ 
curC.style.display="none"; 
curB.className=""

} 
} 
}

//首页网站公告焦点图片轮换
function $(id) { return document.getElementById(id); }

function addLoadEventA(func){
	var oldonloadA = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function(){
			oldonloadA();
			func();
		}
	}
}


function addBtnA() {
	if(!$('focus_turn')||!$('focus_pic')||!$('focus_tx')) return;
	var focusListA = $('focus_pic').getElementsByTagName('li');
	if(!focusListA||focusListA.length==0) return;
	var btnBoxA = document.createElement('div');
	btnBoxA.setAttribute('id','focus_btn');
	var SpanBoxA ='';
	for(var i=1; i<=focusListA.length; i++ ) {
		var spanListA = '<span class="normal">'+i+'</span>';
		SpanBoxA += spanListA;
	}
	btnBoxA.innerHTML = SpanBoxA;
	$('focus_turn').appendChild(btnBoxA);
	$('focus_btn').getElementsByTagName('span')[0].className = 'current';
}

function classNormalA(){
	var focusListA = $('focus_pic').getElementsByTagName('li');
	var btnListA = $('focus_btn').getElementsByTagName('span');
	var txListA = $('focus_tx').getElementsByTagName('li');
	for(var i=0; i<focusListA.length; i++) {
		focusListA[i].className='normal';
		btnListA[i].className='normal';
		txListA[i].className='normal';
	}
}

function classCurrentA(n){
	var focusListA = $('focus_pic').getElementsByTagName('li');
	var btnListA = $('focus_btn').getElementsByTagName('span');
	var txListA = $('focus_tx').getElementsByTagName('li');
	focusListA[n].className='current';
	btnListA[n].className='current';
	txListA[n].className='current';
}

var autoKeyA = false;
function btnTurnA() {
	if(!$('focus_turn')||!$('focus_pic')||!$('focus_tx') || !$('focus_btn')) return;
	$('focus_turn').onmouseover = function(){autoKeyA = true};
	$('focus_turn').onmouseout = function(){autoKeyA = false};	
	var focusListA = $('focus_pic').getElementsByTagName('li');
	var btnListA = $('focus_btn').getElementsByTagName('span');
	var txListA = $('focus_tx').getElementsByTagName('li');
	for (var m=0; m<btnListA.length; m++){
		btnListA[m].onmouseover = function() {
			classNormalA();
			this.className='current';
			var n=this.childNodes[0].nodeValue-1;
			focusListA[n].className='current';
			txListA[n].className='current';
		}
	}
}

addLoadEventA(addBtnA);
addLoadEventA(btnTurnA);
addLoadEventA(setautoturnA);

function setautoturnA() {
	setInterval('autoTurnA()', 5000);
}

function autoTurnA() {
	if(!$('focus_turn')||!$('focus_pic')||!$('focus_tx')) return;
	if (autoKeyA) return;
	var focusListA = $('focus_pic').getElementsByTagName('li');
	var btnListA = $('focus_btn').getElementsByTagName('span');
	var txListA = $('focus_tx').getElementsByTagName('li');
	for(var i=0; i<focusListA.length; i++) {
		if (focusListA[i].className == 'current') {
			var currentNumA = i;
		}
	}
	if (currentNumA==focusListA.length-1 ){
		classNormalA();
		classCurrentA(0);
	} else {
		classNormalA();
		classCurrentA(currentNumA+1);
	}

}

// 首页焦点轮换图片大图
function $(id) { return document.getElementById(id); }

function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}

function moveElement(elementID,final_x,final_y,interval) {
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  var elem = document.getElementById(elementID);
  if (elem.movement) {
    clearTimeout(elem.movement);
  }
  if (!elem.style.left) {
    elem.style.left = "0px";
  }
  if (!elem.style.top) {
    elem.style.top = "0px";
  }
  var xpos = parseInt(elem.style.left);
  var ypos = parseInt(elem.style.top);
  if (xpos == final_x && ypos == final_y) {
		return true;
  }
  if (xpos < final_x) {
    var dist = Math.ceil((final_x - xpos)/10);
    xpos = xpos + dist;
  }
  if (xpos > final_x) {
    var dist = Math.ceil((xpos - final_x)/10);
    xpos = xpos - dist;
  }
  if (ypos < final_y) {
    var dist = Math.ceil((final_y - ypos)/10);
    ypos = ypos + dist;
  }
  if (ypos > final_y) {
    var dist = Math.ceil((ypos - final_y)/10);
    ypos = ypos - dist;
  }
  elem.style.left = xpos + "px";
  elem.style.top = ypos + "px";
  var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
  elem.movement = setTimeout(repeat,interval);
}

function classNormal(focus_turn_btn,focus_turn_tx){
	var focusBtnList = $(focus_turn_btn).getElementsByTagName('li');
	var focusTxList = $(focus_turn_tx).getElementsByTagName('li');
	for(var i=0; i<focusBtnList.length; i++) {
		focusBtnList[i].className='normal';
		focusTxList[i].className='normal';
	}
}

function classCurrent(focus_turn_btn,focus_turn_tx,n){
	var focusBtnList = $(focus_turn_btn).getElementsByTagName('li');
	var focusTxList = $(focus_turn_tx).getElementsByTagName('li');
	focusBtnList[n].className='current';
	focusTxList[n].className='current';
}

function newsfocusChange() {
	if(!$('news_focus_turn')||!$('news_focus_turn_btn')) return;
	$('news_focus_turn').onmouseover = function(){atuokey = true};
	$('news_focus_turn').onmouseout = function(){atuokey = false};
	var focusBtnList = $('news_focus_turn_btn').getElementsByTagName('li');
	if(!focusBtnList||focusBtnList.length==0) return;
	var listLength = focusBtnList.length;
		focusBtnList[0].onmouseover = function() {
			moveElement('news_focus_turn_picList',0,0,5);
			classNormal('news_focus_turn_btn','news_focus_turn_tx');
			classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
		}
	if (listLength>=2) {
		focusBtnList[1].onmouseover = function() {
			moveElement('news_focus_turn_picList',-400,0,5);
			classNormal('news_focus_turn_btn','news_focus_turn_tx');
			classCurrent('news_focus_turn_btn','news_focus_turn_tx',1)
		}
	}
	if (listLength>=3) {
		focusBtnList[2].onmouseover = function() {
			moveElement('news_focus_turn_picList',-800,0,5);
			classNormal('news_focus_turn_btn','news_focus_turn_tx');
			classCurrent('news_focus_turn_btn','news_focus_turn_tx',2)
		}
	}
	if (listLength>=4) {
		focusBtnList[3].onmouseover = function() {
			moveElement('news_focus_turn_picList',-1200,0,5);
			classNormal('news_focus_turn_btn','news_focus_turn_tx');
			classCurrent('news_focus_turn_btn','news_focus_turn_tx',3)
		}
	}
}

setInterval('newsautoFocusChange()', 5000);
var atuokey = false;
function newsautoFocusChange() {
	if(!$('news_focus_turn_btn')) return;
	if(atuokey) return;
	var focusBtnList = $('news_focus_turn_btn').getElementsByTagName('li');
	var listLength = focusBtnList.length;
	for(var i=0; i<focusBtnList.length; i++) {
		if (focusBtnList[i].className == 'current') var currentNum = i;
	}
	if (currentNum==0&&listLength!=1 ){
		moveElement('news_focus_turn_picList',-400,0,5);
		classNormal('news_focus_turn_btn','news_focus_turn_tx');
		classCurrent('news_focus_turn_btn','news_focus_turn_tx',1)
	}
	if (currentNum==1&&listLength!=2 ){
		moveElement('news_focus_turn_picList',-800,0,5);
		classNormal('news_focus_turn_btn','news_focus_turn_tx');
		classCurrent('news_focus_turn_btn','news_focus_turn_tx',2)
	}
	if (currentNum==2&&listLength!=3 ){
		moveElement('news_focus_turn_picList',-1200,0,5);
		classNormal('news_focus_turn_btn','news_focus_turn_tx');
		classCurrent('news_focus_turn_btn','news_focus_turn_tx',3)
	}
	if (currentNum==3){
		moveElement('news_focus_turn_picList',0,0,5);
		classNormal('news_focus_turn_btn','news_focus_turn_tx');
		classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
	}
	if (currentNum==1&&listLength==2 ){
		moveElement('news_focus_turn_picList',0,0,5);
		classNormal('news_focus_turn_btn','news_focus_turn_tx');
		classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
	}
	if (currentNum==2&&listLength==3 ){
		moveElement('news_focus_turn_picList',0,0,5);
		classNormal('news_focus_turn_btn','news_focus_turn_tx');
		classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
	}
}

function indexfocusChange() {
	if(!$('index_focus_turn')||!$('index_focus_turn_btn')) return;
	$('index_focus_turn').onmouseover = function(){atuokey = true};
	$('index_focus_turn').onmouseout = function(){atuokey = false};
	var focusBtnList = $('index_focus_turn_btn').getElementsByTagName('li');
	if(!focusBtnList||focusBtnList.length==0) return;
	var listLength = focusBtnList.length;
		focusBtnList[0].onmouseover = function() {
			moveElement('index_focus_turn_picList',0,0,5);
			classNormal('index_focus_turn_btn','index_focus_turn_tx');
			classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
		}
	if (listLength>=2) {
		focusBtnList[1].onmouseover = function() {
			moveElement('index_focus_turn_picList',0,-268,5);
			classNormal('index_focus_turn_btn','index_focus_turn_tx');
			classCurrent('index_focus_turn_btn','index_focus_turn_tx',1);
		}
	}
	if (listLength>=3) {
		focusBtnList[2].onmouseover = function() {
			moveElement('index_focus_turn_picList',0,-538,5);
			classNormal('index_focus_turn_btn','index_focus_turn_tx');
			classCurrent('index_focus_turn_btn','index_focus_turn_tx',2);
		}
	}
	if (listLength>=4) {
		focusBtnList[3].onmouseover = function() {
			moveElement('index_focus_turn_picList',0,-808,5);
			classNormal('index_focus_turn_btn','index_focus_turn_tx');
			classCurrent('index_focus_turn_btn','index_focus_turn_tx',3);
		}
	}
}

setInterval('indexautoFocusChange()',5000);
var atuokey = false;
function indexautoFocusChange() {
	if(!$('index_focus_turn')||!$('index_focus_turn_btn')) return;
	if(atuokey) return;
	var focusBtnList = $('index_focus_turn_btn').getElementsByTagName('li');
	var listLength = focusBtnList.length;
	for(var i=0; i<listLength; i++) {
		if (focusBtnList[i].className == 'current') var currentNum = i;
	}
	if (currentNum==0&&listLength!=1 ){
		moveElement('index_focus_turn_picList',0,-268,5);
		classNormal('index_focus_turn_btn','index_focus_turn_tx');
		classCurrent('index_focus_turn_btn','index_focus_turn_tx',1);
	}
	if (currentNum==1&&listLength!=2 ){
		moveElement('index_focus_turn_picList',0,-538,5);
		classNormal('index_focus_turn_btn','index_focus_turn_tx');
		classCurrent('index_focus_turn_btn','index_focus_turn_tx',2);
	}
	if (currentNum==2&&listLength!=3 ){
		moveElement('index_focus_turn_picList',0,-808,5);
		classNormal('index_focus_turn_btn','index_focus_turn_tx');
		classCurrent('index_focus_turn_btn','index_focus_turn_tx',3);
	}
	if (currentNum==3 ){
		moveElement('index_focus_turn_picList',0,0,5);
		classNormal('index_focus_turn_btn','index_focus_turn_tx');
		classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
	}
	if (currentNum==1&&listLength==2 ){
		moveElement('index_focus_turn_picList',0,0,5);
		classNormal('index_focus_turn_btn','index_focus_turn_tx');
		classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
	}
	if (currentNum==2&&listLength==3 ){
		moveElement('index_focus_turn_picList',0,0,5);
		classNormal('index_focus_turn_btn','index_focus_turn_tx');
		classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
	}
}
addLoadEvent(newsfocusChange);
addLoadEvent(indexfocusChange);
addLoadEvent(nav);

// 导航效果改进
function nav(){	
}
