www.gusucode.com > SiteEngine(建站引擎) 7.0 个人免费版源码程序 > bicq/system/gui/guest2.js

    var GuestMySelfUID=0;				/* 自身UID */
var GuestGlobalAccountUID=0;			/* 激活窗口的UID */
var GuestAccountActive=0;			/* 帐号是否激活 */
var GuestActiveCounter=0;			/* 帐号激活计数器 */
var GuestActiveCounterFlag=0;			/* 计数器操作标志 */
var GuestAccountTimerKey=null;			/* 帐号激活器ID */
var GuestAccountTimerCallBack="";		/* 定时器到时回调 */
var GuestRefreshTimeCount=5;			/* 刷新间隔(秒) */
var GuestKeepRefreshTimer=null;			/* 保持连接计时器 */
var GuestAccountLoginTestCounter=0;		/* 帐号登录计数器 */
var GuestMembersOlArr=new Array();		/* 用户在线记录 */
var GuestChatInfoCardArr=new Array();		/* 用户名片资料 */
var GuestAccountPetNameArr=new Array();		/* 用户昵称 */
var GuestChatInfoReaderArr=new Array();		/* 用户资料读取标志 */
var GuestChatMessageCounterArr=new Array();	/* 用户消息计数器 */
var GuestChatMessageHistoryArr=new Array();	/* 用户聊天记录 */
var GuestChatMessageHistoryTmp=new Array();	/* 用户聊天记录缓存 */
var GuestTheMainURL=(SETTINGS['ifajax']=='1' ? SETTINGS['ajax_url'] : SETTINGS['home_url']+"/guest.php");

