function $id(p){
	return document.getElementById(p);	
}

//首页轮播
var timeDelay = 5; //定义图片延迟显示的秒数
var currentId = 0; 
var slidint;
var imageNum;

//控制当前焦点按钮样式
function setFocus(n){
	var imgList = document.getElementById("adImg").getElementsByTagName("li");	
	imageNum = imgList.length;
	if ( imageNum > 1 ){
		for ( i=0;i<imgList.length;i++ ){
			if ( i == n ){
				document.getElementById("adText").getElementsByTagName("span")[i].className = "focus";
				document.getElementById("adImg").getElementsByTagName("li")[i].style.display = "block";
			}
			else{
				document.getElementById("adText").getElementsByTagName("span")[i].className = "";
				document.getElementById("adImg").getElementsByTagName("li")[i].style.display = "none";
			}
		}
		//imgAlpha();
	}
}

//播放下一张
function playnext(){
	if(currentId == imageNum-1){
		currentId = 0;
	}
	else{
		currentId++;
	};
	setFocus(currentId);
	playit();
}
function playit(){
	slidint = setTimeout(playnext,timeDelay*1000);
}
function stopit(){
	clearTimeout(slidint);
}
//鼠标滑过及离开图片的操作
function checkMouseOver(){
	document.getElementById("adImg").onmouseover = function(){
		stopit();
	}
	document.getElementById("adImg").onmouseout = function(){
		playit();
	}
	document.getElementById("adText").onmouseover = function(){
		stopit();
	}
	document.getElementById("adText").onmouseout = function(){
		playit();
	}
}
//点击标签按钮后的操作
function checkClick(){
	var btnList = document.getElementById("adText").getElementsByTagName("span");
	for (i=0;i<btnList.length;i++){	
		btnList[i].id = "tempBtn"+i;
		btnList[i].onmouseover = function(){
			currentId = this.id.slice(-1);
			setFocus(currentId);
			stopit();
			playit();
		}
	}
}
function smothSwitchAd(){
try{
	document.getElementById("adText").getElementsByTagName("span")[0].className = "focus";
	checkMouseOver();
	checkClick();
	playit();
}catch(e){}
}


//切换显示
function changeshow(id,childID){
try{
	var btn = document.getElementById(id).getElementsByTagName("span");
	for( i=0;i<btn.length;i++){
		btn[i].id = "btn_"+i;
		btn[i].onclick = function(){
			for( i=0;i<btn.length;i++){
				btn[i].className = "";
				document.getElementById(childID+i).style.display = "none";
			}
			this.className = "focus";
			document.getElementById(childID+this.id.slice(-1)).style.display = "";
		}	
	}
}catch(e){}
}

function iVal(id,text){
try{
	$id(id).value=text;
	$id(id).onfocus=function(){
		if(this.value==text){
			this.value="";
		}
	}
	$id(id).onblur=function(){
		if(this.value==""){
			this.value=text;
		}
	}
}catch(e){}
}

function iHtml(id,text){
try{
	$id(id).innerHTML=text;
	$id(id).onfocus=function(){
		if(this.innerHTML==text){
			this.innerHTML="";
		}
	}
	$id(id).onblur=function(){
		if(this.innerHTML==""){
			this.innerHTML=text;
		}
	}
}catch(e){}
}

function showTextArea(n){
for( i=0;i<3;i++ ){
	if( i==n ){
		$id("textarea1_"+i).style.display = "";
	}else{
		$id("textarea1_"+i).style.display = "none";
	}
}	
}

function showhelpcontent(obj){
	var div = obj.parentNode;
	if( div.className == "focus"){
		div.className = "";
	}else{
		div.className = "focus";
	}
}

function hidehelp(obj){
	var div = obj.parentNode.parentNode.parentNode;
	div.className ="";
}

function showxq(id){
	var div = document.getElementById(id);
	if( div.style.display == "none" ){
		div.style.display = "block"
	}else{
		div.style.display = "none"
	}
}
function showLoginBox(){
	var div = document.getElementById("showLoginBox");
	if( div.style.display == "none" ){
		div.style.display = ""
	}else{
		div.style.display = "none"
	}
}

function closeDiv(){
	document.getElementById("unlogin_loginBox").style.display = "none";	
}

function showDiv(){
	var scrollHeight = document.body.scrollHeight; //正文高度
	var clientWidth = document.body.clientWidth; //可见区域宽度
	var clientHeight = document.body.clientHeight; //可见区域高度
	if( clientHeight > scrollHeight ){ scrollHeight=clientHeight }
	var scrollTop = document.documentElement.scrollTop; //上部被卷去的高度
	document.getElementById("login_mask").style.height = scrollHeight +"px";
	document.getElementById("unlogin_loginBox").style.display = "block";
}

function newshowLoginBox(id){
	var now = $id(id).style.display;
	if( now == 'none' ){
		$id(id).style.display = '';	
	}else{
		$id(id).style.display = 'none';	
	}
	
}

//切换显示
function fiveBangChangeShow(id,childID){
try{
	var btn = document.getElementById(id).getElementsByTagName("span");
	btns = btn.length;
	for( i=0;i<btns;i++){
		btn[i].id = "btn_"+(btns-i-1);
		btn[i].onmouseover = function(){
			for( i=0;i<btn.length;i++){
				btn[i].className = "";
				document.getElementById(childID+i).style.display = "none";
			}
			this.className = "focus";
			showid = this.id.slice(-1);
			//alert(showid);
			document.getElementById(childID+showid).style.display = "";
		}	
	}
}catch(e){}
}


function boxsort(n){
	for( i=0;i<2;i++ ){
		document.getElementById('boxtag_'+i).style.display = 'none';
	}
	document.getElementById('boxtag_'+n).style.display = '';
}
