// 处理浏览器
var Browser = 'Unknown';
if (navigator.appName.indexOf("Microsoft")!= -1) {
	Browser = "IE";
}
if (navigator.appName.indexOf("Netscape")!= -1){
	Browser = "FF";
}
String.prototype.trim = function() { return this.replace(/(^(\s|　)*)|((\s|　)*$)/g, ""); }
String.prototype.reallength = function(){return this.replace(/[^\x00-\xff]/g,"^^").length;}

Array.prototype.indexOf = function(v){
	for(var i=0;i<this.length;i++){
		if( this[i]==v ){
			return i;
		}
	}
	return -1;
}
// 随机串
function randomString(){
	return parseInt(Math.random()*999999);
}
// 按长度截取字符串，一个汉字占2个字符
function truncateLength(string,length,dt){
	if( dt==undefined ){
		dt = '...';
	}
	var real_len = String(string).reallength();
	var len = string.length;
	var i = 0;
	var s = ns = '';
	if( real_len<=length ){
		return string;
	}
	for(i=1;i<=len;i++){
		ns = string.substr(0,i);
		if( ns.reallength()>length ){
			return s+dt;
		}
		s = ns;
	}
	return s+dt;
}
function $$(id){
	if( typeof(id)== "string" ){
		return document.getElementById(id);
	}
	else if( typeof(id)=="object" ){
		return id;
	}
}
function getElementById(id){
	return $('#'+id)[0];
}
// 评估密码强度
function ass_pwd_strength(pwd){
	var level = -1;
	if ( pwd.match(/[a-z]/ig) ){
		level++;
	}
	if ( pwd.match(/[0-9]/ig) ){
		level++;
	}
	if ( pwd.match(/(.[^a-z0-9])/ig) ){
		level++;
	}
	if ( pwd.length<6 && level>0 ){
		level--;
	}
	return level;
}
// 检测并设置字数
function countContentLen(id,len){
	var content = $("#"+id).val();
	content = $.trim(content);
	if( content.length>len ){
		content = content.substr(0,len);
		$("#"+id).val(content);
	}
}
// 验证邮件格式是否正确
function checkEmail(email){
	return email.match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/)
}
// 根据跟定的月份和日期，获取星座数据
function getAstro(v_month, v_day){
	v_month = parseInt(v_month,10)
	v_day = parseInt(v_day,10);
	if ((v_month==12&&v_day>=22) || (v_month==1&&v_day<=20)){
		return "魔羯座";
	}
	else if ((v_month == 1 && v_day >= 21) || (v_month == 2 && v_day <= 19)){
		return "水瓶座";
	}
	else if ((v_month == 2 && v_day >= 20) || (v_month == 3 && v_day <= 20)){
		return "双鱼座";
	}
	else if ((v_month == 3 && v_day >= 21) || (v_month == 4 && v_day <= 20)){
		return "白羊座";
	}
	else if ((v_month == 4 && v_day >= 21) || (v_month == 5 && v_day <= 21)){
		return "金牛座";
	}
	else if ((v_month == 5 && v_day >= 22) || (v_month == 6 && v_day <= 21)){
		return "双子座";
	}
	else if ((v_month == 6 && v_day >= 22) || (v_month == 7 && v_day <= 22)){
		return "巨蟹座";
	}
	else if ((v_month == 7 && v_day >= 23) || (v_month == 8 && v_day <= 23)){
		return "狮子座";
	}
	else if ((v_month == 8 && v_day >= 24) || (v_month == 9 && v_day <= 23)){
		return "处女座";
	}
	else if ((v_month == 9 && v_day >= 24) || (v_month == 10 && v_day <= 23)){
		return "天秤座";
	}
	else if ((v_month == 10 && v_day >= 24) || (v_month == 11 && v_day <= 22)){
		return "天蝎座";
	}
	else if ((v_month == 11 && v_day >= 23) || (v_month == 12 && v_day <= 21)){
		return "射手座";
	}
	return "";
}
// 获取指定月份的天数
function getDays(year , month){
	year = parseInt(year,10);
	month = parseInt(month,10);
	var dayarr = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

	if(month == 2){
		if((year%4 == 0 && year%100 != 0) || year%400 == 0 || year < 1900){
			return 29;
		}
		else{
			return dayarr[month-1];
		}
	}
	else{
		return dayarr[month-1];
	}
}

// 根据年和月的控件，设置日的控件
function setMonthDay(y_id,m_id,d_id,d_v){
	var year = $('#'+y_id).val();
	var month = $('#'+m_id).val();
	var days = getDays(year,month);
	var obj = document.getElementById(d_id);
	d_v = parseInt(d_v,10);
	var last_v = obj.value;
	clearSelectOptions(obj);
	var s = 0;
	for(var i=1;i<=days;i++){
		var j = i<10?'0'+i:i;
		obj.options[obj.length] = new Option( j , j );
		if( (isNaN(d_v)&&i==last_v)||i==d_v ){
			s = i-1;
		}
	}
	obj.options[s].selected = true;
}

