// 泅 巩辑(document)客 包访 ///
LOGMAX = 60;
connected = 0;
BUFFERLEN = 500
chatFrame=parent.frames["main"];

//header 包访
chat_header = "<table border=0 width=100% cellspacing=3><tr><td align=center style='color:#790000'>发布不健康的内容时可能受到法律制裁,</td></tr><tr><td align=center style='color:#FF0101'> 新浪游戏管理员不会公开自己的身份.</td></tr><tr><td align=center style='color:#790000'>当前web聊天服务是beta测试中.</td></tr></table><table border=0 width=100% cellspacing=3><tr><td height=10></td></tr><tr><td align=center><iframe src='/banner/index2.asp?part=chat_in&SubPart=&game=' width='468' height='60' name='banner2' frameborder=0 scrolling=no></iframe></td></tr><tr><td height=10></td></tr></table>"
oper_menu_header = "<img src=\"/chat/img/chat/r_ic0.gif\" alt='房主菜单' style='cursor:hand' onclick='open_operMenu();'>";

RNAME_FACE_CHANGE = 0x002
RNAME_BODY_CHANGE = 0x004

my_def_color = "#000000";

//在/applet/function.js中被重定义
function J_openWin(url){
	try
	{
		var targ_win = window.open(url,"","resizable=1,scrollbars=1,location=0,toolbar=0,diretories=0,status=0,menubar=0");
		return targ_win;
	}
	catch (x)
	{
	}
}

//在/applet/header.js中被重定义，有改动
function msgSend(msg){
	try
	{
		//alert(msg);
		chatApplet.send(msg);		
	}
	catch (x)
	{
	}
}

//在/applet/function.js中被重定义
function set_memo_option(check_option) {
	try
	{
		var msg = "REALNAME m="+check_option;
		msgSend(msg);
	}
	catch (x)
	{
	}
}

//在/applet/function.js中被重定义，有改动
function init_memo_image(param_memo_image) {
	try
	{
		memo_image = param_memo_image;
		if ( memo_init_msg != "" ) {
			swap_memo_image("1",memo_init_msg);
			memo_init_msg = "";
		}
	}
	catch (x)
	{
	}
}

//在/applet/function.js中被重定义，有改动
function swap_memo_image(type,desc) {
	try
	{
		if ( type == "1" ) {
			memo_image.src="/img/footer/message1.gif";
			memo_image.alt=desc;
		}
		else {
			memo_image.src="/img/footer/message.gif";
			memo_image.alt="";
		}
	}
	catch (x)
	{
	}
}


function IsFunction(targ_obj) {
	return ( typeof(targ_obj) == "object" || typeof(targ_obj) == "function" )
}

function init_msgcolor() {
	try
	{
		this.join 	= '#005AB5';
		this.part 	= '#005AB5';
		this.kick	= '#005AB5';
		this.op 	= '#005AB5';
		this.deop	= '#005AB5';
		this.topic 	= '#005AB5';
		this.quit 	= '#005AB5';
		this.join 	= '#005AB5';
		this.set 	= '#005AB5';
		this.error 	= '#005AB5';
	}
	catch (x)
	{
	}
}

function writeTest(msg){
	testWin.insertAdjacentHTML("beforeEnd",msg+"</font><br>");
	var tmp=testWin.scrollHeight-testWin.clientHeight;
	if (tmp >0)
		testWin.scrollTop=tmp;
}

function write_and_log(channel,msg,log_msg) {
	try
	{
		write(channel,msg);
		make_log(channel,log_msg);
	}
	catch(x)
	{
	}
}

