// JavaScript Document
function $(itemid){
	return document.getElementById(itemid)
}

function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}

function Fun_PubSwitch_V(itemid){
	if (document.getElementById(itemid).style.visibility == "hidden") {
		document.getElementById(itemid).style.visibility = "";
	}
	else{
		document.getElementById(itemid).style.visibility = "hidden";
	}
}


function autoswitch (itemid){
	if (document.getElementById(itemid).style.display != "")document.getElementById(itemid).style.display = "";
	else document.getElementById(itemid).style.display = "none";
}




function changClass(Front,id,count,de_class,indexclass,show){
	for(i=1; i<=count; i++){
		if(document.getElementById(Front + i)) {
			document.getElementById(Front + i).className = de_class;
			if (show != false){
				document.getElementById(Front + "S_" + i).style.display = "none";
			}
		}
	}
	
	document.getElementById(Front + id).className = indexclass;
	if (show != false){
		document.getElementById(Front + "S_" + id).style.display = "";
	}
}

function onechangClass(itemid,de_class,indexclass){
	
	if (document.getElementById(itemid).className == de_class){
		document.getElementById(itemid).className = indexclass;
	}
	else{
		document.getElementById(itemid).className = de_class;
	}
}

function changview (Front, id, count){
	for(i=0; i<=count; i++){
		document.getElementById(Front + i).style.display = "none";
	}
	
	document.getElementById(Front + id).style.display = "";
}

function changview_invite (Front, id, count){
	for(i=1; i<=count; i++){
		document.getElementById(Front + i).style.display = "none";
	}
	
	document.getElementById(Front + id).style.display = "";
}

function getoffsetX(e){
	var x = e.offsetLeft;   
	while(e=e.offsetParent) {x += e.offsetLeft;}
	return  x
}

function getoffsetY(e){
	var y = e.offsetTop;   
	while(e=e.offsetParent) {y += e.offsetTop;}
	
	 return  y
}

function showback(e,username){
	var x =getoffsetX(e),y = getoffsetY(e);  
	
	document.getElementById("backcomm").style.top =   y + -100 + "px"
	document.getElementById("buname").innerHTML = username
	//document.getElementById("append_parent").style.left =   x - 70 + "px"

	
	document.getElementById("backcomm").style.display = ""
	//document.getElementById("moveGroup").style.display = ""

}

function showfloat(itemid){
	document.getElementById(itemid).style.display = ""
}

function closeback(itemid){
	document.getElementById(itemid).style.display = "none"
}



//自动调整iframe框架的方法
function iframeAuto() { 
	
	try {
		//if(window.parent) {
			//定位需要调整的frame框架（在父级窗口中查找）		
			var a = parent.document.getElementsByTagName("IFRAME"); 		
			for(var i=0; i<a.length; i++) { 	
				if(a[i].contentWindow==window) { 	
					var h1=0, h2=0; 	
					a[i].parentNode.style.height = a[i].offsetHeight +"px"; 	
					a[i].style.height = "10px";              //首先设置高度为10px,后面会修改	
					if(document.documentElement&&document.documentElement.scrollHeight) { 	
						h1=document.documentElement.scrollHeight; 
		
					} 	
					if(document.body) h2=document.body.scrollHeight; 	
					var h=Math.max(h1, h2);               //取两者中的较大值	
					if(document.all) {h += 4;} 	
					if(window.opera) {h += 1;} 
		
					//调整框架的大小	
					a[i].style.height = a[i].parentNode.style.height = h +"px"; 
		
				} 
			} 
		//}
	} catch (ex){
		//alert(ex);	
	} 

}


var heightPar = -64;
var imgcount = 5;
var Time = 50;
var background = "url(images/nav_v.gif) no-repeat "
//var background = "url(/images/nav_v.gif) no-repeat"
var NavBgPosition = new Array(6);


for (i=0;i<=5;i++){
	NavBgPosition[i] = new Array(2);
	NavBgPosition[i][1] = 0;
	NavBgPosition[i][2] = 0;
}

NavBgPosition[0][0] = -22;
NavBgPosition[1][0] = -110;
NavBgPosition[2][0] = -197;
NavBgPosition[3][0] = -285;
NavBgPosition[4][0] = -373;
NavBgPosition[5][0] = -464;



function bgload(itemid,loadtype){

	clearTimeout(NavBgPosition[itemid][2]);
	bgload_move(itemid,loadtype)
}


function bgload_move(itemid,loadtype){
	
	if (loadtype == 1){
		NavBgPosition[itemid][1] +=1 ;
	}
	else{
		NavBgPosition[itemid][1] -=1;
	}
	
	var imgtop = NavBgPosition[itemid][1] * heightPar;
	
	document.getElementById("nav_" + itemid).style.background =  background + NavBgPosition[itemid][0] +"px " + imgtop + "px";
	

	if (NavBgPosition[itemid][1] < 5 && NavBgPosition[itemid][1] > 0){
		NavBgPosition[itemid][2] = setTimeout("bgload_move("+itemid+","+loadtype+")",Time);
	}

}







function settogroup(e){   
	var x =getoffsetX(e),y = getoffsetY(e);  
	document.getElementById("d_float").style.top =   y + 15 + "px";
	document.getElementById("d_float").style.left =   x - 350 + "px";
	closeset();
	document.getElementById("d_float").style.display = "";
	document.getElementById("game_Message_Reply").style.display = "";

}

function closeset(){   
	if (document.getElementById("d_float")	!= null) document.getElementById("d_float").style.display = "none";
	if (document.getElementById("game_Message_Reply")!= null) document.getElementById("game_Message_Reply").style.display = "none";
}


function killErrors() //杀掉所有的出错信息
{ 
	return true; 
} 
window.onerror = killErrors; 