//显示对象
function show(el){
	if( typeof(el)=='object' ){
		el.style.display = '';
	}
	else if( typeof(el)=='string' ){
		$$(el).style.display = '';
	}
}

// 隐藏对象
function hidden(el){
	if( typeof(el)=='object' ){
		el.style.display = 'none';
	}
	else if( typeof(el)=='string' ){
		$$(el).style.display = 'none';
	}
}

// 删除节点
function remove_node(d){
	if ($$(d)){
		$$(d).parentNode.removeChild($$(d));
	}
}
//清空一个元素的所有节点
function removeChildren(obj){
	while(obj.hasChildNodes()){
		obj.removeChild(obj.firstChild);
	}
}
//清空select的选项
function clearSelectOptions(obj){
    while(obj.length>0)
		obj.remove(0);
	obj.length=0;
}

// 获得元素位置
function getpos(element){
	if ( arguments.length != 1 || element == null ){
		return null;
	}
	var elmt = element;
	var offsetTop = elmt.offsetTop;
	var offsetLeft = elmt.offsetLeft;
	var offsetWidth = elmt.offsetWidth;
	var offsetHeight = elmt.offsetHeight;
	while( elmt = elmt.offsetParent ){
		// add this judge
		if ( elmt.style.position == 'absolute' || elmt.style.position == 'relative'  
            || ( elmt.style.overflow != 'visible' && elmt.style.overflow != '' ) ) { 
            break; 
        }  
		offsetTop += elmt.offsetTop;
		offsetLeft += elmt.offsetLeft;
	}
	return {top:offsetTop, left:offsetLeft, right:offsetWidth+offsetLeft, bottom:offsetHeight+offsetTop };
}

// 判断child_node是否是parent_node的子节点或孙子节点
function isChild(child_node,parent_node){
	var elmt = $$(child_node);
	while( elmt=elmt.offsetParent ){
		if( elmt==parent_node ){
			return true;
		}
	}
	return false;
}

// 后退
function goBack(deep){
	window.history.go(deep);
}

// 复制到剪切板
function copyToClipboard(text){
	if (window.clipboardData) {
		window.clipboardData.setData("Text",text);
	} 
	else {
		var flash_copy = null;
		if( !$$('flash_copy') ){
			var flash_copy = document.createElement("div");
			flash_copy.id = 'flash_copy';
			document.body.appendChild(flash_copy);
		}
		flash_copy = $$('flash_copy');
		flash_copy.innerHTML = '<embed src="/images/flash/_clipboard.swf" FlashVars="clipboard='+escape(text)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
	}
	return true;
}