function write(channel,msg){
	try
	{
		var chan_type = channel.substring(1,2), targ_obj = (chan_type != "1" ? chatWin[channel] : dateWin[channel] ), targ_obj2 = (chan_type != "1" ? chatWin[channel] : dateWin[channel].main_frame );
		if ( typeof(targ_obj) != "object" )
			return;
		else if ( typeof(targ_obj2.msg_frame) != "object" )
			return;
		var isend = ( targ_obj2.msg_frame.scrollTop+targ_obj2.msg_frame.clientHeight == targ_obj2.msg_frame.scrollHeight || targ_obj2.msg_frame.clientHeight > targ_obj2.msg_frame.scrollHeight  ? true : false );
		targ_obj2.msg_frame.insertAdjacentHTML("beforeEnd",msg);
		isend = true;
		if ( isend ) 
			scrollEnd(channel);
	}
	catch (x)
	{
	}
}

function scrollEnd(channel){
	try
	{
		var chan_type = channel.substring(1,2), targ_obj = (chan_type != "1" ? chatWin[channel] : dateWin[channel].main_frame );
		if ( targ_obj.msg_frame.scrollHeight )
			targ_obj.msg_frame.scrollTop=targ_obj.msg_frame.scrollHeight;
	}
	catch (x)
	{
	}
}

function make_log(channel,log_msg) {
	try
	{
		var chan_type = channel.substring(1,2), targ_obj = ( chan_type != "1" ? chatWin[channel] : dateWin[channel] );
		if ( typeof(targ_obj) != "object" || typeof(targ_obj.log) == "undefined" )
			return;
		log_msg = log_msg.replace(/&nbsp;/g," ");
		targ_obj.log[targ_obj.log_index++] = log_msg;
		if ( targ_obj.log_index >= LOGMAX )
			targ_obj.log_index = 0;
	}
	catch(x)
	{
	}
}


function code_to_info(code) {
	try
	{
		//if ( code.substring(1,2) == 0 )
		this.age = ( User.user_id == "viceboss" ? Number(code.substring(6,9)) : "非公开" );
		this.gender = ( code.substring(2,3) == 0 ? ( code.substring(9,10) == 1 ? "男性" : "女性" ) : "非公开" );
		this.job = ( code.substring(3,4) == 0 ? code_to_job(code.substring(10,11)) : "非公开" );
		this.intention = code_to_intention(code.substring(11,12));
		this.region = (( code.substring(5,6) == 0 || User.user_id == "viceboss" ) ? code_to_region(code.substring(12,14)) : "非公开" );
	}
	catch(x)
	{
	}
}


function new_info(userinfo) {
	try
	{
		for(more = 0 ; calbyte(userinfo.substring(0,more)) < 10 && more < 10; more++);
		code = userinfo.substring(more);
		for ( --more ; userinfo.charAt(more) == "." ;more--);
		more++;
		this.realname = ( code.substring(0,1) == 0 || User.user_id == "viceboss" ? userinfo.substring(0,more) : "不公开" );
		var temp_code = new code_to_info(code);
		this.age=temp_code.age;
		this.gender=temp_code.gender;
		this.job=temp_code.job;
		this.intention=temp_code.intention;
		this.region=temp_code.region;
		if (code.length > 19 ) {
			code = code.substring(19);
			more = code.indexOf(",");
			channel = ( more == -1 ? code : code.substring(0,more));
			this.position = get_position(channel);
			this.channel = channel;
		}
		else
			this.position = "等待室";
	}
	catch (x)
	{
	}
}


function user(){
	try
	{
		this.user_id='';
		this.nick='';
		this.oper=0;
		this.user_char='';
		this.user_info='';
		this.profile_msg = '';
	}
	catch (x)
	{
	}
}


function get_all_info(user,info) {
	try
	{
		this.user = new new_user(user);
		this.info = new new_info(info);
	}
	catch (x)
	{
	}
}

function msgWho() {
	try
	{
		if ( typeof(target_who) == "undefined " || typeof(who_list) == "undefined") 
			return;
		var parv = new parse_msg(reply.msg), i = who_list.length;
		who_list[i] = new get_all_info(parv.msg[0],parv.msg[1]);
	}
	catch (x)
	{
	}
}