var GuestChatHtml="<div class=\"GuestChat_Main_Layer\" onClick=\"GuestChatHideFacial('ReplaceUID');\" onKeydown=\"doHotKeySendGuestMessage(event,'ReplaceUID');\">"
	+"<div class=\"GuestChat_Header\" style=\"background-image: url('"+SETTINGS['home_url']+"/images/skins/bicq/chat_bg.gif');\"></div>"
	+"<div class=\"GuestChat_AD\" id=\"GuestChat_ClientAD_ReplaceUID\"><img src=\""+SETTINGS['home_url']+"/index.php?action=ad\" width=\"238\" height=\"38\" border=\"0\"></div>"
	+"<div class=\"GuestChat_Face\"><img id=\"GuestChat_Face_ReplaceUID\" src=\""+SETTINGS['home_url']+"/images/face/1-1.gif\" width=\"32\" height=\"32\" border=\"0\"></div>"
	+"<div class=\"GuestChat_UID\">BICQ:<span id=\"GuestChat_UID_ReplaceUID\">ReplaceUID</span></div>"
	+"<div class=\"GuestChat_PetName\">昵称:<span id=\"GuestChat_PetName_ReplaceUID\">ReplaceUID</span></div>"
	+"<div class=\"GuestChat_InfoBar\" style=\"background-image: url('"+SETTINGS['home_url']+"/images/skins/bicq/guest_chat_info_bar.gif');\"></div>"
	+"<div class=\"GuestChat_InfoBarWord\">对方BICQ形象</div>"
	+"<div class=\"GuestChat_UserShow\"><img id=\"GuestChat_UserShow_ReplaceUID\" src=\""+SETTINGS['home_url']+"/images/show.jpg\" width=\"140\" height=\"226\" border=\"0\"></div>"
	+"<div class=\"GuestChat_InfoCard\"><img src=\""+SETTINGS['home_url']+"/images/skins/bicq/guest_chat_info_card.gif\" width=\"141\" height=\"108\" border=\"0\"></div>"

	+"<div class=\"GuestChat_Box_1\"></div>"
	+"<div class=\"GuestChat_Box_2\" style=\"background-image: url('"+SETTINGS['home_url']+"/images/skins/bicq/chat_bar_bg.gif');\"></div>"

	+"<div class=\"GuestChat_Facial_1\"><img src=\""+SETTINGS['home_url']+"/images/skins/bicq/facial_1.gif\" border=\"0\" width=\"16\" height=\"16\" title=\"字体设置\" onClick=\"zConFontSet('ReplaceMT','ReplaceUID');\"></div>"
	+"<div class=\"GuestChat_Facial_2\"><img src=\""+SETTINGS['home_url']+"/images/skins/bicq/facial_line.gif\" border=\"0\" width=\"2\" height=\"20\"></div>"
	+"<div class=\"GuestChat_Facial_3\"><img src=\""+SETTINGS['home_url']+"/images/skins/bicq/facial_2.gif\" border=\"0\" width=\"16\" height=\"16\" title=\"插入表情\" onClick=\"GuestChatShowFacial('ReplaceUID');\"></div>"
	+"<div class=\"GuestChat_Facial_4\"><img src=\""+SETTINGS['home_url']+"/images/skins/bicq/facial_line.gif\" border=\"0\" width=\"2\" height=\"20\"></div>"
	+"<div class=\"GuestChat_Facial_5\"><img src=\""+SETTINGS['home_url']+"/images/skins/bicq/facial_3.gif\" border=\"0\" width=\"16\" height=\"16\" title=\"传送文件\" onClick=\"GuestShowSendFile('ReplaceUID');\"></div>"

	+"<div class=\"GuestChat_Messages_Content\" id=\"GuestChat_Messages_Body_ReplaceUID\"></div>"
	+"<div class=\"GuestChat_Input_Message\"><textarea id=\"GuestChat_Input_Messages_ReplaceUID\" class=\"GuestChat_Input_Textarea\"></textarea></div>"

	/* 字体设置 */
	+FontSetHTML

	/* 表情 */
	+FacialHtml

	/* 发送文件 */
	+"<div id=\"GuestChat_SendFile_Layer_ReplaceUID\" class=\"GuestChat_SendFile\" style=\"visibility:hidden;\">"
		+"<iframe name=\"GuestChat_DownFile_Frame_ReplaceUID\" style=\"display:none;\" src=\"about:blank\" width=\"0\" height=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" hspace=\"0\" vspace=\"0\"></iframe>"
		+"<iframe name=\"GuestChat_SendFile_Frame_ReplaceUID\" style=\"display:none;\" src=\"about:blank\" width=\"0\" height=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" hspace=\"0\" vspace=\"0\"></iframe>"
		+"<form method=\"post\" action=\""+SETTINGS['home_url']+"/guest.php?action=sendfile\" enctype=\"multipart/form-data\" target=\"GuestChat_SendFile_Frame_ReplaceUID\" onSubmit=\"return GuestChat_SendFile_PostCheck('ReplaceUID');\">"
			+"<input name=\"uid\" type=\"hidden\" value=\"ReplaceUID\">"
			+"<input name=\"AccountKey\" type=\"hidden\" id=\"GuestChat_SendFile_AccountKey_ReplaceUID\" value=\"\">"
			+"<div class=\"GuestChat_SendFile_Layer_1\" id=\"GuestChat_SendFile_InputObject_ReplaceUID\"><input id=\"GuestChat_SendFile_FileName_ReplaceUID\" class=\"GuestChat_SendFile_FileName\" name=\"F_Upload\" type=\"file\" size=\"12\" hidefocus></div>"
			+"<div class=\"GuestChat_SendFile_Layer_2\"><input id=\"GuestChat_SendFile_Upload_ReplaceUID\" type=\"submit\" class=\"GuestChat_Button\" style=\"background-image: url('"+SETTINGS['home_url']+"/images/skins/bicq/button.gif');\" onFocus=\"this.blur()\" value=\"传  送\" onClick=\"\"></div>"
			+"<div class=\"GuestChat_SendFile_Layer_3\"><input id=\"GuestChat_SendFile_Cancel_ReplaceUID\" type=\"button\" class=\"GuestChat_Button\" style=\"background-image: url('"+SETTINGS['home_url']+"/images/skins/bicq/button.gif');\" onFocus=\"this.blur()\" value=\"关  闭\" onClick=\"GuestChat_SendFile_Finished('ReplaceUID','3');\"></div>"
		+"</form>"
	+"</div>"

	+"<div class=\"GuestChat_Button_1\"><input id=\"GuestChat_Button_History_ReplaceUID\" type=\"button\" class=\"GuestChat_Button\" style=\"background-image: url('"+SETTINGS['home_url']+"/images/skins/bicq/button.gif');\" onFocus=\"this.blur()\" value=\"聊天记录\" onClick=\"ShowGuestChatRecordMessages('ReplaceUID');\"></div>"
	+"<div class=\"GuestChat_Button_2\"><input id=\"GuestChat_Button_Clear_ReplaceUID\" type=\"button\" class=\"GuestChat_Button\" style=\"background-image: url('"+SETTINGS['home_url']+"/images/skins/bicq/button.gif');\" onFocus=\"this.blur()\" value=\"清  屏\" onClick=\"ClearGuestChatBody('ReplaceUID');\"></div>"
	+"<div class=\"GuestChat_Button_3\"><input id=\"GuestChat_Button_Close_ReplaceUID\" type=\"button\" class=\"GuestChat_Button\" style=\"background-image: url('"+SETTINGS['home_url']+"/images/skins/bicq/button.gif');\" onFocus=\"this.blur()\" value=\"关  闭\" onClick=\"G_CloseWindow('GuestChat_ReplaceUID');\"></div>"
	+"<div class=\"GuestChat_Button_4\"><input id=\"GuestChat_Button_Send_ReplaceUID\" type=\"button\" class=\"GuestChat_Button\" style=\"background-image: url('"+SETTINGS['home_url']+"/images/skins/bicq/button.gif');\" onFocus=\"this.blur()\" value=\"发送(S)\" onClick=\"SendGuestChatMessages('ReplaceUID');\"></div>"

	+"</div>";


