var bodyCH; 
if(window.innerHeight)
{
    bodyCH=window.innerHeight;
}
else if(document.documentElement&&document.documentElement.clientHeight)
{ 
    bodyCH=document.documentElement.clientHeight; 
}
else if(document.body)
{
    bodyCH=document.body.clientHeight;
}
window.$m_z_index=10000
window.wid=0
if(document.all)
	var IS_IE=1
else
	var IS_IE=0
String.prototype.inc=function(s){return this.indexOf(s)>-1?true:false}
function oDel(obj){if(obj!=null){obj.parentNode.removeChild(obj)}}
function _q_addEvent(obj,eventName,eventFunc){if(obj.attachEvent){obj.attachEvent(eventName,eventFunc);}else if(obj._q_addEventListener){eventName = eventName.toString().replace(/on(.*)/i,'$1');obj._q_addEventListener(eventName,eventFunc,true);}}
function _q_delEvent(obj,eventName,eventFunc){if(obj.detachEvent){obj.detachEvent(eventName,eventFunc);}else if(obj.removeEventListener){eventName = eventName.toString().replace(/on(.*)/i,'$1');obj.removeEventListener(eventName,eventFunc,true);}}
if(!document.all){
	Event.prototype.__defineGetter__("srcElement",function(){var node=this.target;while(node.nodeType!=1){node=node.parentNode}return node})
	Event.prototype.__defineGetter__("x",function(){return this.clientX})
	Event.prototype.__defineGetter__("y",function(){return this.clientY})
}
function objxy(e){
	var a=new Array()
	var t=e.offsetTop;
	var l=e.offsetLeft;
	var w=e.offsetWidth;
	var h=e.offsetHeight;
	while(e=e.offsetParent){
		t+=e.offsetTop;
		l+=e.offsetLeft;
	}
	a[0]=t;a[1]=l;a[2]=w;a[3]=h
  return a;
}
function urlcache(){
	var t=new Date();
	return t.getTime()
}
function textcount(obj){
	var l=obj.value.length
	if(200-l>=0)
		obj.nextSibling.innerHTML="剩余 "+(200-l)+" 字"
	else
		obj.nextSibling.innerHTML="<font style='color:#F00'>超出 "+(l-200)+" 字</font>"
}

