function setCookie (name, value) {
  document.cookie = name + "=" + value + "; path=/; domain=qq.com";
}
function deleteCookie(name) {

  setCookie(name, "");
}
/***********************************************************
进入房间
***********************************************************/
function enterroom(name)
{

	alert("网站聊天室正在维护，请从QQ客户端登录。");
	return;

	for(var i = 0; i < chatroom.length; i ++)
	{
		if (chatroom[i].name==name)
		{
			chat = window.open("","chat","top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=790,height=530"); 
			chat.focus(); 
			if (chatroom[i].roomtype==0)
				chat.location='http://'+chatroom[i].host+':'+chatroom[i].port+'/4a.html?loca='+chatroom[i].loca;
			else
				chat.location='http://'+chatroom[i].host+':'+chatroom[i].port+'/6a.html?loca='+chatroom[i].loca;
			return;
		}
	}
	
	if ((name.indexOf("大学")==-1) && (name.indexOf("学校")==-1) && (name.indexOf("学院")==-1))
		window.open("http://chat.qq.com"); 
	else
		window.open("http://chat.qq.com/index02.shtml?4"); 
		
}

/***********************************************************
进入房间
***********************************************************/
function chat_redirect(host,port,location,roomtype)
{
        
        alert("网站聊天室正在维护，请从QQ客户端登录。");
        return;
      
	deleteCookie("qqradio");
	var chat = window.open("","chat","top=0,left=0,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=790,height=530"); 
	chat.focus(); 
	if (roomtype==0)
		chat.location='http://'+host+':'+port+'/4a.html?loca='+location;
	else
		chat.location='http://'+host+':'+port+'/6a.html?loca='+location;	
}

/***********************************************************
显示节点内容
***********************************************************/
function qc_redirect(room_class)
{
	for(i = 0; i < chatnode.length; i ++)
	{	
		if (chatnode[i].name==room_class)
		{
			location='/index02.shtml?'+chatnode[i].id;
		}
	}
}

/***********************************************************
显示节点导航条
***********************************************************/
function showname(location_no)
{
	
	var str = "";
	var iType=0;	//根节点
	var stnode=null;
	if (location_no=="0") return;
	for(i = 0; i < chatnode.length; i ++)
	{	
		if (chatnode[i].id==location_no)
		{
			if (chatnode[i].pid!="0") iType=1;//子节点
			stnode	= chatnode[i];
			break;
		}
	}
	
	if (iType==1)
	{
		for(i = 0; i < chatnode.length; i ++)
		{	
			if (chatnode[i].id==stnode.pid)
			{
				str = "&nbsp;>&nbsp;<a href='index02.shtml?"+chatnode[i].id+"'>"+chatnode[i].name+"</a>";
				break;
			}
		}
	}
	if (stnode!=null)
		document.write(str,"&nbsp;>&nbsp;",stnode.name);
}


var focusok=false; 
if (navigator.appName == "Netscape") {focusok=true;} 

vers = navigator.appVersion; 
if (navigator.appName == "Microsoft Internet Explorer") 
{pos = vers.lastIndexOf('.');vers = vers.substring(pos-1,vers.length);} 
proper_version = parseFloat(vers);  
if(proper_version>=5){focusok=true;} 

var sColor="#ffffff";
function sc2()
{
if   (sColor=="#ffffff") sColor="#F8F8F8";
else sColor="#ffffff";
document.write("<tr bgcolor="+sColor+">");
}

/***********************************************
nodeID,指节点的ID
iCount,指显示的条数
node,指是否2层节点1 ：是， 0 ：否
***********************************************/
function ShowChatRoomList(nodename,iCount,node)
{
	var i;
	var j;
	var uc;
	var iListCount;
	var nodeID;
	findlist=new Array();
	nodelist=new Array();
	
//获取节点ID
	for(j=0;j<chatnode.length;j++)
	{
		if (chatnode[j].name==nodename)
		nodeID = chatnode[j].id;
	}
	
//获取所有子node列表,如果没有,就传进来的节点
	if (node==1)
	{
		for(j=0;j<chatnode.length;j++)
		{
			if (chatnode[j].pid==nodeID)
			nodelist[nodelist.length] = chatnode[j].id;
		}
	}
	else
		nodelist[nodelist.length] = nodeID;
	
//获取节点的所有房间
	for(i = 0; i < chatroom.length; i ++)
	{	
		for(j=0;j<chatnode.length;j++)
		{
			if (chatroom[i].pid==nodelist[j])
			{
				findlist[findlist.length] = i;
				break;
			}
		}
	}

	if (iCount>findlist.length) iCount = findlist.length;
	
//显示在线人数120以下排名最高的房间
	for (i=0;i<iCount; i++)
	{
		for (var j=i+1;j<findlist.length; j++)
		{
			if ((chatroom[findlist[i]].usercount >  120)
			|| ((chatroom[findlist[i]].usercount <  chatroom[findlist[j]].usercount)
			&& (chatroom[findlist[j]].usercount <  120)))
			{
				uc = findlist[i];
				findlist[i] = findlist[j];
				findlist[j] = uc;
			}
		}
	}
	
	for (var j=0;j<iCount; j++)
	{
		document.write("<li><a href=# onClick=\"chat_redirect('",chatroom[findlist[j]].host,"','",chatroom[findlist[j]].port+"','",chatroom[findlist[j]].loca,"', '",chatroom[findlist[j]].roomtype,"');\" class=title>"+chatroom[findlist[j]].name+"&nbsp;&nbsp;("+chatroom[findlist[j]].usercount+"人)</a><script>showRoomType('"+chatroom[findlist[j]].roomtype+"');</script></li>");
	}	
}


/***********************************************
查找某节点在线人数
***********************************************/
function onlinecount(nodename)
{
	var j;
	for(j=0;j<chatnode.length;j++)
	{
		if (chatnode[j].name==nodename)
		{
			document.write(chatnode[j].usercount);
		}
	}
	
}

/***********************************************************
显示房间类型
***********************************************************/
function showRoomType(roomtype)
{
	if (roomtype==1024)
		document.write("<img src=\"http://img.tencent.com/chat_icon/s.gif\" width=16 height=16 border=0>");
	else if (roomtype==2048)	
		document.write("<img src=\"http://img.tencent.com/chat_icon/v.gif\" width=16 height=16 border=0>");

	return 0;
}	