function msgNick(){
	try
	{
		var newNick=reply.msg, nick_User = new new_user(reply.from);
		if ( newNick == "聊天名" )
			newNick = nick_User.user_id;
		if (nick_User.user_id == User.user_id) 
			User.nick=newNick;
		var nickmsg = msgHtml(nickHtml(nick_User.nick)+"将聊天名修改为 "+nickHtml(newNick)+"！"), log_msg = nick_User.nick+"!"+nick_User.user_id+" 聊天名 更改 -> "+newNick;
		for ( channel in dateWin ) {
			var targ_nick = ( dateWin[channel].my_id.user_id == nick_User.user_id ? dateWin[channel].main_frame.my_nick : ( dateWin[channel].oppo_id.user_id == nick_User.user_id ? dateWin[channel].main_frame.oppo_nick : "" ));
			if ( typeof(targ_nick) == "object" ) {
				targ_nick.innerHTML = "<u>"+newNick+"</u>";
				write_and_log(channel,nickmsg,log_msg);
			}
		}
		for (channel in chatWin){
			if ( typeof(chatWin[channel].user[nick_User.user_id]) == "object" ) {
				chatWin[channel].user[nick_User.user_id].nick = newNick;
				write_and_log(channel,nickmsg,log_msg);
				if ( typeof(chatWin[channel].user_frame) == "object" ) 
					chatWin[channel].user_frame.change_nickname(nick_User.user_id,newNick);
			}
			if (nick_User.user_id == User.user_id) 
				chatWin[channel].char_frame.my_nick.innerHTML=User.nick+"("+User.user_id+")";
		}
	}
	catch (x)
	{
	}
}

function club_member_list(club_id, page_num, page_size) {
	try
	{
		if( club_id != "" ) {
			msgSend("forum f=@"+club_id+",n="+page_num+",p="+page_size);
		}
	}
	catch (x)
	{
	}
}

function nickHtml(nick) {
	return "<font color='#005AB5'>"+nick+"</font>";
}

function msgForum2(id, page_num, page_size, targetFrame) {
	try
	{
		if( id != "" ) {
			msgForum_target2 = targetFrame;
			forum_all_info_list = new Array();
			msgSend("forum f="+id+",t=0,n="+page_num+",p="+page_size);
			var html="<table border='0' cellpadding='0' cellspacing='0' width=100% align=left>";
		}
	}
	catch (x)
	{
	}
}

function msgForumList2() {
	try
	{
		if ( typeof(forum_all_info_list) == "undefined") 
			return;
		var parv = new parse_msg(reply.msg), i = forum_all_info_list.length;
		forum_all_info_list[i] = new get_all_info(parv.msg[0],parv.msg[1]);
	}
	catch (x)
	{
	}
}

function totalusers() {
	try
	{
		msgSend("users");		
	}
	catch (x)
	{
	}
}


//在/applet/header.js中被重定义，改动较大

function watch_friend2() {
	try
	{
		msgSend("watch L");		
	}
	catch (x)
	{
	}
}


function clear(channel){
	try
	{
		var chan_type = channel.substring(1,2), target_Frame=( chan_type == "1" ? dateWin[channel].main_frame : chatWin[channel] );
		if ( typeof(target_Frame) != "object" )
			return;
		else 
			target_Frame = target_Frame.msg_frame;
		var msg = ( chan_type == "1" ? "" : chat_header ) + msgHtml("画面已清屏.");
		target_Frame.innerHTML=  msg;
	}
	catch (x)
	{
	}
}

