<!--
//*******************************
//在线好友列表处理代码
//Ajax方式动态获取好友列表
//*******************************

//预先载入图像函数
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
document.onload=MM_preloadImages('/images/icon14.gif','/images/loding.gif')

var friend_list = false;
function send_request(currentPage) {
	friend_list = false;
	//开始初始化XMLHttpRequest 对象
	//Mozilla 浏览器创建对象语句
	if(window.XMLHttpRequest) { 
		friend_list = new XMLHttpRequest();
	}
	//IE 浏览器浏览器创建对象语句
	else if (window.ActiveXObject) {
		try {
			friend_list = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				friend_list = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	//异常，创建对象实例失败
	if (!friend_list) { 
		window.alert("不能创建XMLHttpRequest 对象实例.");
		return false;
	}
	friend_list.onreadystatechange = processFriend;
	// 确定发送请求的方式和URL 以及是否同步执行下段代码
	if (currentPage==null){currentPage=""}
	friend_list.open("GET","/script/OnLineFriend.asp?currentPage="+currentPage,true);
	friend_list.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	friend_list.send(null);
}
// 处理返回信息的函数
function processFriend() {
	//判断网页当前下载状态
	if (friend_list.readyState == 4){
		//信息已经成功返回，开始处理信息
		if (friend_list.status == 200){
			try{
				document.getElementById("FriendHidden").innerHTML=friend_list.responseText;
				//每5分钟更新一次在线好友列表
				setTimeout("send_request()",300000);
			}catch (err){}
		//如果打开页面出错则提示用户刷新页面
		}else{
			alert("对不起，获取好友列表出错，请检查网络！");
		} 
	}else{
		document.getElementById("FriendHidden").innerHTML="<div style='height:200px;background-color:white;color:black;' align='center'><div style='height:92px;'></div>好友信息加载中<img src='/images/loding.gif'/></div>"
	}
}

//***********************************
//《我有好友》栏目，拖动层开始
//***********************************
var x0=0,y0=0,x1=0,y1=0;
var moveable=false;
var curDragObj;
//var index=10000;//z-index;
//开始拖动我的好友列表菜单;
function startMenuDrag(obj)
{
	//if(event.button==1)
	//{
		//定义对象;
		curDragObj = document.getElementById("FriendMenuDrag");
		//锁定标题栏;
		//obj.setCapture();
		//记录鼠标和层位置;
		x0 = event.clientX;
		y0 = event.clientY;
		x1 = parseInt(curDragObj.style.left);
		y1 = parseInt(curDragObj.style.top);
		moveable = true;
	//}
}
//拖动我的好友列表菜单;
function FriendMenudrag()
{
	if(moveable)
	{
		curDragObj.style.left = x1 + event.clientX - x0;
		curDragObj.style.top  = y1 + event.clientY - y0;
	}
}
//停止拖动我的好友列表菜单;
function stopMenuDrag(obj)
{
	if(moveable)
	{
		obj.releaseCapture();
		moveable = false;
	}
}
//关闭我的好友列表菜单
function closeFriendMenu(){
	curDragObj = document.getElementById("FriendMenuDrag");
	if(curDragObj.style.display=="none"){
		curDragObj.style.display=""
	}else{
		curDragObj.style.display="none"
	}
}
//最小化我的好友列表菜单
function minFriendMinu(){
	curDragObj = document.getElementById("FriendHidden");
	if(curDragObj.style.display=="none"){
		curDragObj.style.display=""
	}else{
		curDragObj.style.display="none"
	}
}
//展开折叠好友分类
function CloseFriendClass(currentItem){
	//****************************
	//定义变量，获取预改变的标签
	//****************************
	var FriendClassImg=document.getElementById("FriendClassImg"+currentItem.toString());
	var FriendClassList=document.getElementById("FriendClassList"+currentItem.toString());
	//******************
	//关闭当前好友分类
	//******************
	if (FriendClassList.style.display==""){
		FriendClassList.style.display="none";
		FriendClassImg.src="/images/icon14.gif";
	//******************
	//显示当前好友分类
	//******************
	}else{
		FriendClassList.style.display='';
		FriendClassImg.src="/images/icon15.gif";
	}
}
//***********************************
//《我有好友》栏目，拖动层结束
//***********************************

//***********************************
//会员登录验证函数
//***********************************
function MemberLogin(obj) {
	if (document.getElementById("UserName2").value == "" || document.getElementById("UserName2").value.length<3){
		alert("请输入用户名或者输入字符大于3！");
		obj.UserName.focus();
		return false;
	}
	else if (document.getElementById("UserPass2").value == "" || document.getElementById("UserPass2").value.length<3){
		alert("请输入密码或者输入字符大于3！");
		obj.UserPass.focus();
		return false;
	}
	postSend("FriendList")
	return false;
}

//***********************************
//初始化《在线好友》列表位置
//***********************************
function ChangeFriendList(){
	//var bodywidth=document.getElementById("BodyWidth").scrollWidth;
	var bodywidth=document.body.offsetWidth;
	//var bodywidth=document.body.scrollWidth;
	var friendwidth=document.getElementById("FriendMenuDrag").scrollWidth;
	if(parseInt(document.body.scrollWidth)==(bodywidth)){
		document.getElementById("FriendMenuDrag").style.left=(bodywidth-friendwidth-3)+"px";
	}else{
		document.getElementById("FriendMenuDrag").style.left=(bodywidth-friendwidth-25)+"px";
	}
}
window.onresize=function(){
	ChangeFriendList();
}
//-->