//=====================遮罩弹窗处理============
var bgDiv,frameShim,messageDiv;
/** 遮罩弹窗
 * @param title		窗口标题
 * @param content	内容区域内容
 * @param default_menu 信息下面是否自动带“确定
 * @param width		窗口宽度		可留空
 * @param height	内容区域高度	可留空
 * @param top		窗口位置（上）可留空
 * @param left		窗口位置（左）可留空
**/
function MessageBox(title,content,bottom_menu,height,width,top,left){
	if( bgDiv!=null ){
		return false;
	}
	// 处理高度
	var offsetWidth = parseInt(document.body.offsetWidth,10);
	var offsetHeight = parseInt(document.body.offsetHeight,10);
	var scrollWidth = parseInt(document.body.scrollWidth,10);
	var scrollHeight = parseInt(document.body.scrollHeight,10);
	var default_message_width = 320;
	var default_message_height = 300;
	//var win_width = offsetWidth;
	var win_width = Math.max(offsetWidth,scrollWidth,screen.availWidth)-20;
	//alert(offsetWidth+' '+scrollWidth+' '+screen.availWidth);
	var win_height = Math.max(offsetHeight,scrollHeight,screen.availHeight-100)+20;
	//var win_height = offsetHeight + 20;
	scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
	//
	width = parseInt(width,10);
	height = parseInt(height,10);
	top = parseInt(top,10);
	left = parseInt(left,10);
	if( isNaN(width) ){
		width = default_message_width;
	}
	if (isNaN(height) ){
		height = default_message_height;
	}
	width = width<100?default_message_width:width;
	height = height<30?default_message_height:height;
	if( isNaN(top) ){
		top = 100;
	}
	top = scrollTop+100;
	if( isNaN(left) ){
		left = (offsetWidth-width-20)/2;
	}
	// 创建背景
	bgDiv = document.createElement("div");
	bgDiv.setAttribute('id','bgDiv');
	bgDiv.style.position	= "absolute";
	bgDiv.style.zIndex		= "9998";	
	bgDiv.style.top			= "0";
	bgDiv.style.background	= "#000";
	bgDiv.style.filter		= "progid:DXImageTransform.Microsoft.Alpha(style=1,opacity=30,finishOpacity=70)";
	bgDiv.style.opacity		= "0.7";
	bgDiv.style.left		= "0";
	//bgDiv.style.width		= "100%";
	bgDiv.style.width		= win_width + 'px';
	bgDiv.style.height		= win_height + "px";
	//bgDiv.style.height		= '100%';
	document.body.appendChild(bgDiv);
	// 创建shim frame
	frameShim = document.createElement('iframe');
	frameShim.setAttribute('id','frameShim');
	frameShim.setAttribute("src","about:blank",0);
	frameShim.style.width	= bgDiv.style.width; 
	frameShim.style.height	= bgDiv.style.height; 
	frameShim.style.top		= bgDiv.style.top; 
	frameShim.style.left	= bgDiv.style.left; 
	frameShim.style.position	= "absolute";
	frameShim.frameBorder	= 0;
	frameShim.scrolling		= "no";
	frameShim.style.filter	= "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=30)";
	frameShim.style.opacity	= "0.4";
	frameShim.style.zIndex	= '9997'; 
	frameShim.style.display	= "block";
	document.body.appendChild(frameShim);
	// 处理内容区域
	messageDiv = document.createElement("div");
	messageDiv.setAttribute('id','messageDiv');
	messageDiv.style.position	= "absolute";
	messageDiv.style.zIndex		= "9999";
	messageDiv.style.left		= left+'px';
	messageDiv.style.width		= width+'px';
	messageDiv.style.top		= top+'px';
	var html = '<div class="tBorder" style="width:'+width+'px">\
                	<div class="tBorder1">\
                    	<h2 class="tBoxH2"><span class="right"><a href="javascript:void(0);" onclick="closeMessageBox();"><img id="close_window_s" src="/images/s_window/bg10.gif" width="8" height="8" alt="关闭" /></a></span>'+title+'</h2>\
                        <div class="tBox">\
                        <div class="s_scroll" style="height:'+height+'px;">'+content+'</div>\
                        ';
	if( bottom_menu!=undefined ){
		html += '<div class="blank10"></div><div class="s_w_box_1_box2">'+bottom_menu+'</div><div class="clear"></div>';
	}
    html += '			</div>\
    				</div>\
                </div>';
	document.body.appendChild(messageDiv);
	messageDiv.innerHTML = html;
	//bgDiv.appendChild(messageDiv);
}
//关闭遮罩弹窗
function closeMessageBox(){
	if( messageDiv!=null ){
		document.body.removeChild(messageDiv);
	}
	if( bgDiv!=null ){
		document.body.removeChild(bgDiv);
	}
	if( frameShim!=null ){
		document.body.removeChild(frameShim);
	}
	bgDiv		= null;
	frameShim	= null;
	messageDiv	= null;
	window.focus();
}
// 快捷弹窗处理，类似Alert
function MyAlert(msg,title){
	if( title==undefined ){
		title = "提示信息";
	}
	var bottom_menu = '<input name="s_close_btn" id="s_close_btn" value="确定" type="button" class="btn_2" onclick="closeMessageBox();" />';
	MessageBox(title,msg,bottom_menu,50);
}

// ====================弹窗结束=========

