	function faces(texts){
		document.getElementById('content').value=document.getElementById('content').value+texts;
	}

var XmlHttp;
function CreateXmlHttp()
{
	if(window.ActiveXObject)
	{
		 XmlHttp=new ActiveXObject("microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest)
	{
		XmlHttp=new XMLHttpRequest();
	}
}

function login()
{
	CreateXmlHttp();

	var username = document.getElementById('username').value;
	var password = document.getElementById('password').value;
	var str = "type=login&username="+username+"&password="+password;

	XmlHttp.open("POST","http://www.hellof1.com/include/f1_insert_comment.php",true);
	XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	XmlHttp.onreadystatechange=function ()
		{
			if(XmlHttp.readyState==4)
			{
				if(XmlHttp.status==200)
				{
					if(XmlHttp.responseText==1) alert('用户名或密码不能为空');
					if(XmlHttp.responseText==2) {
						alert('用户名或密码错误');
						$('username').value = '';
						$('password').value = '';
					}
					if(XmlHttp.responseText==username){
						$('log').innerHTML='欢迎 <font color="red">'+XmlHttp.responseText+'</font>, <a href="javaScript:logout()">退出登陆</a>';
					}
				}else{
					alert('网络错误');
				}
			}
		}
	XmlHttp.send(str);
}


function logout()
{
	CreateXmlHttp();
	if(!confirm('确认要退出登陆?')) return;
	var str = 'type=logout';

	XmlHttp.open("POST","http://www.hellof1.com/include/f1_insert_comment.php",true);
	XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	XmlHttp.onreadystatechange=function ()
		{
			if(XmlHttp.readyState==4)
			{
				if(XmlHttp.status==200)
				{
					$('log').innerHTML='论坛帐号:<input type="text" name="username" size="12" id="username" onmouseover="javascript:this.select()"/> 密码: <input type="password" name="pwd" size="12" id="password" onmouseover="javascript:this.select()" />&nbsp;<input type="button" value="登录" onclick="login()" class="button1"/> <a href="http://bbs.hoopchina.com/register.php" target="_blank">注册</a>';
				}else{
					alert('错误');
				}
			}
		}
	XmlHttp.send(str);
}