/*************************************************************
title窗口标题，w窗口宽度,url表单提交的地址,fmecho提交后回调函数
*************************************************************/
function _$w(title,w,url,fmecho){
	wid++
	var obox,obox2,otop,otitle,oclose,odel
	//大容器
	obox=document.createElement("div");
	obox.style.cssText="width:"+w+"px; border:1px solid #6488B8;background:#fff;padding:1px; position:absolute;z-index:"+$m_z_index
	obox2=document.createElement("div");
	obox2.style.cssText="width:"+(w-10)+"px;background:url(http://image2.sina.com.cn/pay/quanzi/qsina/messenger/send_r2_c8.png) repeat-x;padding-right:10px"
	obox.appendChild(obox2)
	//top
	otop=document.createElement("div");
	otop.style.cssText="width:98%; height:22px;margin:0;padding:0 0 0 4px;cursor:move"
	otop.onselectstart=function(){return false}
	obox2.appendChild(otop)
	//拖拽操作
	var dragxy=new Array()			//拖拽边距
	var del_drag=null
	otop.onmousedown=function(e){
		e=e||event
		dragxy[0]=(e.x-obox.style.left.replace("px",""))
		dragxy[1]=(e.y-obox.style.top.replace("px",""))
		_q_addEvent(document.body,"onmousemove",drag)
	}
	obox.onmouseup=function(){
		_q_delEvent(document.body,"onmousemove",drag)
	}
	var drag=function(e){
		if(dragxy.length!=0){
			e=e||event
			var a=dragxy
			var mx=e.x-a[0]
			var my=e.y-a[1]
			obox.style.left=mx+"px"
			obox.style.top=my+"px"
			shadow1.style.left=(mx+1)+"px"
			shadow1.style.top=(my+1)+"px"
			shadow2.style.left=(mx+2)+"px"
			shadow2.style.top=(my+2)+"px"
			shadow3.style.left=(mx+3)+"px"
			shadow3.style.top=(my+3)+"px"
		}
	}
	otitle=document.createElement("div");
	otitle.style.cssText="float:left; width:180px; margin:3px 0 0 0; padding:0; font-size:13px; color:#5A5152;overflow-x:hidden;white-space:nowrap"
	otitle.innerHTML=title==null?"信息提示":title
	otop.appendChild(otitle)
	odel=document.createElement("input");
	odel.type="button"
	odel.value=""
	if(url!=null&&!$("but_hidden"+wid)){
		odel.setAttribute("id","but_hidden"+wid)
	}
	odel.style.cssText="float:right;margin:8px 0 0 0;cursor:pointer;background:url(http://image2.sina.com.cn/pay/quanzi/qsina/messenger/message_r2_c4.png);width:8px;height:8px;border:0px"
	otop.appendChild(odel)
	odel.onclick=function(){
		//关闭按钮
		try{
			oDel(shadow1)
			oDel(shadow2)
			oDel(shadow3)
			oDel(obox)
			oDel(hoar)
		}catch(e){}
	}
	//top end
	//消息内容
	var strbox,spanbt
	this.alert=function(str,echo){
		strbox=document.createElement("div")
		strbox.style.cssText="font-size:12px; color:#333333;height:60px;text-align:center; margin:20px 10px;line-height:18px;"
		strbox.innerHTML="<font style='font-size:12px'>"+str+"</font>"
		obox2.appendChild(strbox)
		if(str.length>115)
				obox2.style.height="150px"
	}
	//消息插入按钮
	this.add_bt=function(btname,echo){
		var button
		if(spanbt==null){
			spanbt=document.createElement("span")
			spanbt.style.cssText="padding:15px 0 0 0; display:block; text-align:center"
			strbox.appendChild(spanbt)
		}
		var button=document.createElement("input")
		button.type="button"
		button.style.cssText="background:url(http://image2.sina.com.cn/pay/quanzi/qsina/messenger/botton.png) no-repeat; border:none; width:44px; height:21px;margin:0px 5px;text-align:center"
		button.value=btname
		if(echo!=null&&!$("but_hidden"+wid)){
			odel.id="but_hidden"+wid
		}
		if(echo==null)
			button.onclick=odel.onclick
		else if(typeof(echo)=="function"){
			button.onclick=echo
		}else{
			button.onclick=function(){
				eval(echo)
			}
		}
		spanbt.appendChild(button)
	}
	
	//创建表单
	var fm
	this.setfm=function(){
		fm=document.createElement("form")
		fm.style.cssText="padding:10px 0 0 15px;margin:0px;text-align:left"
		fm.onsubmit=function(){
			if(fm.checkwd.value==""){
				$msg("验证码不能为空!")
				return false
			}
			if(fm.content.value==""||fm.content.value=="请在这里输入纸条内容"||fm.content.value=="请在这里输入您的附加留言"){
				$msg("内容不能为空!")
				return false
			}
			if(fm.content.value.length>200){
				$msg("最多可以输入200个字!")
				return false
			}
			var parameter="checkwd="+fm.checkwd.value+"&msg="+encodeURIComponent(fm.content.value.replace(/\>/g,"&gt;").replace(/</g,"&lt;").replace(/&/g,"%26").replace(/\+/g,"%20"))
			//var parameter="msg="+encodeURIComponent(fm.content.value.replace(/\>/g,"&gt;").replace(/</g,"&lt;").replace(/&/g,"%26").replace(/\+/g,"%20"))
			SetAjax(url,parameter,fmecho)

			return false
		}
		obox2.appendChild(fm)
	}
	//插入验证码
	this.validate=function(){
		var sp=document.createElement("span")
		sp.innerHTML='验证码：<input type="text" name="checkwd" class="send_input" style="vertical-align:middle;width:105px"/> <img src="http://q.blog.sina.com.cn/control/checkpng.php" style="vertical-align:middle"/>'
		//sp.innerHTML=''
		fm.appendChild(sp)
	}
	//插入文本框
	this.addtext=function(){
		var textdiv=document.createElement("div")
		textdiv.style.cssText="padding:5px 0"
		textdiv.innerHTML='<textarea name="content" id="w_content" onfocus="wtextfocus(this)" style="width:240px;color:#999; height:101px; border:1px solid #A7ACB2; padding:5px; font-size:12px;" onkeyup="textcount(this)" onmousedown="textcount(this)"></textarea><div style="text-align:right;color:#808080;padding-right:20px">剩余 200 字</div>'
		fm.appendChild(textdiv)
	}
	var btdiv,btsubmit,btcancel		//表单提交按钮
	this.fmbutton=function(){
		btdiv=document.createElement("div")
		btdiv.style.cssText="text-align:center;padding:15px 0 5px 0"
		btsubmit=document.createElement("input")
		btsubmit.type="submit"
		btsubmit.style.cssText="background:url(http://image2.sina.com.cn/pay/quanzi/qsina/messenger/send_r2_c9.png);border:0px;width:44px;height:21px;margin:0px 5px"
		btsubmit.value=""
		btdiv.appendChild(btsubmit)
		btcancel=document.createElement("input")
		btcancel.type="button"
		btcancel.style.cssText="background:url(http://image2.sina.com.cn/pay/quanzi/qsina/messenger/send_r2_c10.png);border:0px;width:44px;height:21px;margin:0px 5px"
		btcancel.value=""
		btdiv.appendChild(btcancel)
		btcancel.onclick=odel.onclick
		fm.appendChild(btdiv)
	}
	
	//层的位置
	var shadow1,shadow2,shadow3
	this.xy=function(){
		var x,y,w,h
		w=obox.offsetWidth
		h=obox.offsetHeight
		x=(document.body.clientWidth-w)/2
		obox.style.left=x+"px"
		var cobj = document.body;
		while(cobj.scrollTop == 0 && cobj.parentNode) {
			if(cobj.tagName.toLowerCase() == 'html') break;
			cobj = cobj.parentNode;
		}
		var ch=(document.body.parentNode.clientHeight>document.body.clientHeight)?document.body.parentNode.clientHeight:document.body.clientHeight
		y=(cobj.scrollTop+(window.screen.availHeight-h)/2)
		obox.style.top=y+"px"
		shadow1=document.createElement("div")
		shadow1.style.cssText="position:absolute;left:"+(x+1)+"px;top:"+(y+1)+"px;width:"+w+"px;height:"+h+"px;background:#000;filter:alpha(opacity=7);-moz-opacity:0.07;z-index:"+($m_z_index-1)
		document.body.appendChild(shadow1)
		shadow2=document.createElement("div")
		shadow2.style.cssText="position:absolute;left:"+(x+2)+"px;top:"+(y+2)+"px;width:"+w+"px;height:"+h+"px;background:#000;filter:alpha(opacity=7);-moz-opacity:0.07;z-index:"+($m_z_index-2)
		document.body.appendChild(shadow2)
		shadow3=document.createElement("div")
		shadow3.style.cssText="position:absolute;left:"+(x+3)+"px;top:"+(y+3)+"px;width:"+w+"px;height:"+h+"px;background:#000;filter:alpha(opacity=7);-moz-opacity:0.07;z-index:"+($m_z_index-3)
		document.body.appendChild(shadow3)
		$m_z_index+=10
	}
	//灰底
	var hoar
	this.hoar=function(){
		hoar=document.createElement("div")
		hoar.style.cssText="position:absolute;top:0px;left:0px;background:#000;filter:alpha(opacity=7);-moz-opacity:0.07;z-index:"+($m_z_index-5)
		hoar.style.width=window.screen.width+"px"
		document.body.style.overflowX=document.body.parentNode.style.overflowX="hidden"
		hoar.style.height=document.body.scrollHeight+"px"
		document.body.appendChild(hoar)
		hoar.onmouseup=function(){
			_q_delEvent(document.body,"onmousemove",drag)
		}
	}
	
	//显示窗口
	this.show=function(){
		document.body.appendChild(obox)
		this.xy()
		obox.focus()
	//	if(document.getElementById("but_hidden"+wid)){
	//		$("but_hidden"+wid).onclick=odel.onclick
	//	}
	}
}