// ====================浮动弹窗=========
// 浮动窗列表
var float_window_list = [];
function getFloatWindowZIndexMaxMin(){
	var len = float_window_list.length;
	var max_min = {'min':5000,'max':5000}
	for(var i=0;i<len;i++){
		if( float_window_list[i]['z_index']<max_min['min'] ){
			max_min['min'] = float_window_list[i]['z_index'];
		}
		if( float_window_list[i]['z_index']>max_min['max'] ){
			max_min['max'] = float_window_list[i]['z_index'];
		}
	}
	return max_min;
}
// 浮动窗口
function FloatWindow(float_id,title,content,can_move,opacity,width,height,top,left){
	// 处理数据
	if( can_move!=true ){
		can_move = false;
	}
	opacity = parseInt(opacity,10);
	if( isNaN(opacity) ){
		opacity = 100;
	}
	width = parseInt(width,10);
	if( isNaN(width) ){
		width = 400;
	}
	height = parseInt(height,10);
	if( isNaN(height) ){
		height = 400;
	}
	top = parseInt(top,10);
	if( isNaN(top) ){
		top = 100;
	}
	left = parseInt(left,10);
	if( isNaN(left) ){
		left = 200;
	}
	// 窗口信息
	var window_info = {};
	var max_min = getFloatWindowZIndexMaxMin();
	var div = document.createElement("div");
	if( float_id!="" ){
		$("#"+float_id).remove();
		window_info['id'] = float_id;
	}
	else{
		window_info['id'] = 'float_'+parseInt(Math.random()*999999);
	}
	window_info['z_index'] = max_min['max']+1;
	div.setAttribute('id',window_info['id']);
	div.style.position	= "absolute";
	div.style.zIndex	= window_info['z_index'];
	div.style.left		= left+'px';
	div.style.width		= width+'px';
	div.style.top		= top+'px';
	if( opacity!=100 ){
		//div.style.filter	= "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity="+opacity+")";
		div.style.filter	= "alpha(style=0,opacity="+opacity+")";
		div.style.opacity	= opacity/100;
	}
	float_window_list[window_info.length] = window_info;
	var html = '<div class="tBorder" style="width:'+width+'px">\
                	<div class="tBorder1">\
                    	<h2 class="tBoxH2"><span class="right"><a href="javascript:void(0);" onclick="closeFloatWindow(\''+window_info['id']+'\');"><img id="close_window_s" src="/images/s_window/bg10.gif" width="8" height="8" alt="关闭" /></a></span>'+title+'</h2>\
                        <div class="tBox">\
                        	<div class="s_scroll" style="height:'+height+'px;">'+content+'</div>\
						</div>\
    				</div>\
                </div>';
	document.body.appendChild(div);
	div.innerHTML = html;
	if( can_move==true ){
		$('#'+window_info['id']).Draggable(
		{
			ghosting:	true,
			opacity:	0.5,
			fx:			300
		}
		);
	}
}
// 关闭窗口
function closeFloatWindow(id){
	var obj = $("#"+id)[0];
	if( obj ){
		obj.parentNode.removeChild(obj);
	}
}
// ==============浮动弹窗结束============

// ==============加好友处理==============
// 加f_uid为好友
function f_addFriend(f_uid){
	// 获取f_uid的好友设置
	$.getJSON(
		'/interface/friend.php',
		{'_a':'check_to_add','f_uid':f_uid,'rnd':randomString()},
		function(data){
			if( data['success'] ){
				f_addFriendPanle(data['f_user_info']);
			}
			else{
				alert(data['desc']);
			}
		}
	);
}
// 填写好友请求信息的面板
function f_addFriendPanle(user){
	// 创建分组面板
	var title = '请求加'+user['gender_ta']+'为好友';
	var html = '\
	<div class="add_friend_l">\
		<div class="PT_span head_img_bg mauto"><div class="head_img_Box"></div><img src="'+user['photo_url']+'" width="60" height="60" alt="'+user['name']+'" /></div>\
	</div>\
	<div class="add_friend_r">\
		<p class="lh24">需通过'+user['name']+'的验证才能加'+user['gender_ta']+'为好友。<br />给'+user['gender_ta']+'的附加信息：</p>\
		<textarea name="add_friend_remark" id="add_friend_remark" rows="15" cols="36" class="t_in1" onfocus="this.className=\'t_in2\';" onblur="this.className=\'t_in1\';" style="width:215px; height:60px" ></textarea>\
		<div class="blank10"></div>\
	</div>';
	var bottom_menu = '<input name="m_btn" value="确定" type="button" class="rb1" onclick="f_addFriendSave('+user['uid']+');" /> <input class="btn_grey" id="btn_sc" title="取消" type="button" onclick="closeMessageBox();" value="取消" />';
	MessageBox(title,html,bottom_menu,130,360);
}
// 保存添加好友操作
function f_addFriendSave(f_uid){
	var remark = $.trim($("#add_friend_remark").val());
	if( !remark ){
		alert('请输入好友附加信息！');
		$('#add_friend_remark').focus();
		return false;
	}
	closeMessageBox();
	// 加好友
	$.post(
		'/interface/friend.php',
		{'_a':'add_friend','f_uid':f_uid,'remark':remark,'rnd':randomString()},
		function(data){
			if( data['success'] ){
				alert('你已经申请加'+data['f_user_info']['name']+'为好友，请等待'+data['f_user_info']['gender_ta']+'审核');
			}
			else{
				alert(data['desc']);
			}
		},
		'json'
	);
}

// =================加好友处理结束============