function send_do(form) {
	try
	{
		if ( typeof(form) != "object" )
			return;
		var msg = form.msg.value, to = form.to.value, face = form.f.value, channel = form.channel.value, chan_type = channel.substring(1,2), targ_obj = (chan_type != "1" ? chatWin[channel] : dateWin[channel] )
		if ( typeof(targ_obj) != "object" )
			return;
		else if ( chan_type == "1" && targ_obj.users < 2 )
			return;
		else if(msg.length ==0){
			targ_obj.main_frame.alert ("对不起，发言请先输入内容！");
			return;
		}
		var parv = new parse_msg(msg);
		form.msg.value='';
		form.msg.focus();
		switch (parv.msg[0]) {
		case "/n" :
		case "/别名" :
			if ( parv.msg.length < 2 ) {
				var err_msg = "<font color="+msgcolor.error+">命令形式有误，更改聊天名时<b>\"/绰号 聊天名\"</b> 或者 <b>\"/n 聊天名\"</b> 来 输入即可</font>";
				write(channel,msgHtml(err_msg));
			}
			else if ( parv.msg[1] == "聊天名" ) {
				var err_msg = "<font color="+msgcolor.error+">聊天名不能改成聊天名.</font>";
				write(channel,msgHtml(err_msg));
			}
			else 
				msgSend("NICK "+parv.msg[1]);
			break;
		case "/自我介绍" :
			sendProfile(channel);
			break;
		default  :
			if ( !flood_cnt_inc() )
				return;
			msg=SpaceToNbsp(disableTag(msg));
			/*var cubic_num = Math.random();
			cubic_num = Math.ceil(cubic_num*6);
			msg=msg.replace(/\/林荤困/g,"/林荤困"+cubic_num);*/
			var from="<b>" + ( to != "" ? "->"+to : User.nick ) + "</b>", target = ( to != "" ?  id_convert(to) : channel ), html = privmsgHtml(from, ( chan_type == "1" ? get_small_head(dateWin[channel].my_id.user_char) : targ_obj.user[User.user_id].user_char ) , face+targ_obj.mycolor, TransMsg(msg)), log_msg = User.user_id+"!"+User.nick+" : "+msg;
			write_and_log(channel,html,log_msg);
			msg="PRIVMSG "+target+" :"+"1"+face+targ_obj.mycolor+"?"+msg;
			msgSend(msg);
		}
	}
	catch (x)
	{
	}
}