/* 清屏 */
function ClearGuestChatBody(UID) {
	if (confirm("确定要清屏吗?")) {
		/* 判断帐号是否激活 */
		if (GuestAccountActive==0) {
			ShowTheAlertMessages(UID,"请等待系统初始化完成。");
			/* 将初始化窗口前置 */
			if (GuestGlobalAccountUID!=null) G_ShowWindow("GuestChat_"+GuestGlobalAccountUID);
			return;
		}
		$get_("GuestChat_Messages_Body_"+UID).innerHTML="";
	}
};

function GuestShowSendFile(UID) {
	zFontSetFlag['GuestChat_'+UID]=0;
	$get_("GuestChat_FontSet_Layer_"+UID).style.visibility="hidden";
	$get_("GuestChat_SendFile_Layer_"+UID).style.visibility="inherit";
};

function GuestHideSendFile(UID) {
	zFontSetFlag['GuestChat_'+UID]=0;
	$get_("GuestChat_FontSet_Layer_"+UID).style.visibility="hidden";
	$get_("GuestChat_SendFile_Layer_"+UID).style.visibility="hidden";
};

function GuestChat_SendFile_Finished(UID,sType) {
	$get_("GuestChat_SendFile_FileName_"+UID).readOnly=false;
	$get_("GuestChat_SendFile_Upload_"+UID).disabled=false;
	$get_("GuestChat_SendFile_FileName_"+UID).value="";
	$get_("GuestChat_SendFile_InputObject_"+UID).innerHTML="<input id=\"GuestChat_SendFile_FileName_"+UID+"\" class=\"GuestChat_SendFile_FileName\" name=\"F_Upload\" type=\"file\" size=\"12\" hidefocus></div>";

	if (sType=="1") {// 传输成功
		GuestHideSendFile(UID);
		ShowTheAlertMessages(UID,"<img src=\""+SETTINGS['home_url']+"/images/info.gif\" border=\"0\" align=\"absmiddle\">&nbsp;文件传输完毕,对方将收到您发送的文件。");
	}
	else if (sType=="2") {// 文件太大
		ShowTheAlertMessages(UID,"<img src=\""+SETTINGS['home_url']+"/images/info.gif\" border=\"0\" align=\"absmiddle\">&nbsp;文件传输失败!您传输的文件太大。服务器允许传输的最大尺寸为"+SETTINGS['file_size']+"KB。");
	}
	else if (sType=="3") {// 取消传输
		GuestHideSendFile(UID);
	}
	else if (sType=="4") {// 未初始化完成
		ShowTheAlertMessages(UID,"系统未初始化完成,无法进行文件传输。");
	}
};

function GuestChat_SendFile_PostCheck(UID) {
	/* 检查是否断开连接或者未初始化完毕 */
	if (GuestCheckDoAnyThings(UID)) return false;

	var SendFileName=$get_("GuestChat_SendFile_FileName_"+UID).value;
	if (SendFileName=="") {
		alert('请选择一个要发送的文件!');
		return false;
	}
	$get_("GuestChat_SendFile_FileName_"+UID).readOnly=true;
	$get_("GuestChat_SendFile_Upload_"+UID).disabled=true;
	$get_("GuestChat_SendFile_AccountKey_"+UID).value=GetGuestUserAccountKey();
	ShowTheAlertMessages(UID,"<img src=\""+SETTINGS['home_url']+"/images/info.gif\" border=\"0\" align=\"absmiddle\">&nbsp;正在将文件传输给对方,请耐心等待。");
	return true;
};

/* 显示表情 */
function GuestChatShowFacial(UID) {
	if ($get_("Facial_GuestChat_"+UID).style.visibility!="hidden") {
		$get_("Facial_GuestChat_"+UID).style.visibility="hidden";
		return false;
	}
	FacialStatusArr['GuestChat_'+UID]=1;
	$get_("Facial_GuestChat_"+UID).style.top=123+"px";
	$get_("Facial_GuestChat_"+UID).style.visibility="inherit";

	zFontSetFlag['GuestChat_'+UID]=0;
	$get_("GuestChat_FontSet_Layer_"+UID).style.visibility="hidden";
	$get_("GuestChat_SendFile_Layer_"+UID).style.visibility="hidden";

	setTimeout("FacialStatusArr['GuestChat_"+UID+"']=0;",100);
};

/* 隐藏表情 */
function GuestChatHideFacial(UID) {
	if (FacialStatusArr['GuestChat_'+UID]==0) {
		$get_("Facial_GuestChat_"+UID).style.visibility="hidden";
	}
};

/* 过滤ID */
function ConvertGuestChatHtml(UID) {
	var RCHtml=GuestChatHtml.replace(/ReplaceUID/gi,UID);
	RCHtml=RCHtml.replace(/ReplaceMT/gi,"GuestChat");

	return RCHtml;
};