// ======================统一的提示处理，3秒钟自动隐藏=====
// 显示提示层
function showNotice(msg,success,longchar){
	var notice_div = $$('notice_div');
	if( success!=1 ){
		success = 1;
	}
	if( longchar!=1 ){
		longchar = 0;
	}
	if( notice_div ){
		var html = '';
		if( success==1 ){
			var class_name = 'remind_bg_5';
			if( longchar==0 ){
				class_name = 'remind_bg_5 a_m_nav_remind';
			}
			// 成功提示框
			var html = '\
			<div class="'+class_name+'">\
				<div class="remind_bg_5_box">\
				<img src="'+_img_url+'/images/bg35.gif" width="22" height="16" alt="成功" align="absmiddle" /> '+msg+'\
				</div>\
				<div class="remind_bg_5_bot"></div>\
				<div class="blank10"></div>\
			</div>\
			';
		}
		else{
			var class_name = 'wront_remind';
			if( longchar==0 ){
				class_name = 'wront_remind a_m_nav_remind';
			}
			// 失败提示框
			var html = '\
			<div class="'+class_name+'">\
				<div class="wront_remind_box">\
					<img src="'+_img_url+'/images/bg35_w.gif" width="16" height="16" alt="失败" align="absmiddle" />　'+msg+'\
				</div>\
				<div class="wront_remind_bot"></div>\
			</div>\
			';
		}
		notice_div.innerHTML = html;
		notice_div.style.display = 'block';
		// 设置几秒后自动隐藏成功提示框
		window.setTimeout(hiddenNotice,3000); 
	}
}
// 隐藏消息提示层
function hiddenNotice(){
	var notice_div = $$('notice_div');
	if( notice_div ){
		notice_div.style.display = 'none';
	}
}

// ================统一的提示处理，3秒钟自动隐藏 结束=====
// ================获取短消息的定时器==============
var ori_web_title = '';
var cron_msg_title_flash = null;
/**
 * 读取最新的消息信息
 */
function cronNewMessage(timeout){
	if( timeout==undefined ){
		timeout = 20000;
	}
	if( ori_web_title=='' ){
		ori_web_title = document.title;
	}
	var pars = '_a=new_msg&timeout='+timeout+'&rid='+randomString();
	var url = '/interface/message.php';
	var param = {'_a':'new_msg','timeout':timeout,'rnd':randomString()};
	$.post(
		url,
		param,
		function(ret){
			var timeout = ret['timeout'];
			cronNewMessageResult(ret);
			timeout = parseInt(timeout,10);
			if( timeout<1 ){
				timeout = 20000;
			}
			window.setTimeout(cronNewMessage,timeout);
		},
		'json'
	)
}

// 窗口标题闪现
function cronNewMessageSetTitle(){
	var now_title = document.title;
	if( ori_web_title==now_title ){
		document.title = '【有新消息】'+ori_web_title;
	}
	else{
		document.title = ori_web_title;
	}
}

// 设置消息
function cronNewMessageResult(num_result){
	var html = '';
	// 总数量
	var new_num = parseInt(num_result['new'],10);
	var msg_num = parseInt(num_result['msg'],10);
	var sys_num = parseInt(num_result['sys'],10);
	var guestbook_num = parseInt(num_result['guestbook'],10);
	// 显示消息得对象
	// 顶部
	var top_message_new_obj = $$("top_message_new_div");
	// 我的首页
	var my_message_new_obj = $$("my_message_new_div");
	
	// 显示
	// 设置顶部
	if( top_message_new_obj ){
		if( new_num>0 ){
			top_message_new_obj.innerHTML = '消息 <font color="red">('+new_num+')</font>';
		}
		else{
			top_message_new_obj.innerHTML = '消息';
		}
	}
	// 设置首页
	if( my_message_new_obj ){
		if( new_num>0 ){
			my_message_new_obj.innerHTML = new_num;
			my_message_new_obj.className = 'red';
		}
		else{
			my_message_new_obj.innerHTML = '0';
			my_message_new_obj.className = '';
		}
	}
	// 处理声音
	html = '';
	if( new_num>0&&num_result['sound']==1 ){
		html = '<object id="MediaPlayer1" width="0" height="0" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" align="baseline" border="0" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"><param name="URL" value="/images/msg.mid"><param name="autoStart" value="true"><param name="volume" value="100"><param name="invokeURLs" value="false"><param name="playCount" value="1"><param name="defaultFrame" value="datawindow"><embed src="/images/msg.mid" align="baseline" border="0" width="0" height="0" type="application/x-mplayer2"pluginspage="" name="MediaPlayer1" showcontrols="1" showpositioncontrols="0" showaudiocontrols="1" showtracker="1" showdisplay="0" showstatusbar="1" autosize="0" showgotobar="0" showcaptioning="0" autostart="1" autorewind="0" animationatstart="0" transparentatstart="0" allowscan="1" enablecontextmenu="1" playcount="1" clicktoplay="0" defaultframe="datawindow" invokeurls="0" volume="100"></embed></object>';
	}
	if( $$('top_msgsound_div') ){
		$$('top_msgsound_div').innerHTML = html;
	}
}