function makeProfile2HTML(user_id,user_nick,user_char,etc_info,profile_msg, channel) {
	var chan_type = channel.charAt(1);
	etc_info = new new_info(etc_info);
	user_char=number_convert(user_char);
	user_char=user_char.split("|");
	var profile_char = "<div id='profile_char' style='position:relative; left:0px; top:0px; width=75px; height:125px; overflow:hidden'>"+make_all_char_html(user_char)+"</div>"
	if ( chan_type == "1" ) {
		var html = "<table width=100% cellspacing=2 cellpadding=0><tr><td align=center><table border='0' cellspacing='0' cellpadding='0' bgcolor='F2F7E2'><tr><td width='27' rowspan='3' valign=top><img src='/chat/window/1chat/img/info_topl.gif'></td><td colspan='2' height=5 background='/chat/window/1chat/img/info_topbg.gif'></td><td width='25' rowspan='3'  valign=top align=right><img src='/chat/window/1chat/img/info_topr.gif'></td></tr>";
		html += "<tr bgcolor='#F2F7E2'><td rowspan='3' width=80>"+profile_char+"</td><td height=14 valign=bottom><img src='/chat/window/1chat/img/info_ti.gif'></td></tr><tr><td height=7></td></tr><tr><td background='/chat/window/1chat/img/info_l.gif' width='27'></td><td><table width='190' border='0' cellspacing='1' cellpadding='0' style='table-layout:fixed'>";
		html += "<tr height='13' style='padding:2;' bgcolor='#E0ECBC'><td style='color:#005AB5;' width='60'>ID</td><td width='130'>"+user_id+"</td></tr>";
		html += "<tr height='13' style='padding:2;' bgcolor='#E0ECBC'><td style='color:#005AB5;'>聊天名</td><td>"+user_nick+"</td></tr>";
		html += "<tr height='13' style='padding:2;' bgcolor='#E0ECBC'><td style='color:#005AB5;'>性别</td><td>"+etc_info.gender+"</td></tr>";
		html += "<tr height='13' style='padding:2;' bgcolor='#E0ECBC'><td style='color:#005AB5;'>年龄</td><td>"+( etc_info.age != "不公开" ? etc_info.age + "岁" : etc_info.age )+"</td></tr>";
		html += "<tr height='13' style='padding:2;' bgcolor='#E0ECBC'><td style='color:#005AB5;'>目的</td><td>"+etc_info.intention+"</td></tr>";
		html += "<tr style='padding:2;' bgcolor='#E0ECBC'><td valign=top style='color:#005AB5;'>个人介绍</td><td>"+profile_msg+"</td></tr></table></td><td background='/chat/window/1chat/img/info_r.gif' width='25'></td></tr><tr> <td><img src='/chat/window/1chat/img/info_dwl.gif'></td><td colspan='2' background='/chat/window/1chat/img/info_dwbg.gif'></td><td width='25'><img src='/chat/window/1chat/img/info_dwr.gif'></td></tr></table></td></tr></table>";
	}
	else {
		var html = "<center><table width=400 border=0 cellspacing=0 cellpadding=0><tr><td rowspan=2 height=137 width=95 align=center>";
		html+= profile_char+"</td><TD valign=top><IMG src='/chat/img/mine/_ti.gif'></td>";
		html+= "</tr><tr><td align=center valign=top><table width=100% border=0 cellpadding=0 cellspacing=2 style='table-layout:fixed'>";
		html+= "<tr height='20' style='padding:3;' bgcolor=#E8F5F5><td width=54% colspan=2><font color=#345656>聊天名 :</font> "+user_nick+"</td><td width=46%><font color=#345656>ID :</font> "+user_id+"</td></tr>";
		html+= "<tr height='20' style='padding:3;' bgcolor=#E8F5F5><td width=27%><font color=#345656>性别 :</font> "+etc_info.gender+"</td><td width=27%><font color=#345656>年龄 :</font> "+( etc_info.age != "不公开" ? etc_info.age + "岁" : etc_info.age )+"</td><td width=50%><font color=#345656>连接地区 :</font> "+etc_info.region+"</td></tr>";
		html+= "<tr height='20' style='padding:3;' bgcolor=#E8F5F5><td colspan=2><font color=#345656>目的 :</font> "+etc_info.intention+"</td><td><font color=#345656>职业 :</font> "+etc_info.job+"</td></tr>";
		html+= "<tr style='padding:3;' bgcolor=#E8F5F5 ><td colspan=3><font color=#345656>个人介绍</font></br>&nbsp;"+profile_msg+"</td></tr>";
		html+= "</table></td></tr></table></center>";
	}
	return html;
}

function open_tag(msg) {
	msg = msg.replace(/&ltimg(.*)&gt/gi,"<img$1>");
	msg = msg.replace(/&lta(.*)&gt(.*)&lt\/a&gt/gi,"<a$1>$2</a>");
	msg = msg.replace(/&nbsp;/gi," ");
	return msg;
}