/* 获取聊天记录 */
function GuestChatSetHistoryFromRemote(UID,Mf,Mtime,Messages) {
	/* 数组初始化 */
	if (typeof(GuestChatMessageCounterArr[UID])=="undefined") GuestChatMessageCounterArr[UID]=0;
	if (typeof(GuestChatMessageHistoryTmp[UID])!="object") GuestChatMessageHistoryTmp[UID]=new Array();

	/* 记录到缓存 */
	GuestChatMessageHistoryTmp[UID][GuestChatMessageCounterArr[UID]]=Mf+"&nbsp;"+Mtime+"<br />"+Messages;
	GuestChatMessageCounterArr[UID]++;
};

/* 显示聊天记录 */
function ShowGuestChatRecordMessages(UID) {
	if (typeof(GuestChatMessageHistoryArr[UID])=="object") {
		for (var i=GuestChatMessageCounterArr[UID];i>=0;i--) {
			var xMsg=GuestChatMessageHistoryArr[UID][GuestChatMessageCounterArr[UID]-i];
			if (xMsg!="undefined" && xMsg!=null && xMsg!="") {
				ShowTheAlertMessages(UID,xMsg);
			}
		}
	}
	else {
		ShowTheAlertMessages(UID,"没有任何消息记录!");
	}
};

/* 添加到聊天记录 */
function AddInGuestHistory(UID,MSG) {
	/* 数组初始化 */
	if (typeof(GuestChatMessageCounterArr[UID])=="undefined") GuestChatMessageCounterArr[UID]=0;
	if (typeof(GuestChatMessageHistoryArr[UID])!="object") GuestChatMessageHistoryArr[UID]=new Array();

	/* 记录到数组 */
	GuestChatMessageHistoryArr[UID][GuestChatMessageCounterArr[UID]]=MSG;
	GuestChatMessageCounterArr[UID]++;

	/* 只保留10条记录 */
	if (GuestChatMessageCounterArr[UID]>10) {
		GuestChatMessageHistoryArr[UID][GuestChatMessageCounterArr[UID]-10]=null;
	}
};

/* 检查是否断开连接或者未初始化完毕 */
function GuestCheckDoAnyThings(UID) {
	/* 判断是否与服务器断开了连接 */
	if (sExec==1) {
		ShowTheAlertMessages(UID,"您已经断开了与服务器的连接。");
		return true;
	}

	/* 判断帐号是否激活 */
	if (GuestAccountActive==0) {
		ShowTheAlertMessages(UID,"请等待系统初始化完成。");
		/* 将初始化窗口前置 */
		if (GuestGlobalAccountUID!=null) G_ShowWindow("GuestChat_"+GuestGlobalAccountUID);
		return true;
	}

	return false;
}

/* 发消息热键 */
function doHotKeySendGuestMessage(evt,UID) {
	/* 禁止热键 */
	if (HotKeyDisabled==1) return;

	evt=evt ? evt : (window.event ? window.event : null);
	/* 处理Ctrl+Enter */
	if (evt.ctrlKey && evt.keyCode==13) {
		SendGuestChatMessages(UID);
		if (G_Microsoft_IE) evt.keyCode = 0;
		evt.cancelBubble = true;
	}
	/* 处理Alt+S */
	else if (evt.altKey && evt.keyCode==83) {
		SendGuestChatMessages(UID);
		if (G_Microsoft_IE) evt.keyCode = 0;
		evt.cancelBubble = true;
	}

	return false;
};

/* 发送消息 */
function SendGuestChatMessages(UID) {
	var zPetName="您("+GuestMySelfUID+")";
	var MsgBody="";
	var MsgFlag=0;
	if (G_Microsoft_IE) {
		MsgBody=$get_("GuestChat_Input_Messages_"+UID).innerHTML;
	}
	else {
		MsgBody=$get_("GuestChat_Input_Messages_"+UID).value;
	}
	if (MsgBody=="") {
		alert("消息不能为空!");
		$get_("GuestChat_Input_Messages_"+UID).focus();
		return;
	}

	/* 检查是否断开连接或者未初始化完毕 */
	if (GuestCheckDoAnyThings(UID)) return;

	MsgBody=MsgBody.substr(0,SETTINGS['messagemaxlen']);
	MsgBody="<span style=\"font-family:"+(zFontSetContent['GuestChat_font_face'+UID] ? zFontSetContent['GuestChat_font_face'+UID] : "")+";font-size:"+(zFontSetContent['GuestChat_font_size'+UID] ? zFontSetContent['GuestChat_font_size'+UID] : "")+";font-weight:"+(zFontSetContent['GuestChat_font_weight'+UID] ? zFontSetContent['GuestChat_font_weight'+UID] : "normal")+";font-style:"+(zFontSetContent['GuestChat_font_style'+UID] ? zFontSetContent['GuestChat_font_style'+UID] : "normal")+";text-decoration:"+(zFontSetContent['GuestChat_text_decoration'+UID] ? zFontSetContent['GuestChat_text_decoration'+UID] : "none")+";color:"+(zFontSetContent['GuestChat_color'+UID] ? zFontSetContent['GuestChat_color'+UID] : "")+";\">"+MsgBody+"</span>";

	/* 将消息显示到屏幕上 */
	var sObj=document.createElement("span");
	var xMsg="<span style=\"color:#008040;\">"+zPetName+"&nbsp;"+GetCurrentTime()+"</span><br />"+(((MsgBody.replace(/\r/gi, '')).split("\n")).join("<br />"));
	sObj.innerHTML=xMsg+"<br /><img src=\""+SETTINGS['home_url']+"/images/blank.gif\" width=\"1\" height=\"7\" border=\"0\"><br />";
	$get_("GuestChat_Messages_Body_"+UID).appendChild(sObj);
	$get_("GuestChat_Messages_Body_"+UID).scrollTop += 10000;

	/* 将输入文本框置空 */
	$get_("GuestChat_Input_Messages_"+UID).value="";
	$get_("GuestChat_Input_Messages_"+UID).focus();

	/* 提示用户对方不在线 */
	if (GuestMembersOlArr['_'+UID]==null || GuestMembersOlArr['_'+UID]=="undefined") {
		MsgFlag=1;
		ShowTheAlertMessages(UID,"(对方目前不在线,消息将会发送到对方的手机和邮箱。)");
	}

	/* 发送到服务器 */
	//@@
	MsgBody+="\r\n"+parent.location.href;
	httpconnect(GuestTheMainURL,"action=send&uid="+UID+"&MsgFlag="+MsgFlag+"&msg="+ReplaceAjaxWord(MsgBody));

	/*添加到聊天记录*/
	AddInGuestHistory(UID,xMsg);

	/*释放内存*/
	sObj=null;
	MsgBody=null;
};