//  ======================关注用户
function attentionUser(obj_id,type,is_img){
	if( type!='cancle' ){
		type = 'add';
	}
	if( is_img!=1 ){
		is_img = 0;
	}
	at_uid = $("#"+obj_id).attr("uid");
	at_uid = parseInt(at_uid,10);
	if( isNaN(at_uid)||at_uid<1 ){
		alert("错误的用户");
		return false;
	}
	var url = '/interface/user.php';
	var param = {'_a':'attention_user','obj_id':obj_id,'at_uid':at_uid,'type':type,'is_img':is_img,'rnd':randomString()};
	$.post(
		url,
		param,
		function(ret){
			if( ret['succ']==1 ){
				var type = ret['type'];
				var at_uid = ret['at_uid'];
				var obj_id = ret['obj_id'];
				var is_img = ret['is_img'];
				var obj = $$(obj_id);
				if( obj!=undefined&&obj!=null ){
					if( type=='cancle' ){
						if( is_img==1 ){
							obj.src = '/images/ionguanzhu.gif';
							obj.onclick = function(){
								attentionUser(this.id,'',1);
							};
						}
						else{
							obj.innerHTML = "加关注";
							obj.onclick = function(){
								attentionUser(this.id,'');
							};
						}
						alert("取消关注成功");
					}
					else{
						if( is_img==1 ){
							obj.src = '/images/ionquxguanzhu.gif';
							obj.onclick = function(){
								attentionUser(this.id,'cancle',1);
							};
						}
						else{
							obj.innerHTML = "取消关注";
							obj.onclick = function(){
								attentionUser(this.id,'cancle');
							};
						}
						alert("已添加到关注列表");
					}
				}
			}
			else{
				alert(ret['desc']);
			}
		},
		'json'
	)
}