function TransMsg(msg){
	msg = open_tag(msg);
	var suffix=new Array(), j=0, tmp='', message='';
	for(var i=0; i<= msg.length-3;i++){
		if(msg.substring(i,i+1)=="/"){
			switch(msg.substring(i,i+3)){
				case "/阵/":
					tmp="</b>"+tmp;
					break;
				case "/期/":
					tmp="</i>"+tmp;
					break;
				case "/底/":
					tmp="</u>"+tmp;
					break;
				case "/1/":
				case "/2/":
				case "/3/":
				case "/4/":
				case "/5/":
				case "/6/":
					tmp="</font>"+tmp;
					break;
				case "/./":
					suffix[j]=tmp;
					tmp="";
					j++;
					break;
			}
		}
	}

	suffix[j]=tmp;
	
	msg=msg.replace(/\/柳\//g,"<b>");
	msg=msg.replace(/\/期\//g,"<i>");
	msg=msg.replace(/\/底\//g,"<u>");
	msg=msg.replace(/\/1\//g,"<font size=1>");
	msg=msg.replace(/\/2\//g,"<font size=2>");
	msg=msg.replace(/\/3\//g,"<font size=3>");
	msg=msg.replace(/\/4\//g,"<font size=4>");
	msg=msg.replace(/\/5\//g,"<font size=5>");
	msg=msg.replace(/\/6\//g,"<font size=6>");
	var tmp=msg.split("/./");
	for(i=0; i<=j; i++){
		message+=tmp[i]+suffix[i];
	}
	return message;
}


function privmsgHtml(from, charac, option, msg){
	try
	{
		var html, f=option.substring(0,1), color=option.substring(1), charac_info=number_convert(charac), charac=charac_info.split("|"), face;
		switch(f){
			case "A":
				face="宋体";
				break;
			case "B":
				face="楷书_GB2312";
				break;
			case "C":
				face="黑体";
				break;
			case "D":
				face="隶书";
				break;
			case "E":
				face="Arial";
				break;
			case "F":
				face="Courier New";
				break;
			case "G":
				face="Fixedsys";
				break;
			case "H":
				face="Impact";
				break;
			case "I":
				face="Tahoma";
				break;
			case "J":
				face="Times New Roman";
				break;
			case "K":
				face="Verdana";
				break;
		}
		html="<table width='100%' align=center cellspacing=0 cellpadding=0 align=center style='TABLE-LAYOUT:fixed; word-break:break-all'>\
					<tr style='padding:2 1 2 0;'>\
						<td width=40 valign=middle align=center>"+make_small_char_html(charac,-1)+"</td>\
						<td width=90 align=center style='color:"+color+"'>"+from+"</td>\
						<td width=15 align=center style='color:"+color+"'>?</td>\
						<td><font face='"+face+"' color='"+color+"'>"+msg+"</font></td>\
					</tr></table>";
		//alert(html);
		return html;		
	}
	catch (x)
	{
	}
}

function msgHtml(msg) {
	return "<table align=center cellspacing=0 cellpadding=0 align=center><tr width='500' height=25><td align='center'><font color='#9B0000'><b>"+msg+"</b></font></td></tr></table>";
}

function msgMode(channel) {
	try
	{
		msgSend("MODE "+channel);		
	}
	catch (x)
	{
	}
}


function chat_start(channel) {
	try
	{
		chatWin[channel].msg_frame.innerHTML=chat_header;
	}
	catch (x)
	{
	}
}


function make_nicklist_html(channel,user_info) {
	try
	{
		var html;
		html="<span id='userid_"+user_info.user_id+"'><table width=100%><tr><td width='29'>";
		html+="<span id='userchar_"+user_info.user_id+"'>" + make_small_char_html(user_info.user_char2,user_info.oper) + "</span></td>";
		html+="<td "+u_line_dec+" onclick=\"show_user_info('"+user_info.user_id+"')\" style=\"cursor:hand;\"><span id='usernick_"+user_info.user_id+"'>" + user_info.nick+"</span>("+user_info.user_id+")</td>";
		html+="<tr><td background='/Chat/img/chat/dot.gif' height='1' colspan='2'></td></tr></table></span>";
		return html
	}
	catch(x)
	{
	}
}

function make_datelist(channel,list_msg){
	try
	{
		var parv = new parse_msg(list_msg);
		if ( typeof(dateWin[channel]) == "undefined" )
			return;
		for(var i=0;i<parv.msg.length;i++){
			var real_id=get_userid(parv.msg[i]);
			if ( real_id == User.user_id ) 
				dateWin[channel].my_id = new new_user(parv.msg[i]);
			else
				dateWin[channel].oppo_id = new new_user(parv.msg[i]);
			dateWin[channel].users++;
		}
	}
	catch (x)
	{
	}
}

function update_tolist(channel){
	try
	{		
		to = chatWin[channel].send_frame.to;
		to.length = chatWin[channel].users;
		if ( to.length > 1 ) {
			j = 1;
			for (user_id in chatWin[channel].user){
				if(user_id!=User.user_id){
					to.options[j].value=user_id;
					to.options[j].text=user_id;
					j++;
				}
			}
		}
	}
	catch (x)
	{
	}
}

function update_user_stat(channel) {
	try
	{
		if ( typeof(chatWin[channel].user_frame) == "object" ) 
			chatWin[channel].user_frame.users.innerHTML=chatWin[channel].users+"/"+chatWin[channel].usermax;
	}
	catch (x)
	{
	}
}

function add_nick(channel,userinfo){
	try
	{
		if ( typeof(chatWin[channel]) == "undefined" )
			return;
		var user_id = get_userid(userinfo);
		if ( typeof(chatWin[channel].user[user_id]) != "object" ) 
			chatWin[channel].users++;
		chatWin[channel].user[user_id]=new new_user(userinfo);
		chatWin[channel].can_profile = 1;
		if ( typeof(chatWin[channel].user_frame) == "object" ) {
			html = make_nicklist_html(channel,chatWin[channel].user[user_id]);
			chatWin[channel].user_frame.deop_list.insertAdjacentHTML("beforeEnd",html);
			update_user_stat(channel);
		}
		if ( typeof(chatWin[channel].send_frame) == "object" )
			update_tolist(channel);
	}
	catch (x)
	{
	}
}

function del_nick(channel,userinfo){
	try
	{
		if ( typeof(chatWin[channel]) == "undefined" )
			return;
		var user_id=get_userid(userinfo);
		if ( typeof(chatWin[channel].user[user_id]) == "object" ) {
			chatWin[channel].users--;
			delete chatWin[channel].user[user_id];
			if ( typeof(chatWin[channel].user_frame) == "object" ) {
				chatWin[channel].user_frame.delete_user(user_id);
				update_user_stat(channel);
			}
			if ( typeof(chatWin[channel].send_frame) == "object" )
				update_tolist(channel);
		}
	}
	catch (x)
	{
	}
}

function make_memo_frame(win, targetFrame, closed) {
	try
	{
		this.win = win;
		this.frame=targetFrame;
		this.closed=closed;
	}
	catch (x)
	{
	}
}


function chan_modify(channel,modify_form) {
	try
	{
		if ( chatWin[channel].topic != modify_form.topic.value )
			modifyTopic(channel,modify_form.topic.value);
		if ( chatWin[channel].noticechan != modify_form.welcome.value )
			modifyNoticeChan(channel,modify_form.welcome.value);
		var msg_mode = "", msg_change = "", msg_change2 = "", msg_param = "", msg_kick_param = "", msg_kick_reason = "", temp_max_user = ( modify_form.max_user.value == "0" ? "无限制 " : modify_form.max_user.value );
		if ( chatWin[channel].usermax != temp_max_user ) {
			msg_change = ( modify_form.max_user.value == "0" ? "-" : "+" );
			msg_param += " "+modify_form.max_user.value;
			if ( msg_change != msg_change2 ) {
				msg_mode += msg_change
				msg_change2 = msg_change;
			}
			msg_mode += "l";
		}
		if ( modify_form.key.value != chatWin[channel].key ) {
			msg_change = ( modify_form.key.value == "" ? "-" : "+" );
			msg_param += " " + ( modify_form.key.value == "" ? chatWin[channel].key : modify_form.key.value );
			if ( msg_change != msg_change2 ) {
				msg_mode += msg_change
				msg_change2 = msg_change;
			}
			msg_mode += "k";
		}
		if ( channel.substring(0,4) == "#c31" ) {
			if ( modify_form.music_url.value != chatWin[channel].music_addr ) {
				msg_change = ( modify_form.music_url.value == "" ? "-" : "+" );
				msg_param += " "+ ( modify_form.music_url.value == "" ? chatWin[channel].music_addr : modify_form.music_url.value );
				if ( msg_change != msg_change2 ) {
					msg_mode += msg_change
					msg_change2 = msg_change;
				}
				msg_mode += "M";
			}
		}
		if ( typeof(modify_form.memberonly) == "object" ) {
			var memberonly = modify_form.memberonly.checked;
			if ( memberonly != chatWin[channel].memberonly ) {
				msg_change = ( memberonly ? "+" : "-" );
				if ( msg_change != msg_change2 ) {
					msg_mode += msg_change
					msg_change2 = msg_change;
				}
				msg_mode += "F";
			}
		}
		
		if ( modify_form.op_list.value != "" && modify_form.op_modify.value != "" ) {
			var user_id = " "+id_convert(modify_form.op_list.value);
			switch(modify_form.op_modify.value) {
			case "0":
				msg_change = "-";
				msg_param += " "+user_id;
				if ( msg_change != msg_change2 ) {
					msg_mode += msg_change
					msg_change2 = msg_change;
				}
				msg_mode += "o";
				break;
			case "2":
				msg_change = "+";
				msg_param += " *!"+user_id+"@*.*.*.*";
				if ( msg_change != msg_change2 ) {
					msg_mode += msg_change
					msg_change2 = msg_change;
				}
				msg_mode += "b";
				msg_kick_reason = "002";
			case "1":
				msg_kick_param += ","+user_id;
				if ( msg_kick_reason == "" )
					msg_kick_reason = "001";
				break;
			}
		}
		if ( modify_form.deop_list.value != "" && modify_form.deop_modify.value != "" ) {
			var user_id = id_convert(modify_form.deop_list.value);
			switch(modify_form.deop_modify.value) {
			case "0":
				msg_change = "+";
				msg_param += " "+user_id;
				if ( msg_change != msg_change2 ) {
					msg_mode += msg_change
					msg_change2 = msg_change;
				}
				msg_mode += "o";
				break;
			case "2":
				msg_change = "+";
				msg_param += " *!"+user_id+"@*.*.*.*";
				if ( msg_change != msg_change2 ) {
					msg_mode += msg_change
					msg_change2 = msg_change;
				}
				msg_mode += "b";
				msg_kick_reason = "002";
			case "1":
				msg_kick_param += ","+user_id;
				if ( msg_kick_reason == "" )
					msg_kick_reason = "001";
				break;
			}
		}
		if ( msg_mode != "" ) 
			msgSend("MODE "+channel+" "+msg_mode+msg_param);
		if ( msg_kick_param != "" )
			msgSend("KICK "+channel+" "+msg_kick_param.substring(1)+" "+msg_kick_reason);
	}
	catch (x)
	{
	}
}

function modifyTopic(channel,newTopic) {
	try
	{
		msgSend("TOPIC "+channel+" :"+newTopic);
	}
	catch (x)
	{
	}
}
function modifyNoticeChan(channel,newNoticeChan) {
	try
	{
		msgSend("NOTICECHAN "+channel+" :"+newNoticeChan);
	}
	catch (x)
	{
	}
}


function getdateWin() {
	try
	{
		var channel = "#100"+id_convert(appletFrame.User.user_id), targ_obj = dateWin[channel];
		return targ_obj;
	}
	catch (x)
	{
	}
}

function init_category_list(room_cnt, user_cnt, male_cnt, female_cnt) {
	try
	{
		this.user_cnt = user_cnt;
		this.room_cnt = room_cnt;
		this.male_cnt = male_cnt;
		this.female_cnt = female_cnt;
	}
	catch (x)
	{
	}
}

function school_add(school_index) {
	try
	{
		msgSend("forum +"+school_index);
	}
	catch (x)
	{
	}
}

function msgKill(kill_msg) {
	try
	{
		alert(kill_msg);
		top.location.href="/";
	}
	catch (x)
	{
	}
}