/* 显示新消息 */
function RecvGuestChatMessages(UID,Mtime,Messages) {
	var zPetName=GuestAccountPetNameArr[UID];
	if (zPetName=="" || zPetName=="undefined" || zPetName==null) zPetName="对方("+UID+")";

	/* 检查窗口是否存在 */
	if (G_CheckWindowExists("GuestChat_"+UID)) {
		/* 如果是关闭状态则显示 */
		if ($get_("GMainFrameWindow_GuestChat_"+UID).style.display!="") {
			GuestOpenMessageDialog(UID);
		}
	}

	/* 设置该用户在线状态 */
	if (GuestMembersOlArr['_'+UID]==null || GuestMembersOlArr['_'+UID]=="undefined") GuestMembersOlArr['_'+UID]=1;

	/* 将消息显示到屏幕上 */
	var sObj=document.createElement("span");
	var xMsg="<span style=\"color:#0000FF;\">"+zPetName+"&nbsp;"+Mtime+"</span><br />"+Messages;
	sObj.innerHTML=xMsg+"<br /><img src=\""+SETTINGS['home_url']+"/images/blank.gif\" width=\"1\" height=\"7\" border=\"0\"><br />";
	$get_("GuestChat_Messages_Body_"+UID).appendChild(sObj);
	$get_("GuestChat_Messages_Body_"+UID).scrollTop += 10000;

	/*添加到聊天记录*/
	AddInGuestHistory(UID,zPetName+"&nbsp;"+Mtime+"<br />"+Messages);

	/*释放内存*/
	sObj=null;
	Messages=null;
};

/* 读取新消息 */
function ReadGuestNewMessages(UID,SID) {
	if (SID!="") {
		/* 读取新消息 */
		httpconnect(GuestTheMainURL,"action=recv&uid="+UID+"&sid="+SID);
	}
};

/* 接受服务器消息 */
function doGuestNewMessages(sID) {
	if (sID!="") {
		var sObj=sID.split("\x7f|\x7f");
		for (var i=0;i<sObj.length;i++) {
			if (sObj[i]!="") {
				var xObj=sObj[i].split("\x7f,\x7f");
				/* 判断消息类别 */
				if (xObj[1]=='0') {/* 普通消息 */
					/* 读取新消息 */
					ReadGuestNewMessages(xObj[0],xObj[2]);
				}
				else if (xObj[1]=='6') {/* 文件传输 */
					GuestGetTheUserSendFile(xObj[0],xObj[2]);
				}
				else if (xObj[1]=='7') {/* 会话转接 */
					doGuestChatMessagesDirection(xObj[0]);
				}
			}
		}
	}
};

/* 获取传送过来的文件信息 */
function GuestGetTheUserSendFile(UID,SID) {
	httpconnect(GuestTheMainURL,"action=getfileinfo&uid="+UID+"&sid="+SID);
};

/* 将接收到的文件信息显示到屏幕上 */
function GuestShowTheUserGetFile(UID,mTime,FileInfo,SID) {
	var TheInfo=FileInfo.split("\x7f|\x7f");
	GuestOpenMessageDialog(UID);
	ShowTheAlertMessages(UID,"<img src=\""+SETTINGS['home_url']+"/images/info.gif\" border=\"0\" align=\"absmiddle\">&nbsp;对方发送了一个文件给您,点击文件名下载该文件。<br />&nbsp;<a href=\""+SETTINGS['home_url']+"/guest.php?action=getfile&sid="+SID+"&AccountKey="+GetGuestUserAccountKey()+"\" target=\"GuestChat_DownFile_Frame_"+UID+"\">"+TheInfo[0]+"("+(Math.round(parseFloat(TheInfo[1])/1024*100)/100)+"KB)</a>");
};