// =======================================显示足迹==================
var zuji_comment_mid = 1001;
var window_zj_id = 0;
// 每次显示4个图片
var window_zuji_image_page = 1;
var window_zuji_image_limit = 4;
var window_zuji_image_list = [];
var window_zuji_image_list_index = 0;
var window_zuji_image_list_start = 0;
var window_zuji_image_list_end = 0;
var window_zuji_has_image = 0;
// 显示前一页图片
function showZujiBigImageWindowPre(){
	var max = window_zuji_image_list.length;
	if( window_zuji_image_page<2 ){
		return false;
	}
	window_zuji_image_page--;
	showZujiBigImageListWindow();
}
// 显示后一页图片
function showZujiBigImageWindowNext(){
	var max = window_zuji_image_list.length;
	if( window_zuji_image_page*window_zuji_image_limit>=max ){
		return false;
	}
	window_zuji_image_page++;
	showZujiBigImageListWindow();
}
// 显示从start到end的图片
function showZujiBigImageListWindow(){
	var start = (window_zuji_image_page-1)*window_zuji_image_limit;
	var end = window_zuji_image_page*window_zuji_image_limit-1;
	var html = '';
	html += '<li style="padding:10px 0 0 0"><a href="javascript:void(0);" onclick="showZujiBigImageWindowPre();"><img src="/images/ion_02.gif" border="0" /></a></li>';
	for(var i=start;i<=end&&i<window_zuji_image_list.length;i++){
		if( i==start ){
			showZujiBigImageWindow(window_zuji_image_list[i]['thumb_image_url'],window_zuji_image_list[i]['big_image_url'],window_zuji_image_list[i]['remark']);
		}
		html += '<li><a href="javascript:void(0);" onclick="showZujiBigImageWindow(\''+window_zuji_image_list[i]['thumb_image_url']+'\',\''+window_zuji_image_list[i]['big_image_url']+'\',\''+window_zuji_image_list[i]['remark']+'\');"><img src="'+window_zuji_image_list[i]['thumb_image_url']+'" width="48" height="48" border="0" title="'+window_zuji_image_list[i]['remark']+'" /></a></li>';
	}
	html += '<li style="padding:10px 0 0 0"><a href="javascript:void(0);" onclick="showZujiBigImageWindowNext();"><img src="/images/ion_03.gif" border="0" /></a></li>';
	$("#zuji_image_list_window_div").html(html);
}
// 加入收藏
function addZujiToFav(zj_id){
	var ajax_url = '/interface/shenying.php';
	var param = {'_a':'add_fav','zj_id':zj_id};
	$.getJSON(ajax_url,param,function(ret){
		if( ret['succ']==1 ){
			alert("加入收藏成功");
		}
		else{
			alert(ret['desc']);
		}
	});
}
// 保存窗口中的身影评论
function saveZujiCommentWindow(zj_id){
	var content = $("#window_comment_content").val();
	if( content.length<3 ){
		alert("评论内容不能少于3个字");
		return false;
	}
	if( content.length>200 ){
		alert("评论内容不能超过200个字");
		return false;
	}
	var ajax_url = '/comment/index.php';
	var param = {
		'_a':'save',
		'mid':zuji_comment_mid,
		'ident_id':zj_id,
		'content':content,
		"rnd":randomString()
	};
	$.post(
		ajax_url,
		param,
		function(data){
			if( data['succ']==1 ){
				alert("评论成功");
				$("#window_comment_content").val('');
				showZujiCommentWindow();
			}
			else{
				alert(data['desc']);
			}
		},
		'json'
	);
}
// 窗口中显示评论
function showZujiCommentWindow(query_string){
	var param = {"limit":5,"callback":"showZujiCommentWindow","rnd":randomString()};
	if( typeof(query_string) == 'undefined' ){
		url = '/comment/index.php?_a=get_list&mid='+zuji_comment_mid+'&ident_id='+window_zj_id;
	}
	else{
		url += '?'+query_string;
	}
	$.getJSON(
		url,
		param,
		function(data){
			var comment_list = data['data']['comment_list'];
			var page_string = data['data']['page_string'];
			var html = '';
			var item = null;
			if( comment_list.length==0 ){
				html = '<li><p>还没有评论</p></li>';
			}
			for(var i=0;i<comment_list.length;i++){
				item = comment_list[i];
				html += '\
				<li>\
					<div class="liuyan_pic"><img src="'+item['user_info']['photo_url']+'" width="20" height="20" /><span><a href="'+item['user_info']['link']+'" title="'+item['user_info']['name']+'">'+item['user_info']['name']+'</a></span><span style="float:right; width:120px; text-align:right;">'+item['ctime']+'</span></div>\
					<p>'+item['content']+'</p>\
					<div class="clear"></div>\
				</li>\
				';
			}
			$("#window_comment_list_div").html(html);
			$("#window_comment_pagestring_div").html(page_string);
		}
	);
}
// 显示身影大图
function showZujiBigImageWindow(thumb_photo_url,big_photo_url,src_photo_url,remark){
	//var img = new Image();
	//.src = big_photo_url;
	if( window_zuji_has_image==1 ){
		$("#zuji_big_image_window").html('<a href="###" title="点击放大" style="cursor:pointer;" onclick="showZujiBigImagePicWindow(\''+thumb_photo_url+'\',\''+src_photo_url+'\');return false;"><img src="'+thumb_photo_url+'" width="240" height="165" /></a>');
	}
	else{
		$("#zuji_big_image_window").html('<img src="'+thumb_photo_url+'" width="240" height="165" />');
	}
	$("#zuji_big_image_window_desc").html(remark);
	var img = new Image();
	img.onload = function(){
		var src_url = this.getAttribute("src_url");
		var url = this.src;
		if( window_zuji_has_image==1 ){
			$("#zuji_big_image_window").html('<a href="###" title="点击放大" style="cursor:pointer;" onclick="showZujiBigImagePicWindow(\''+url+'\',\''+src_url+'\');return false;"><img src="'+url+'" width="240" height="165" /></a>');
		}
		else{
			$("#zuji_big_image_window").html('<img src="'+url+'" width="240" height="165" />');
		}
	}
	try{
		img.setAttribute("src_url",src_photo_url);
	}
	catch(e){
		
	}
	img.src = big_photo_url;
}
// 图片点击大图
function showZujiBigImagePicWindow(big_photo_url,src_photo_url){
	var html = '\
	<div style="padding:10px 0px; text-align:center;">\
	<a href="###" onclick="hideZujiBigImagePicWindow();return false;" title="点击切换回详细信息"><img src="'+big_photo_url+'" /></a>\
	<div class="tankPh"><img src="/images/tankPhbig.gif" align="absmiddle" /> <a href="'+src_photo_url+'" target="_blank">查看原图</a></div>\
	</div>';
	$("#zj_info_window_pic_div").html(html);
	$("#zj_info_window_div").hide();
	$("#zj_info_window_pic_div").show();
}
// 隐藏大图
function hideZujiBigImagePicWindow(){
	$("#zj_info_window_pic_div").hide();
	$("#zj_info_window_div").show();
}
// 显示某个身影的详细
function showZujiDetailWindow(zj_id){
	if( zuji_info[zj_id]==undefined ){
		return false;
	}
	MessageBox('请稍等','正在读取身影信息，请稍等...','',100);
	var ajax_url = '/interface/shenying.php';
	var param = {'_a':'get_zuji_info','zj_id':zj_id,'rnd':randomString()};
	$.getJSON(
		ajax_url,
		param,
		function(ret){
			closeMessageBox();
			if( ret['succ']!=1 ){
				alert(ret['desc']);
				return false;
			}
			/** 具体显示部分start **/
			window_zuji_image_list = [];
			window_zuji_image_list_start = 0;
			window_zuji_image_list_end = 0;
			window_zuji_image_list_index = 0;
			var info = ret['zj_info'];
			var image_list = ret['image_list'];
			var visited_list = ret['visited_list'];
			var title = '<a href="'+info['user_info']['link']+'">'+info['user_info']['name']+'</a>的身影';
			var html = 'ID:'+zj_id;
			html = '\
	<div id="zj_info_window_pic_div"></div>\
	<div id="zj_info_window_div">\
	<div class="map_xiangqingL">\
		<div class="textTk">'+truncateLength(info['content'],140)+'</div>';
			if( image_list.length==0 ){
				window_zuji_has_image = 0;
				image_list[0] = {
					'thumb_image_url':'/images/shenying_nophoto_small.jpg',
					'big_image_url':'/images/shenying_nophoto.jpg',
					'remark':''
				};
				ret['first_image'] = {
					'thumb_image_url':'/images/shenying_nophoto_small.jpg',
					'big_image_url':'/images/shenying_nophoto.jpg',
					'remark':''
				};
			}
			else{
				window_zuji_has_image = 1;
			}
			if( image_list.length>0 ){
				var temp_image_list = [];
				for(var ii=0;ii<image_list;ii++){
					temp_image_list[ii] = new Image();
					temp_image_list[ii].src = image_list[ii]['thumb_image_url'];
				}
				html += '<div class="photoTk">\
			<div style="clear:both;">\
				<p style="padding:0 5px 5px; color:#999;">发布时间：'+info['create_time']+'</p>\
				<p id="zuji_big_image_window"></p>\
				<p class="tk01" id="zuji_big_image_window_desc"></p>\
			</div>\
			<ul style="padding:20px 0;*padding:19px 0;" id="zuji_image_list_window_div">\
				<li style="padding:10px 0 0 0"><a href="javascript:void(0);" onclick="showZujiBigImageWindowPre();"><img src="/images/ion_02.gif" border="0" /></a></li>';
				for(var i=0;i<image_list.length;i++){
					window_zuji_image_list[window_zuji_image_list.length] = image_list[i];
					if( i<window_zuji_image_limit ){
						html += '<li><a href="###" onclick="showZujiBigImageWindow(\''+image_list[i]['thumb_image_url']+'\',\''+image_list[i]['big_image_url']+'\',\''+image_list[i]['src_image_url']+'\',\''+image_list[i]['remark']+'\');"><img src="'+image_list[i]['thumb_image_url']+'" width="48" height="48" border="0" title="'+image_list[i]['remark']+'" /></a></li>';
						window_zuji_image_list_end = i;
					}
				}
				html += '<li style="padding:10px 0 0 0"><a href="javascript:void(0);" onclick="showZujiBigImageWindowNext();"><img src="/images/ion_03.gif" border="0" /></a></li>\
			</ul>\
			<div class="c"></div>\
		</div>';
			}
			if( ret['is_owner']==0 ){
				html += '\
				<div>\
					<p style="padding:10px 0 0 0; text-align:center;"><input name="" type="button" class="btn_20" value="收藏" onclick="addZujiToFav('+zj_id+');" /></p>\
				</div>';
			}
			html += '</div>\
	<div class="map_xiangqingR">\
		<div class="map_xiangqingRLy">\
		<ul id="window_comment_list_div">\
		</ul>\
		<div class="page" style="padding:0" id="window_comment_pagestring_div"></div>\
		<div  class="c"></div>\
		</div>\
		<div class="pinglunTk">\
			<h6>评论：</h6>\
			<div>\
				<input name="window_comment_content" id="window_comment_content" class="pinglunTk_input" type="text" />\
				<p style="padding:8px 0 0 0"><input name="" type="button" class="btn_20" value="留言" onclick="saveZujiCommentWindow('+zj_id+');" /> 每条最多200个字</p>\
			</div>\
		</div>\
		<div class="pinglunTk">\
			<h6>最近来访：</h6>\
			<div class="laifangTK">\
			<ul>';
			for(var i=0;i<visited_list.length;i++){
				html += '<li><a href="'+visited_list[i]['link']+'"><img src="'+visited_list[i]['photo_url']+'" width="48" height="48" /></a><span><a href="'+visited_list[i]['link']+'">'+visited_list[i]['name']+'</a><br />'+visited_list[i]['time_diff']+'</span></li>';
			}
			html += '</ul>\
			</div>\
		</div>\
		<div class="clear"></div>\
	</div>\
	</div>\
			';
			var bottom_menu = '<input class="btn_grey" id="btn_sc" title="关闭" type="button" onclick="closeMessageBox();" value="关闭" />';
			MessageBox(title,html,'',430,600,-50);
			// 换图
			if( image_list.length>0 ){
				showZujiBigImageWindow(ret['first_image']['thumb_image_url'],ret['first_image']['big_image_url'],ret['first_image']['src_image_url'],ret['first_image']['remark']);
			}
			window_zj_id = zj_id;
			showZujiCommentWindow();
			/** 具体显示部分end **/
		}
	);
}