function pmsg(recvuid, subject) {
	$.post(siteurl+'member/index.php', { ac:"pm", in_ajax:1, op:'write', recvuid:recvuid, subject:subject }, 
		function(result) {
			if (result.match(/<form.+method="post".+>/)) {
				result += '<iframe style="display:none" src="" name="ifpmsg" id="ifpmsg"></iframe>';
				myDialog('发送短信', result, 500, 300, true);
			} else {
				myAlert(result);
			}
		});
}

function post_pmsg () {

	var form = document.pmsgfrm;

	if(form.dest.value.trim() == ''){
		alert('未添加发送对象。');
		return false;
	} else if(form.subject.value.trim() == '') {
		alert('未填写短信主题。');
		return false;
	} else if(form.subject.value.length > 60) {
		alert('短信主题不能超过60个字符。');
		return false;
	} else if(form.content.value.trim() == '') {
		alert('未填写短信内容。');
		return false;
	} else if(form.content.value.length > 500) {
		alert('短信内容不能超过500个字符。');
		return false;
	}

	return true;
}

function readmsg(pmid) {
	var c = $("#pmid_"+show_pmid+'_content');
	if(c[0]) {
		c.css("display","none");
	}
	var n = $("#pmid_"+pmid+'_content');
	if(n[0]) {
        c.css("display","");
		show_pmid = pmid;
		return;
	}

	$.post(siteurl+'member/index.php', {ac:"pm", in_ajax:1, op:'read', pmid:pmid }, 
		function(result){
			if (result.match(/<.+id="readmsg".*>/)) {
				var c_row = document.getElementById('pmid_'+pmid);
				var m_table = c_row.parentNode;
				var n_row = m_table.insertRow(c_row.rowIndex + 1);
				n_row.id = 'pmid_'+pmid+'_content';
				var n_cell1 = n_row.insertCell(0);
				n_cell1.innerHTML = '&nbsp;';
				var n_cell2 = n_row.insertCell(1);
				n_cell2.colSpan = 4;
				n_cell2.innerHTML = result;
				show_pmid = pmid;
			} else {
				myAlert(result);
			}
	});
}

function addfriend(friendid) {
	$.post(siteurl+'member/index.php', { ac:"friends",in_ajax:1,op:'add',friendid:friendid }, 
		function(result){
			if (result.match(/<form.+method="post".+>/)) {
				result += '<iframe style="display:none" src="" name="ifaddfriend" id="ifaddfriend"></iframe>';
				myDialog('添加好友', result, 300, 230);
			} else {
				myAlert(result);
			}
	});
}

function post_addfriend() {
	var form = document.addfriendfrm;
	if(!is_numeric(form.friendid.value)){
		alert('会员不存在，无法添加。');
		return false;
	} else if(form.content.value.length > 300) {
		alert('对好友的留言不能超过300个字，请精简一下留言。');
		return false;
	}

	return true;
}