/* 处理会话转接 */
function doGuestChatMessagesDirection(UID) {
	/* 打开对话窗口 */
	GuestOpenMessageDialog(UID);
	$get_("GuestChat_Input_Messages_"+UID).focus();

	/* 显示问候语 */
	if (GuestAccountPetNameArr['Direct_'+UID]!=1) {
		GuestAccountPetNameArr['Direct_'+UID]=1;
		RecvGuestChatMessages(UID,GetCurrentTime(),"您好,请问您有什么需要帮助的?");
	}
};

/* 获取聊天记录 */
function GuestGetUserChatHistory(UID) {
	if (GuestChatInfoReaderArr['history_'+UID]!=1) {
		httpconnect(GuestTheMainURL,"action=history&uid="+UID);
	}
};

/* 聊天记录获取标志 */
function GuestSetReadHistoryFlag(UID) {
	/* 标记已读 */
	GuestChatInfoReaderArr['history_'+UID]=1;

	var zMax=GuestChatMessageCounterArr[UID];
	GuestChatMessageCounterArr[UID]=0;

	/*添加到聊天记录*/
	for (var i=0;i<zMax;i++) {
		AddInGuestHistory(UID,GuestChatMessageHistoryTmp[UID][zMax-i]);
	}
	GuestChatMessageHistoryTmp[UID]=null;
};

/* 用户信息获取标志 */
function GuestSetReadInfoFlag(UID) {
	/* 标记已读 */
	GuestChatInfoReaderArr[UID]=1;
};

/* 获取用户信息 */
function GuestGetUsersInfo(UID) {
	if (GuestChatInfoReaderArr[UID]!=1) {
		httpconnect(GuestTheMainURL,"action=info&uid="+UID);
	}
};

/* 设置用户信息 */
function GuestSetUsersInfo(UID,PetName,Sex,Face,zShow) {
	var imgURL=zShow.replace("\x7f|\x7f",",");
	GuestAccountPetNameArr[UID]=PetName;
	$get_("GuestChat_UID_"+UID).innerHTML=UID;
	$get_("GuestChat_PetName_"+UID).innerHTML=PetName;
	$get_("GuestChat_Face_"+UID).src=SETTINGS['home_url']+"/images/face/"+Face+"-1.gif";
	$get_("GWindowTitleName_GuestChat_"+UID).innerHTML="与 "+PetName+" 对话中";
	$get_("GuestChat_UserShow_"+UID).src=(imgURL!="" ? GuestTheMainURL+"?action=show_getfile&sid="+imgURL : SETTINGS['home_url']+"/images/show.jpg");
};

/* 设置用户名片自立啊 */
function GuestSetUsersCard(UID,Email,Address,Tel,Mobile) {
	GuestChatInfoCardArr[UID+'_email']=Email;
	GuestChatInfoCardArr[UID+'_address']=Address;
	GuestChatInfoCardArr[UID+'_tel']=Tel;
	GuestChatInfoCardArr[UID+'_mobile']=Mobile;
};

/* 显示系统广告 */
function setGuestChatInfoAD(UID,sURL) {
	$get_("GuestChat_ClientAD_"+UID).innerHTML="<img src=\""+sURL+"\" width=\"238\" height=\"38\" border=\"0\">";
};

/* 警告用户非法篡改 */
function setGuestChatADWarn(UID) {
	$get_("Chat_ClientAD_"+UID).innerHTML="<strong>请勿篡改BICQ的系统文件,谢谢!<br />Powered By BokaVan 2008</strong>";
};

/* 显示系统消息 */
function ShowTheAlertMessages(UID,zMsg) {
	var sObj=document.createElement("span");
	var xMsg="<span style=\"color:#6f6f6f;\">"+zMsg+"</span><br /><img src=\""+SETTINGS['home_url']+"/images/blank.gif\" width=\"1\" height=\"7\" border=\"0\"><br />";
	sObj.innerHTML=xMsg;
	$get_("GuestChat_Messages_Body_"+UID).appendChild(sObj);
	$get_("GuestChat_Messages_Body_"+UID).scrollTop += 10000;
};

/* 更换请求验证码 */
function GuestChatRefreshVerify() {
	$get_("GuestChat_Input_VerifyCode").value="";
	$get_("GuestChat_Input_VerifyCode").focus();
	$get_("GuestChat_VerifyCode").src=SETTINGS['home_url']+"/verify.php?rnd="+(new Date().getTime())+"&SESSION_ID="+BICQ_SESSION_ID;
};

