replyCommentID = 0;
// 打开或者关闭所有评论
allCommentOpen = 1;
function changeAllComment() {
	if (allCommentOpen == 1) {
		allCommentOpen = 0;
		closeAllComment();
	} else {
		allCommentOpen = 1;
		openAllComment();
	}
	function openAllComment() {
		$('#feedBlock ol').css('display', 'block');
	}
	function closeAllComment() {
		$('#feedBlock ol').css('display', 'none');
	}
}

// 回复Feed
function doReply(feedId, username, userId) {
	url = WEB_PATH + '/ajax.php?mod=Feed&do=reply&feedId=' + feedId;
	content = $('#replyContent_' + feedId).val();
	reship = $('#reshipCk_' + feedId).attr('checked');

	if (content.length == 0) {
		alert('请填写评论内容');
		$('#replyContent_' + feedId).focus()
		return;
	}

	$('#replyContent_' + feedId).val('');
	$('#replySub_' + feedId).attr('disabled', 'true');
	$.post(url, {content:content, reship:reship, replyCommentID:replyCommentID}, function(data){appendReply(userId, username, data, feedId, content)}, 'json');
	replyCommentID = 0;

	function appendReply(userId, username, data, feedId, content) {
		if (data.status == 'SUCCESS') {
			date = getDate();
			commentId = data.data;
			comment = '<div id="commentRow_' + commentId + '" class="row"><div class="headPic">';
			comment += '<a href="javascript:void(0)"><img src="' + IMAGE_PROCESSING_PATH + '/avatar.php?uid=' + userId + '" width="35" height="35"></a></div>';
			comment += '<div class="commentContent"><div>';
			comment += '<a href="javascript:void(0)">' + username + '</a>&nbsp;&nbsp;&nbsp;[' + date + ']';
			comment += ' - <a href="javascript:void(0)" onclick="setReplyTo(' + feedId + ', ' + commentId + ', \'' + username + '\', ' + userId + ')">回复</a>';
			comment += ' - <a href="javascript:void(0)" onclick="delComment(' + feedId + ',' + commentId + ')">删除</a>';
			comment += '</div><div id="commentContent_' + commentId + '">' + content + '</div></div></div>';
			$('#replyTo_' + feedId).before(comment);
			$('#replyNum_' + feedId).html(parseInt($('#replyNum_' + feedId).html()) + 1);
		} else {
			alert(data.message);
		}

		$('#replySub_' + feedId).removeAttr('disabled');
		unsetReply(feedId);
	}

}

// 设置回复指定的对象
function setReplyTo(feedId, commentId, userName) {
	html = '回复：' + userName + '&nbsp;&nbsp;<a href="javascript:void(0)" onclick="unsetReply(' + feedId + ')">X</a>';
	$('#replyTo_' + feedId).css('display', 'block');
	$('#replyTo_' + feedId).html(html);
	$("#replyContent_" + feedId).focus();
	replyCommentID = commentId;
}
function unsetReply(feedId) {
	$('#replyTo_' + feedId).css('display', 'none');
	$('#replyTo_' + feedId).html('');
	$("#replyContent_" + feedId).focus();
	replyCommentID = 0;
}

// 打开折叠的评论列表
function showCommentList(feedId) {
	changeHidden('comment_' + feedId);
	changeHidden('comment_open_' + feedId);
}

// 执行选中“发布一条广播”的复选框的操作
function checkPutFeed(feedId) {
	if ($('#reshipCk_' + feedId).attr('checked')) {
		$('#reshipCk_' + feedId).removeAttr('checked')
	} else {
		$('#reshipCk_' + feedId).attr('checked', 'true')
	}
}

// 删除评论
function delComment(feedId, commentId) {
	if (confirm('您确认要删除这条回复信息么？')) {
		url = WEB_PATH + '/ajax.php?mod=Comment&do=del&commentId=' + commentId + '&' + new Date();
		$.getJSON(url, function(data){
			if (data.status == 'SUCCESS') {
				$('#commentRow_' + commentId).remove();
				$('#replyNum_' + feedId).html($('#replyNum_' + feedId).html()-1);
			} else {
				alert(data.message)
			}
		});
	}
}

// 当光标定位到评论输入框时
function replyInputOnFocus(id) {
	$('#reply_' + id).css('height', '47px');
}

// 当光标离开评论输入框时
function replyInputOnBlur(id) {
	if ($('#replyContent_' + id).val()) {
		return false;
	}
	$('#reply_' + id).css('height', '22px');
}

// 打开feed编辑器
function openEditFeed() {
	changeHidden('floatDiv', 'block');
	$('#floatDiv').html($('#editFeed').html());
}

// 修改图片大小
function changeImageSize(imgId, feedImg, feedThumb) {
	src = $(imgId).attr('src');
	
	if ($(imgId).css('max-height') == '90px') {
		$(imgId).css('max-width', '98%');
		$(imgId).css('max-height', '4000px');
		$(imgId).attr('src', feedImg);
	} else {
		$(imgId).css('max-width', '120px');
		$(imgId).css('max-height', '90px');
		$(imgId).attr('src', feedThumb);
	}
}

// 播放视频
function playVideo(id, feedId, src) {
	html = '<embed id="video_' + feedId + '" src="' + src + '" quality="high" width="420" height="320" align="middle" allowScriptAccess="allways" mode="transparent" type="application/x-shockwave-flash"></embed>';
	$(id).after(html);
	$(id).remove();
	$('#closeVideo_' + feedId).css('display', '');
}
function closeVideo(id, src) {
	html = '<img src="./misc/images/public/player.gif" onclick=\'playVideo($(this), "' + id +'", "' + src + '")\'>';
	$('#video_' + id).after(html);
	$('#video_' + id).remove();
	$('#closeVideo_' + id).css('display', 'none');
}

function openVideoBox(src) {
	changeHidden('floatDiv', 'block');
	$('#floatDiv').html($('#putVideo').html());
	$('#putVideoInput').focus();
}

// 上传视频
function putVideo() {
	swfPath = $.trim($('#putVideoInput').val());
	if (!swfPath) {
		alert('请输入swf文件所在地址');
		$('#putVideoInput').focus();
		return false;
	}
	if (swfPath.toLowerCase().indexOf('.swf') != swfPath.length - 4 || swfPath.toLowerCase().indexOf('http://') != 0 ) {
		alert('您输入的swf文件所在地址有误');
		$('#putVideoInput').focus();
		return false;
	} else {
		$('#swfVideoPath').val(swfPath);
		$('#uploadVideo').html('<img src="misc/images/icon/video2.gif">');
		$('#feedBlock textarea').val('[视频]: ' + $('#feedBlock textarea').val());
		$('#putVideoInput').val('');
		changeHidden('floatDiv');
	}
}

/*
 获取更多的feed
feedStart	= 30;
feedRows	= 20;
function getMoreFeed(userId, fgId, type) {
	$.getJSON('ajax.php?mod=Feed&do=getMoreFeed&start='+feedStart+'&rows='+feedRows+'&selfId='+userId+'&type='+type+'&'+new Date(), function(data) {
		if (data.status == 'SUCCESS') {
			feedStart += feedRows;
			var div = '<div class="feedList" style="text-align:center">o(∩_∩)o ------------ 华丽的分割线 ------------ o(∩_∩)o</div>';
			$('#feed').append(div+data.data);
		} else {
			alert(data.message);
		}
	});
}
*/
/**
修改feed分类
**/
function changeFeedClass(feedId, classId) {
	url = 'ajax.php?mod=Feed&do=changeClass'
	$.post(url, {feedId:feedId, classId:classId});
}
