<?php
session_start();
include "Include/Global.php";
$Roomlist=RoomList(0,'<option value="{RoomId}">{Name}</option>');
$online=$db->sqlnum($db->query("select * from chat_user_online"));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>月光小屋“聊天室”</title>
<link href="images/css.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">

	var wchat;
	var xh;
	
	function xhReady()
	{
		if(xh.readyState==4)
		{
			if(xh.status==200)
			{
				if(xh.responseXML.documentElement.getAttribute("Result") == "TRUE")
				{
					wchat.document.body.innerHTML="<table width='100%'><tr><td height='400' align='center' valign='bottom' style='color:#C2C2C2'><img src='ChatRoom/loading.gif'><br><span style='color:#666666; font-size:12px'>登录中...请稍后！<br><span style='cursor:hand; color:#6699FF' onClick=\"window.open('http://s-net.cn')\">LChat V1.0(月光小屋) QQ:103602950</span><br>"+xh.responseXML.documentElement.getAttribute("MSG")+"</span></td></tr></table>";
					wchat.document.location.href = "ChatRoom.php?ChatId=" + xh.responseXML.documentElement.getAttribute("ChatId");
					wchat.focus();
				}
				else if(xh.responseXML.documentElement.getAttribute("Result") == "FALSE")
				{
					if(wchat != null)
						wchat.close()
					alert(xh.responseXML.documentElement.getAttribute("MSG"));
				}
				else
				{
					if(wchat != null)
						wchat.close()
					alert("错误！");
				}
			}
		}
	}
	function InitAjax()
	{
　	var ajax_obj=false;
　	try {
　　	ajax_obj = new ActiveXObject("Msxml2.XMLHTTP");
　		} 
	catch (e) {
　　		try {
　　　		ajax_obj = new ActiveXObject("Microsoft.XMLHTTP");
　　		} 
			catch (E) {
　　　		ajax_obj = false;
　　		}
　		}
　			//if (!ajax_obj && typeof XMLHttpRequest!='undefined') {
　　		//ajax_obj = new XMLHttpRequest();
　			//}
	if(!ajax_obj)
	{
	if(confirm("你使用的浏览器不能登陆聊天室！是否下载最新的IE浏览器？"))
	location.href='http://www.microsoft.com/china/windows/downloads/ie/getitnow.mspx';
	return null;
	}
　	return ajax_obj;
	}
	function StartChat()
	{
		if(ChatForm.UserName.value == '')
		{
			alert('请输入名字和密码！游客请随便输入一个名字即可！');
			ChatForm.UserName.focus();
			return false;
		}
		else
		{
		wchat = window.open('about:blank','LchatChat','height='+screen.availHeight+',width='+screen.availWidth+',top=-1,left=-1,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no');
		wchat.focus();
		wchat.document.writeln("<table width='100%'><tr><td height='400' align='center' valign='bottom' style='color:#C2C2C2'><img src='ChatRoom/loading.gif'><br><span style='color:#666666; font-size:12px'>登录中...请稍后！<br>如果长时间没有反应!请关闭浏览器!重新打开再试</span></td></tr></table>");
		var SendValue = "Name=" + ChatForm.UserName.value.replace(/\s+/g, '') + "&PassWord=" + ChatForm.PassWord.value + "&UserSex=" + ChatForm.UserSex0.checked+ "&RoomId=" + ChatForm.RoomId.value;
		xh = InitAjax();
		xh.open("POST","Service.php?Act=Login",true);
		xh.onreadystatechange = xhReady;
		xh.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xh.send(SendValue);
		}
	}//End StartChat()
	
	var XmlHttp;
	function GetOnLineUser()
	{
	///*
		XmlHttp = InitAjax();
		XmlHttp.onreadystatechange = getReady;
		XmlHttp.open("GET","Service.php?Act=ListOnLineUser&RoomId=0",true);
		XmlHttp.send(null);
		//*/
	}
	function $(id)
	{
		return document.getElementById(id);
	}
	function getReady()
	{
		if(XmlHttp.readyState==4)
		{
			if(XmlHttp.status==200)
			{
				$('OnLineUser').innerHTML = XmlHttp.responseXML.documentElement.getElementsByTagName("Users")[0].childNodes[0].nodeValue;
				setTimeout("GetOnLineUser()",30000);
				//alert("kkk");
			}
		}
	}
//*/


</script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body bgcolor="#FFFFFF" leftMargin=0 topMargin=0 onLoad="GetOnLineUser()">
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="400" align="center" background="images/1.jpg"><script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','600','height','400','src','images/flash','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/flash','wmode','transparent' ); //end AC code
</script>
            <noscript>
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="600" height="400">
              <param name="movie" value="images/flash.swf">
              <param name="quality" value="high">
              <PARAM NAME="wmode" VALUE="transparent">
              <embed src="images/flash.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="600" height="400"></embed>
            </object>
          </noscript></td>
        </tr>
      </table>
      <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><form action="" target="QxnzxChat" method=post ID="ChatForm" style="margin:0px;">
              <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="14"><img src="images/top1.gif" width="14" height="39"></td>
                  <td background="images/top3.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="110"><img src="images/biao.gif" width="110" height="19" align="absmiddle"></td>
                        <td valign="bottom"><font color="#666666">&nbsp;在线人[<font color="#CC6600"><span id="OnLineUser">
                          <?=$online?>
                          </span></font>]</font> <font color="#666666">用户名：
                          <INPUT name=UserName  class="box1" style="FONT-SIZE: 9pt; WIDTH: 60px" size="20" maxlength="20" autocomplete="off">
                          密码(游客无需密码)：
                          <INPUT name=PassWord type="PassWord"  class="box1" style="FONT-SIZE: 9pt; WIDTH: 50px" title="游客不需输入密码">
                          房间：
                          <select name="RoomId" id="RoomId"  class="box1" style="width:70px">
                            <?=$Roomlist?>
                          </select>
                          <input type="radio" value="0" name="UserSex" id="UserSex0">
                          男
                          <input type="radio" value="1" checked="true" name="UserSex" id="UserSex1">
                          女</font>
                          <input type=image value="聊天" id="Submit1" name="Submit1" src="images/Mail_Login.gif" align=absmiddle onClick="StartChat();return false;"> 
                          <input type=image value="聊天" src="images/Mail_Reg.gif" align=absmiddle onClick="window.open('Reg.php');return false"></td>
                      </tr>
                  </table></td>
                  <td width="14"><img src="images/top2.gif" width="14" height="39"></td>
                </tr>
              </table>
            </form></td>
        </tr>
        <tr>
          <td height="30" align="center">Copyright &copy; <font color="#FF6600"><strong>S-net.Cn</strong></font> <a href="http://s-net.cn" target="_blank"><strong><span style='cursor:hand; color:#336699' onClick="window.open('http://s-net.cn')">LChat V1.0(月光小屋)</span></strong></a><font color="#FF3300"> QQ:103602950 E-Mail:<a href="mailto:xianlin85@163.com" target="_blank">Xianlin85@163.Com</a></font></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