/* 请求验证码提交 */
function GuestChatRequestAccountPostVerify(UID) {
	var sKey=$get_("GuestChat_Input_VerifyCode").value;
	if (sKey=="") {
		alert('请输入验证码!');
		return;
	}
	if (GuestMySelfUID==0) GuestChatRequestTheAccountVerify(UID,sKey);
};

/* 提交验证码并请求帐号 */
function GuestChatRequestTheAccountVerify(UID,sKey) {
	if (GuestActiveCounterFlag==0) {/* 如果计时器不在工作 */
		GuestAccountTimerKey=GetUniqueProgressKeyID();
		ShowTheAlertMessages(UID,"正在连接到服务器,请稍候。<span id=\"GuestActiveAccountTimerID_"+GuestAccountTimerKey+"\">&nbsp;</span>");
		GuestAccountTimerCallBack="GuestChatRequestTheAccountVerifyFailed(\""+UID+"\");";
		EnableTheAccountTimer(UID);/* 启动倒计时 */
		GuestRequestTheAccount(UID,sKey);/* 请求分配帐号 */
	}
};

/* 提交验证码并请求帐号失败 */
function GuestChatRequestTheAccountVerifyFailed(UID) {
	DisableTheAccountTimer();
	ShowTheAlertMessages(UID,"连接到服务器失败,请按 [确定] 按钮重新连接到服务器。");
};

/* 提交验证码错误 */
function GuestChatRequestTheAccountVerifyError(UID) {
	DisableTheAccountTimer();
	GuestChatRefreshVerify();
	ShowTheAlertMessages(UID,"验证码错误!请重新输入并按 [确定] 按钮。");
};

/* 设置帐号分配验证码 */
function GuestSetAccountVerifyKey(UID,sKey) {
	DisableTheAccountTimer();
	BICQ_SESSION_ID=sKey;
	GuestGlobalAccountUID=UID;
	ShowTheAlertMessages(UID,"请输入验证码并按 [确定] 按钮进行系统初始化。<br /><img id=\"GuestChat_VerifyCode\" src=\""+SETTINGS['home_url']+"/verify.php?SESSION_ID="+sKey+"\" border=\"0\" align=\"absmiddle\" onClick=\"GuestChatRefreshVerify();\" style=\"cursor:pointer;\" title=\"点击更换验证码\">&nbsp;<input id=\"GuestChat_Input_VerifyCode\" class=\"GuestChat_Input_VerifyCode\" type=\"text\" value=\"\" maxlength=\"5\">&nbsp;<span style=\"font-weight: bold;cursor:pointer;color:#000000;\" onClick=\"GuestChatRequestAccountPostVerify('"+UID+"');\">[确定]</span>");
};

/* 请求系统分配帐号 */
function GuestRequestTheAccount(UID,sKey) {
	httpconnect(GuestTheMainURL,"action=register&uid="+UID+"&sKey="+sKey);
};

/* 帐号激活定时器函数 */
function TheGuestAccountTimerEx(UID) {
	/* 检测定时器是否关闭 */
	if (GuestActiveCounterFlag==0) return;

	GuestActiveCounter++;
	$get_("GuestActiveAccountTimerID_"+GuestAccountTimerKey).innerHTML="["+(60-GuestActiveCounter)+"]";
	if (GuestActiveCounter<60) {
		setTimeout("TheGuestAccountTimerEx('"+UID+"');",1000);
	}
	else {/* 时间到 */
		eval(GuestAccountTimerCallBack);
	}
};

/* 关闭帐号激活定时器 */
function DisableTheAccountTimer() {
	GuestActiveCounter=0;/* 计时器归零 */
	GuestActiveCounterFlag=0;/* 定时器关闭 */
	$get_("GuestActiveAccountTimerID_"+GuestAccountTimerKey).style.visibility="hidden";
};

/* 启动帐号激活定时器 */
function EnableTheAccountTimer(UID) {
	GuestActiveCounter=0;/* 计时器归零 */
	GuestActiveCounterFlag=1;/* 定时器启动 */
	TheGuestAccountTimerEx(UID);
};

/* 帐号请求失败 */
function GuestRequestTheAccountFailed(UID) {
	/* 如果已经激活,则返回 */
	if (GuestAccountActive==1 || GuestActiveCounterFlag==0) return;

	DisableTheAccountTimer();
	ShowTheAlertMessages(UID,"系统初始化失败,点击<span style=\"cursor:pointer;color:#000000;\" onClick=\"GuestCheckAccountStatus('"+UID+"');\">[这里]</span>重新初始化。");
};

/* 帐号分配完成 */
function GuestGetTheAccountFinish(UID,sKey) {
	/* 保存帐号信息 */
	SetGuestUserAccountKey(sKey);

	/* 开始登录操作 */
	GuestAccountActive=1;/* 帐号已激活 */
	DisableTheAccountTimer();/* 关闭计时器 */
	ShowTheAlertMessages(UID,"系统初始化完成。");
};