///ajax
/*
function SetAjax(url,parameter,echo){
	var put="get"	//提交类型
	if(parameter.slice(0,5)=="post:"){
		parameter=parameter.slice(5)
		put="post"
	}
	var req = null;
	if(window.XMLHttpRequest){
		req = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		var msxml = new Array('MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
		for(var i=0;i<msxml.length;i++){
			try{
				req = new ActiveXObject(msxml[i]);
			    break;
			}catch(e){}
		}
	}
	if(put=="get"){
		url+="&"+parameter
		parameter=null
	}
	req.open(put,url, true);
	req.onreadystatechange = function(){
		if(req.readyState==4 && req.status==200){
		//	alert(req.responseText)
			echo(req.responseXML)
		}
	}
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	req.send(parameter);
}
*/

///transfer SetAjax to use js append method
function SetAjax(url,parameter,echo){
	var put="get"	//提交类型
	if(parameter.slice(0,5)=="post:"){
		parameter=parameter.slice(5)
		put="post"
	}
	
	url="http://q.blog.sina.com.cn"+url;
	//alert(url)
	if(put=="get"){
		url+="&"+parameter
		parameter=null
	}
	url+="&callback="+echo;
	url+="&r="+parseInt(Math.random()*1000);
	
	var ScriptID = 'set_ajax_appandscript';
	var oScript = document.getElementById(ScriptID);
	var HttpHolder = document.getElementsByTagName("body").item(0);
	if(oScript)
	{
		HttpHolder.removeChild(oScript);
	}
	oScript = document.createElement("script");
	oScript.setAttribute("id",ScriptID);
	oScript.setAttribute('defer', true);
	oScript.setAttribute("src",url);
	HttpHolder.appendChild(oScript);
}

