/**
* @Copyright (c) 2006, DM72 S&D
* All rights reserved.
* 用户js --- 好友
* @filesource:	user.js
* @author      	DM72 www.dm72.net<linrenling>
* @package     	/js/
* @version     	$Id: $
*/
function friend_dlg(path, friend_id, is_login, base_path)
{
	if (is_login == "yes")
	{
		new Dialog('friend_create_dlg', '加为好友', {url: '/' + path + '/friend_create_dlg?friend_id=' + friend_id, width: 400, height: 150});
	}
	else
	{
		go_login(base_path + path + "/");
	}
	return false;
}

/**
 *发送站内信
 */
function send_msg_dlg(user_id, user_name, is_login, visit_path, base_path)
{
	if (is_login == "yes")
	{
		new Dialog('send_msg_dlg', '发送消息', {url: '/' + visit_path + '/send_msg_dlg?user_id=' + user_id + '&user_name=' + encodeURIComponent(user_name), width: 400, height: 250});
	}
	else
	{
		go_login(base_path + visit_path + "/");
	}
	return false;
}

/**
 *打招呼
 */
function send_notify(user_name,is_login, visit_path, base_path) {
	if (is_login == "no")
	{
		go_login(base_path + visit_path + "/");
		return false;
	}
	new ConfirmDialog('打个招呼', '是否跟' + user_name + '打个招呼？', {
		onConfirm: function() {
			new SimpleSubmit('notify_form', '/sys/app/message_opt.php',
			{onComplete: function(){}});
		}
	});
}
function friend_add()
{
	new SimpleSubmit(
	'dm72_form',
	'/sys/app/friend_opt.php',
	{ dialogId:'friend_create_dlg'}
	);
	return false;
}
function send_msg()
{
	if(!check_blank("title"))
	{
		alert("标题不能为空。");
		$("title").focus();
		return false;
	}
	if(!check_bytem("content", 2000))
	{
		alert("内容不能超过2000字。");
		$("content" ).focus();
		return false;
	}
	$("dm72_action").value = 'add';
	new SimpleSubmit(
	'dm72_form',
	'/sys/app/message_opt.php',
	{dialogId: 'send_msg_dlg'}
	);
	return false;
}
function login_sub()
{
	new SimpleSubmit(
	'dm72_form',
	'/sys/app/friend_opt.php',
	{autoClose: false}
	);
	return false;
}
function want_create()
{
	$('group_name').disabled=false;
	$('show_notice').style.display='block';
}
function use_old()
{
	$('group_name').disabled=true;
	$('group_name').value = "创建新分组";
	$('show_notice').style.display = 'none';
}
function friend_list(user_id, group_id)
{
	Query.execute('/sys/json/friend_list.php?user_id=' + user_id + '&group_id=' + group_id, 'friend_list', 40);
}