/* 清除帐号信息并重新分配帐号 */
function GuestClearAndRequestAccount(UID) {
	GuestAccountActive=0;		/* 帐号未激活 */
	SetGuestUserAccountKey("");	/* 清除帐号信息 */
	GuestCheckAccountStatus(UID);	/* 重新分配帐号 */
};

/* 游客帐号登录 */
function GuestTheAccountDoLogin(UID) {
	GuestAccountActive=1;/* 帐号已激活 */
	GuestAccountLoginTestCounter++;/* 登陆计数器加1 */
	if (GuestAccountLoginTestCounter>3) {/* 当登录次数大于3的时候 */
		/* 清除帐号信息并重新分配帐号 */
		GuestClearAndRequestAccount(UID);
		return;
	}
	ShowTheAlertMessages(UID,"正在连接到服务器,请稍候。<br />注意:在连接到服务器之前,对方将无法收到您的消息。");
	httpconnect(GuestTheMainURL,"action=login&uid="+UID);
};

/* 检查帐号信息 */
function GuestCheckAccountStatus(UID) {
	if (BICQ_SESSION_ID!="") return;

	var GuestAccountKey=GetGuestUserAccountKey();
	if (GuestAccountKey=="") {/* 如果没有找到帐号信息 */
		if (GuestActiveCounterFlag==0) {/* 如果计时器不在工作 */
			GuestAccountTimerKey=GetUniqueProgressKeyID();
			ShowTheAlertMessages(UID,"由于您是第一次使用BICQ,或者日志记录丢失。系统正在初始化,请稍候。<span id=\"GuestActiveAccountTimerID_"+GuestAccountTimerKey+"\">&nbsp;</span>");
			GuestAccountTimerCallBack="GuestRequestTheAccountFailed(\""+UID+"\");";
			EnableTheAccountTimer(UID);/* 启动倒计时 */
			GuestRequestTheAccount(UID,"");/* 请求分配帐号 */
		}
	}
	else {/* 登录 */
		GuestTheAccountDoLogin(UID);
	}
};

function GuestKeepRefresh_Ex() {
	if (sExec==0) {
		httpconnect(GuestTheMainURL,"action=keepfresh");
	}
};

/* 保持客户端的连接 */
function GuestKeepRefresh(UID,sUID,sKey) {
	GuestMySelfUID=sUID;
	BICQ_SESSION_ID=sKey;
	if (SETTINGS['refresh']) GuestRefreshTimeCount=SETTINGS['refresh'];
	GuestKeepRefreshTimer=setInterval("GuestKeepRefresh_Ex();",GuestRefreshTimeCount*1000);
	ShowTheAlertMessages(UID,"已经成功连接到服务器,您现在可以跟对方进行即时沟通。");

	/* 提示用户对方不在线 */
	if (GuestMembersOlArr['_'+UID]==null || GuestMembersOlArr['_'+UID]=="undefined") {
		ShowTheAlertMessages(UID,"(对方目前不在线,消息将会发送到对方的手机和邮箱。)");
	}

	/* 获取聊天记录 */
	GuestGetUserChatHistory(UID);
};

/* 让客户端断开连接 */
function setGuestAccountOffline() {
	sExec=1;
	alert('您在其他页面开了新的即时沟通窗口,本页面的消息连接将中断。');
};

/* 没有启用客户端 */
function GuestClientNotOpened() {
	sExec=1;
	alert('很抱歉,该服务器关闭了匿名会话支持!您无法继续与对方进行在线即时交流!所有消息连接将中断!');
};

/* 不允许跨域使用 */
function GuestClientNotAccess(sTime) {
	sExec=1;
	alert('很抱歉,您没有使用该服务器跨域代理的权限!请将代理时差设置为 '+sTime);
};

/* 打开对话窗口 */
function GuestOpenMessageDialog(UID) {
	G_CreateWindows("GuestChat_"+UID,GetRandom(500),GetRandom(500),500,487,SETTINGS['home_url']+"/images/skins/bicq/title.gif","与 "+UID+" 对话中",1,ConvertGuestChatHtml(UID));
	G_ShowWindow("GuestChat_"+UID);
};

/* 获取在线人员的列表 */
function GuestGetMembersOnlineArr(IDS) {
	httpconnect(GuestTheMainURL,"action=online&ids="+IDS);
};

/* 返回在线人员的列表 */
function GuestSetMembersOnlineArr(IDS) {
	try {
		GuestSetMembersOlStatus(IDS);
	} catch(e){alert('缺少GuestSetMembersOlStatus函数,或者此函数程序有错误。');};
};

/* 创建窗口 */
function GuestSendMessage(UID) {
	/* 检测是否启用客户端 */
	if (SETTINGS['ifguests']!="1") {
		GuestClientNotOpened();
		return;
	}

	GuestOpenMessageDialog(UID);
	GuestCheckAccountStatus(UID);
	GuestGetUsersInfo(UID);
	$get_("GuestChat_Input_Messages_"+UID).focus();
};