//callback
function q_ajax_call(callback, json)
{
	window.eval(callback+"(json)");
}

function SelectNodes(Xml,xpath){
	if(!xpath.inc("/"))
		return Xml.getElementsByTagName(xpath)
	if (document.all)
		return Xml.selectNodes(xpath) ;
	else{
		var aNodeArray = new Array();
		var xPathResult = Xml.evaluate(xpath, Xml, Xml.createNSResolver(Xml.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
		if (xPathResult){
			var oNode = xPathResult.iterateNext() ;
			while(oNode){
				aNodeArray[aNodeArray.length] = oNode ;
				oNode = xPathResult.iterateNext();
			}
		}
		return aNodeArray ;
	}
}
//function xva(Xml,xpath){return SelectNodes(Xml,xpath)}
//function xv(Xml,xpath,n){try{return oTxt(xva(Xml,xpath)[n==null?0:n])}catch(e){return ""}}
//function oTxt(obj){try{return obj.firstChild.nodeValue.replace(/\</gi,"&lt;").replace(/\>/gi,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&acute;")}catch(e){return ""}}

//json data parse
function xva(json,xpath){
	var arr = $H(json);
	return arr.get(xpath);
}
function xv(json,xpath)
{
	try{
				return oTxt(xva(json, xpath));
	}catch(e){
				return "";
	}
}
function oTxt(obj)
{
	obj+="";
	try{
		return obj.replace(/\</gi,"&lt;").replace(/\>/gi,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&acute;")
	}catch(e){
		return ""
	}
}

function oKey(obj,key){var o=obj.getAttribute(key);return o==null?"":o}
function $close(){
	for(var i=0;i<=wid;i++){
		if($("but_hidden"+i)){
			window.setTimeout("$('but_hidden"+i+"').click()",20)
		}
	}
}
//消息接口
function $msg(str,title,echo){
	var w=new _$w(title,250);
	w.alert(str)
	w.add_bt("确定",echo)
	if(echo!=null)
		w.add_bt("取消")
	w.hoar()
	w.show();
}

//发送窗口
function $send(title,url,fmecho){
	var w=new _$w(title,280,url,fmecho);
	w.setfm();
	w.validate()
	w.addtext()
	w.fmbutton()
	w.hoar()
	w.show();
}

//未登录弹出登录框
function ISlogin(showmsg){
	var userinfo = get_current_userinfo();
	//alert(userinfo);
	myuid = userinfo['sinaid'];
		myloginname = userinfo['username'];
		mynickname = userinfo['yueku_nick'];
	if(userinfo==false) {
		islogin = 0;
	}else {
		islogin = 1;
		myuid = userinfo['sinaid'];
		myloginname = userinfo['username'];
		mynickname = userinfo['yueku_nick'];
	}

	//alert(islogin);
	//alert(myuid);
	//alert(myloginname);
	//alert(mynickname);
	if(typeof(islogin)=="undefined"||islogin==0){
		if(showmsg==true) {
			alert('请先登录!');
			//
			//sq_login_url(function(){return true;});
		}
		return false;
	}
	return true;
}
//发小纸条
function Scrip(name,uid){
	if(ISlogin(true)==false)
		return
	var title="发送给：<span style='color:#3064AD'>"+name+"</span>"
	var fromnick=mynickname==""?myloginname:mynickname
	//alert("/control/friends/sendmsg.php?code=utf&ie="+IS_IE+"&t="+urlcache()+"&fromid="+myuid+"&toid="+uid+"&fromnick="+encodeURIComponent(fromnick)+"&tonick="+encodeURIComponent(name));
	$send(title,"/control/friends/sendmsg.php?code=utf&ie="+IS_IE+"&t="+urlcache()+"&fromid="+myuid+"&toid="+uid+"&fromnick="+encodeURIComponent(fromnick)+"&tonick="+encodeURIComponent(name),"scripback")
	if($("w_content")){
		$("w_content").value="请在这里输入纸条内容"
	}
}
function scripback(xml,txt){
	var result=xv(xml,"result")
	//alert(result)
	if(result=="您输入的验证码有误。"){
		$msg("您输入的验证码有误。")
		return
	}
	$close()
	if(result==1){
		$msg("小纸条发送成功！")
		return
	}
	$msg(result)
}
//加好友
function add_friend(uid){
	if(ISlogin(true)==false)
		return
	SetAjax("/control/friends/checkuserstatus.php?code=utf&t="+urlcache()+"&fromid="+myuid+"&toid="+uid,"","set_friend")
}
function set_friend(xml){
	var result=xv(xml,"status")
	var uid=xv(xml,"uid")
	var nickname=xv(xml,"nickname")
	var fromnick=mynickname==""?myloginname:mynickname
	if(result==1){
		var title="您将添加<font style='color:#3064AD'>"+nickname+"</font>为好友"
		$send(title,"/control/friends/sendinvitemsg.php?code=utf&ie="+IS_IE+"&t="+urlcache()+"&fromnick="+encodeURIComponent(fromnick)+"&tonick="+encodeURIComponent(nickname)+"&toid="+uid+"&fromid="+myuid,"start_friend")
		if($("w_content")){
			$("w_content").value="请在这里输入您的附加留言"
		}
	}else if(result==0){
		$msg("对方不接收好友邀请。是否将对方加入您的其他联系人？",null,"add_linkman('"+nickname+"','"+uid+"')")
	}else{
		$msg(result)
	}
}
//加好友返回
function start_friend(xml){
	var result=xv(xml,"result")
	if(result=="您输入的验证码有误。"){
		$msg("您输入的验证码有误。")
		return
	}
	if(result==1){
		$close()
		$msg("好友邀请发送完成，请等待对方确认！")
	}else{
		$close()
		$msg(result)
	}
}
//添加联系人
function add_linkman(name,uid){
	SetAjax("/control/friends/addcontact.php?code=utf&t="+urlcache()+"&fromid="+myuid+"&toid="+uid,"","linkman_back")
}
function linkman_back(xml){
	var result=xv(xml,"result")
	$close()
	if(result==1){
		$msg("添加联系人成功！")
	}else
		$msg(result)
}
/////文本焦点
function wtextfocus(obj){
	if(obj.value=="请在这里输入纸条内容"||obj.value=="请在这里输入您的附加留言"){
		obj.value="";
		obj.style.color="#000"
	}
}
/////留言数小框
var $_fx=0
var $_move=true
function $_hint(n){
	if(n==0)
		return
	var div=document.createElement("div")
	div.style.cssText="width:197px; height:112px;right:2px; border:1px solid #6488B8; padding:1px; position:absolute;"
	div.innerHTML='	<div style="width:197px; height:112px; background:url(http://image2.sina.com.cn/pay/quanzi/qsina/messenger/message_r2_c2.png) repeat-x;">\
						<div style="width:187px; height:22px; margin:0; padding:0 6px 0 4px;">\
							<div style="float:left; width:150px; margin:3px 0 0 0; padding:0; font-size:13px; color:#5A5152;">纸条箱提示</div>\
							<div style="float:right; width:8px; margin:8px 0 0 0; padding:0;"><img src="http://image2.sina.com.cn/pay/quanzi/qsina/messenger/message_r2_c4.png" id="close_hint" style="cursor:pointer"/></div>\
						</div>\
						<div onclick="window.open(\'http://q.msg.mail.sina.com.cn\')" style="width:123px; height:65px; margin:0; padding:25px 0 0 74px; background:url(http://image2.sina.com.cn/pay/quanzi/qsina/messenger/message_r2_c3.png) no-repeat;cursor:pointer; background-position:20px 15px; font-size:12px; line-height:150%;">您有 <span style="color:#FF0000; font-family:Arial;"><strong>'+n+'</strong></span> 条未读纸条<br /><a href="http://q.msg.mail.sina.com.cn/">请注意查收！</a></div>\
					</div>'
					
					
	var cobj = document.body;
	while(cobj.scrollTop == 0 && cobj.parentNode) {
		if(cobj.tagName.toLowerCase() == 'html') break;
		cobj = cobj.parentNode;
	}
	var k=0
	div.onmouseover=function(){
		$_move=false
		window.setTimeout("$_hint_xy(1)",1000)
	}
	div.onmouseout=function(){
		$_move=true
		window.setTimeout("$_hint_xy(1)",1000)
	}
	window.onresize=window.onscroll=window.$_hint_xy=function(key){
		var clientHeight=document.body.parentNode.clientHeight==0?document.body.clientHeight:document.body.parentNode.clientHeight
		div.style.top=(cobj.scrollTop+bodyCH-k)+"px"
///		div.style.top=(cobj.scrollTop+document.body.clientHeight-k)+"px"
//		window.status=div.style.top+"|"+cobj.scrollTop+"|"+document.body.clientHeight+"|"+document.body.parentNode.parentNode.clientHeight
		if(!$_move){
			window.setTimeout("$_hint_xy(1)",1000)
			return
		}
		if(key==null) return
				
		if(k==118){
			if($_fx==1)
				return
			k=117
			$_fx=1
			window.setTimeout("$_fx=2;$_hint_xy(1)",3000)
		}
		if($_fx==0){
			k++
			window.setTimeout("$_hint_xy(1)",1)
		}
		if($_fx==2){
			k--
			if(k==0){
				try{oDel(div)}catch(e){}
				return
			}
			window.setTimeout("$_hint_xy(1)",1)
		}
	}
	
	$_hint_xy(1)
	document.body.appendChild(div)
	document.getElementById("close_hint").onclick=function(){
		oDel(div)
	}
}


///删除好友
function del_friends(toid,utype,tonick){
	var key=utype==1?"好友":"联系人"
	if(utype==1){
		var str='<div style="padding-left:40px">您确认要删除该好友吗？ <br><input type="checkbox" id="w_block" value="1">同时将该用户加入黑名单</div>'
	}else{
		var str='<div style="padding-left:40px">删除该联系人可能会造成对该用户好友邀请的失效。您确认要删除吗？ <br><input type="checkbox" id="w_block" value="1">同时将该用户加入黑名单</div>'
	}
	$msg(str,"删除"+key,"setdel_friends("+toid+","+utype+",'"+tonick+"')")
}
function setdel_friends(toid,utype,tonick){
	var block
	if(document.getElementById("w_block").checked)
		block=1
	else
		block=0
	SetAjax("/control/friends/delfriend.php?code=utf&t="+urlcache()+"&fromid="+myuid+"&toid="+toid+"&tonick="+tonick+"&utype="+utype+"&block="+block,"","delfriend_back")
}
function delfriend_back(xml){
	var result=xv(xml,"result")
	$close()
	if(result==1){
		$msg("您的操作已经成功，该页面将在3秒内自动刷新更新列表。")
		window.setTimeout("location.reload()",3000)
	}else
		$msg("删除失败！")
}
///////名片
function get_userinfo(uid,obj){
	var xy=objxy(obj)
	obj.setAttribute("mp",uid)
	if($("userinfo_"+uid)){
		var div=$("userinfo_"+uid)
		var shadow=$("shadow_"+uid)
		
		var sTop=xy[0]
		if(obj.getAttribute("tag")=="master"){
			sTop=sTop-$("master").scrollTop
		}
		div.style.top=sTop+"px"
		shadow.style.top=(sTop+6)+"px"

		$("userinfo_"+uid).style.display=""
		if(document.body.clientWidth/2<xy[1]){
			div.style.left=(xy[1]-div.offsetWidth-6)+"px"
			shadow.style.left=(xy[1]-div.offsetWidth-6+4)+"px"
		}else{
			div.style.left=(xy[1]+xy[2]+2)+"px"
			shadow.style.left=(xy[1]+xy[2]+2+4)+"px"
		}
		$("shadow_"+uid).style.display=""
	}else{
		var div=document.createElement("div");
		div.id="userinfo_"+uid
		div.className="q_card"
		var html='  <table width="100%" border="0" cellspacing="0" cellpadding="0">\
					  <tr>\
					    <td rowspan="2" valign="top" style="width:77px;padding-right:5px">\
							  	<a href="/mygroup.php?uid=$uid" target="_blank"><img src="http://image2.sina.com.cn/pay/quanzi/t2b.jpg"  id="icon_$uid" style="width:60px;height:60px;border:1px solid #d4d4d4;padding:1px;margin:0px"/></a>\
							  	<div style="padding:3px 0 0 5px"><a href="/mygroup.php?uid=$uid" style="margin:6px" target="_blank">个人中心</a></div>\
							</td>\
					    <td colspan="2" style="vertical-align:top;height:35px;border-bottom:1px solid #dedede;padding-bottom:5px">\
						  		<div style="float:left;width:180px;height:27px;line-height:18px;color:#5d5d5d">\
						  			昵　　称：<a href="/mygroup.php?uid=$uid" target="_blank"><strong id="nickname_$uid">读取中...</strong></a><img id="gender_$uid" style="display:none;width:12px;height:12px"/><br/>\
									会员编码：<a href="/mygroup.php?uid=$uid" target="_blank"><strong id="loginname_$uid">[读取中...]</strong></a>\
								</div>\
								<img src="http://image2.sina.com.cn/pay/quanzi/order/card/close.gif" style="float:right;width:9px;height:9px;cursor:pointer;" id="close_$uid"/>	  </td>\
					  </tr>\
					  <tr>\
					   	<td valign="top" style="width:160px;padding:5px 0 3px 0">\
							<div style="border-right:1px solid #dedede;margin:0 3px 3px 0;padding-right:3px;color:#3e2cb0">\
								<div style="color:#7d7d7d">个人简介：</div>\
								<div id="intro_$uid" style="width:155px;height:50px;word-break:break-all;overflow:hidden;line-height:18px">读取中...</div>\
							</div>\
							</td>\
					   	 <td style="line-height:24px;width:50px;padding:5px 0 3px 0"" valign="bottom">\
						 	 	<img src="http://image2.sina.com.cn/pay/quanzi/order/card/friend.gif" style="cursor:pointer" alt="加为好友" id="friend_$uid"/><br />\
					   	   <img src="http://image2.sina.com.cn/pay/quanzi/order/card/scrip.gif" style="margin-top:3px;cursor:pointer" alt="发纸条" id="scrip_$uid"/>\
							</td>\
					  </tr>\
					  <tr>\
					    <td colspan="3" style="text-align:center;padding-top:5px;margin-top:5px;vertical-align:top;background:url(http://image2.sina.com.cn/pay/quanzi/order/card/solid.gif) no-repeat top center">\
						  	<div style="color:#d9d9d9;padding:3px 0 0 0;text-align:center">\
								<a href="http://blog.sina.com.cn/u/$uid" target="_blank">博客</a>　|　<a href="http://v.blog.sina.com.cn/m/$uid" target="_blank">播客</a>　|　<a href="http://bbs.service.sina.com.cn/forum/disprofile.php?uid=$uid" target="_blank">论坛</a>　|　<a href="/mygroup.php?uid=$uid" target="_blank">圈子</a>\
							</div>\
						  </td>\
					  </tr>\
					</table>'
		div.innerHTML=html.replace(/\$uid/gi,uid)
		document.body.appendChild(div)
		
		var shadow=document.createElement("div")
		shadow.id="shadow_"+uid
		shadow.className="q_cardshadow"
		shadow.style.cssText="width:310px !important;width:312px"
		if(navigator.userAgent.inc("IE 7"))
			shadow.style.cssText="width:310px"
		var sTop=xy[0]
		if(obj.getAttribute("tag")=="master"){
			sTop=sTop-$("master").scrollTop
		}
		
		div.style.top=sTop+"px"
		shadow.style.top=(sTop+6)+"px"
		if(document.body.clientWidth/2<xy[1]){
			div.style.left=(xy[1]-div.offsetWidth-6)+"px"
			shadow.style.left=(xy[1]-div.offsetWidth-6+4)+"px"
		}else{
			div.style.left=(xy[1]+xy[2]+2)+"px"
			shadow.style.left=(xy[1]+xy[2]+2+4)+"px"
		}
		shadow.style.height=div.offsetHeight+"px"
		document.body.appendChild(shadow)
		SetAjax("/control/get_usrinfo.php","post:uid="+uid,"showinfo")
		var eventclose=function(e){
			e=e||event
			try{
				var ee=e.srcElement
				if(ee.getAttribute("mp")!=null){
					if($("userinfo_"+ee.getAttribute("mp"))&&$("userinfo_"+ee.getAttribute("mp")).style.display=="")
						return
				}
				if(ee!=obj){
					while(ee){
							if(ee==div)
								return
							if(ee.tagName=="HTML"){
								div.style.display=shadow.style.display="none"
								return
							}
							ee=ee.parentNode
					}
				}
			}catch(e){}
		}
		_q_addEvent(document.body,"onmousedown",eventclose)
		$("close_"+uid).onclick=function(){
			div.style.display="none"
			shadow.style.display="none"
		}
	}
}
function showinfo(xml){
	var uid=xv(xml,"uid")
	var loginname=xv(xml,"loginname")
	$("loginname_"+uid).innerHTML=uid
	var icon=xv(xml,"icon")
	$("icon_"+uid).src=icon
	var nickname=xv(xml,"nickname")
	if(nickname=="")
		nickname=loginname
	$("nickname_"+uid).innerHTML=nickname
	var intro=xv(xml,"intro")
	if(intro=="-")
		intro="-<br><br>"
	$("intro_"+uid).innerHTML='<a href="/mygroup.php?uid='+uid+'" target="_blank" style="line-height:18px">'+intro+'</a>'
	$("intro_"+uid).title=intro.replace("<br><br>","").replace(/\'/g,"").replace(/\"/g,"").replace(/&quot;/g,"")
	var gender=xv(xml,"gender")
	$("gender_"+uid).src=gender
	$("gender_"+uid).style.display=""
	
	$("friend_"+uid).onclick=function(){
		add_friend(uid)
		$("userinfo_"+uid).style.display="none"
		$("shadow_"+uid).style.display="none"
	}
	$("scrip_"+uid).onclick=function(){
		Scrip(nickname,uid)
		$("userinfo_"+uid).style.display="none"
		$("shadow_"+uid).style.display="none"
	}
	$("shadow_"+uid).style.height=$("userinfo_"+uid).offsetHeight+"px"
}

//触发留言数
function sethint(xml){
	var s=xv(xml,"result")
	//暂时取消弹出框，改为更新页面区域
	//$_hint(s)
	if(typeof(draw_msg_account)=="function"){
		draw_msg_account(s)
	}
}
function $gethint(){
	if(ISlogin(false)!=1)
		return
	SetAjax("/control/friends/countmsg.php?code=utf&fromid="+myuid,"","sethint")
}


window.setTimeout("$gethint()",3000)