function _cbCid(id){
	Comment.Page.MiniNormal.unique_id = id;
	Comment.Page.MiniNormal.Id = id;
	Comment.Page.MiniNormal.preinit();
}
function _cbGid(id){
	Comment.Page.MiniNormal.unique_id = id;
	Comment.Page.MiniNormal.Id = id;
	Comment.Page.MiniNormal.preinit();
}
Comment.Page.MiniNormal = {
	load: function(option)
	{
		this.show = 1;
		if (option.show)
		{
			if (option.show == 0)
			{
				this.show = 0;
			}
		}

		if (!option.site || !option.id)
		{
			alert('访问参数错误');
			return;
		}
		this.site = option.site;
		this.unique_id = option.id;
		this.Id = option.id;
		this.ojs08 = 0;
		if(option.ojs08)
			this.ojs08 = option.ojs08;
		this.option = option;
		if(this.option.is_group == 1 || this.option.group == 1) this.is_group = true;
		if(this.Id <= 3000000 && window.location.href.indexOf('sum.comment.qq.com')==-1){
			if(this.is_group){
				addJs('http://comment5.qq.com/php/ggid.php?site='+this.site+'&g_id='+this.Id);
			}else{
				addJs('http://comment5.qq.com/php/gcid.php?site='+this.site+'&c_id='+this.Id);
			}
		}else{
			this.preinit();
		}
	},
	preinit: function(){
		if (!this.option.mode) this.option.mode = 'origin';
		this.mode = this.option.mode + '_count';
		var mode_exist = false;
		for(var i = 0; i < Comment.DataObject.sum.length; ++i){
			if (this.mode == Comment.DataObject.sum[i]) mode_exist = true;
		}
		if(!mode_exist) this.mode = 'origin_count';
		if(!this.option.sum) this.option.sum = 10;
		this.replyPerPage = this.option.sum/1;
		if(this.replyPerPage > 30) this.replyPerPage = 30;
		this.replyPerPageConst = this.replyPerPage;
		
		var top_c = Comment.Configure.top_reply_count;
		var normal_c = 1;
		if(this.mode == 'top_count') top_c = this.replyPerPage||1;
		else normal_c = this.replyPerPage||1;
		
		if (this.option.is_group == 1 || this.option.group == 1)
		{
			this.is_group = true;
			this.path = 'group';
			this.info_html = 'groupinfo';
			this.commentTitle = new Object();
			this.request_url = Comment.Configure.php_dir + 'greplyBygid.php?site='
				+ this.site + '&g_id='
				+ this.Id + '&t_c='
				+ top_c + '&o_c='
				+ normal_c;
		}
		else
		{
			this.is_group = false;
			this.path = 'normal';
			this.info_html = 'commentinfo';
			this.request_url = Comment.Configure.php_dir + 'greplyBycid.php?site='
				+ this.site + '&c_id='
				+ this.Id + '&t_c='
				+ top_c + '&o_c='
				+ normal_c;
		}
		this.name = 'MiniNormal';

		if (this.is_group)
		{
			this.comment_g_id = this.unique_id;
		}

		this.allow_group = '|edu|';
		this.init();
	},
	init: function()
	{
		var self = this;
		this.final_domain = 'http://comment5.qq.com';
		if(cmt_domains[this.site]) this.final_domain = 'http://comment5.'+this.site+'.qq.com';
		this.pgv_domain = 'i_comment.qq.com';
		if (this.option.final_domain)
		{
			this.final_domain = 'http://' + this.option.final_domain;
			this.pgv_domain = this.option.final_domain;
		}
		this.count_array = [];
		if (this.option.count_id)
		{
			var count_id = this.option.count_id;
			if (count_id.indexOf('|') != -1)
			{
				this.count_array = count_id.split('|');
				g_count_array = this.count_array;
			}
			else
			{
				if (this.count_array != ''|| count_id != '')
				{
					this.count_array.push(count_id);
				}
			}
		}
		this.submit_pos = this.option.submit_pos ? this.option.submit_pos : 0;
		if (this.submit_pos < 0 || this.submit_pos > 2)
		{
			this.submit_pos = 0;
		}
		if ($('Submit') && this.submit_pos == 2)
		{
			$('Submit').style.display = 'none';
		}

		this.currPage = 1;
		this.order = 1;

		if (this.is_group)
		{
			if ($('view_c_href'))
			{
				if(this.ojs08==1)
					$('view_c_href').href = this.final_domain + '/axel/comment_group_ojs08.htm?site=' + this.site + '&id=' + this.unique_id;
				else
					$('view_c_href').href = this.final_domain + '/comment_group.htm?site=' + this.site + '&id=' + this.unique_id;
			}
		}
		else
		{
			if ($('view_c_href'))
			{
				if(this.ojs08==1)
					$('view_c_href').href = this.final_domain + '/axel/comment_ojs08.htm?site=' + this.site + '&id=' + this.unique_id;
				else
					$('view_c_href').href = this.final_domain + '/comment.htm?site=' + this.site + '&id=' + this.unique_id;
			}
		}
		this.bindPageInfo(this.mode);
		Comment.Post.init({base:self});
		/* pgv start */
		var pgv_path = "/" + this.site + "/nolist.htm";		
		if (this.option.sum != 0)
		{
			pgv_path = "/" + this.site + "/sumlist.htm";
		}
		Comment.PGV_Count({
			domain:	self.pgv_domain,
			path:	pgv_path
		});
		/* pgv end */
	},
	reload: function()
	{
		var self = this;
		this.currPage = 1;
		this.bindPageInfo(this.mode);
		/* pgv start */
		var pgv_path = "/nolist.htm";
		Comment.PGV_Count({
			domain:	self.pgv_domain,
			path:	pgv_path
		});
		/* pgv end */
	},
	bindCommentInfo: function(data)
	{
		var self = this;
		self.data_commentinfo = data;
		self.comment_title = data.title;
		if (self.is_group)
		{
			self.commentId = data.comment_id;
			document.title = '评论组：' + data.title.toDocTitle() + ' - 腾讯网';
		}
		else
		{
			self.comment_g_id = data.group_id;
			self.commentId = self.unique_id; 
			self.sort_en = data.sort_en;
			document.title = '评论：' + data.title.toDocTitle() + ' - 腾讯网';
		}

		createSiteNav($('site_nav'));
		function createSiteNav(obj)
		{
			if (!obj)
			{
				return;
			}
			if (self.is_group)
			{
				obj.innerHTML = '<a href="' + pinglun_domain + '" target="_blank" class="b1">评论首页</a> &gt;&gt; '
				+ data.site_cn;
			}
			else
			{
				function getCommentListLink(site_en, site_cn, sort_en, sort_cn, className)
				{
					if (className)
					{
						className = 'class="' + className + '"';
					}
					else
					{
						className = '';
					}
					return '<a href="' + Comment.Configure.commentIndex + '" ' + className + ' target="_blank">评论首页</a> &gt;&gt; '
						+ site_cn + ' &gt;&gt; '
						+ sort_cn;
				}
				obj.innerHTML = getCommentListLink(self.site, data.site_cn, data.sort_en, data.sort_cn, 'b0');
			}
		}
	},
	bindPageInfo: function(mode)
	{
		var bind_comment = false;
		if (this.show == 1
		&& (this.replyPerPage != 0
		|| this.is_group
		|| this.allow_group.indexOf('|' + this.site + '|') != -1)
		){
			bind_comment = true;
		}else{
			if ($('site_nav')) $('site_nav').style.display = 'none';
			this.sort_en = 'defaultcatalog';
			this.commentId = this.unique_id;
		}
		
		if (this.submit_pos == 0)
		{
			$('Comment_top').className = 'topno';
		}
		var self = this;
		new Ajax.Request(
		self.request_url + '&t=' + new Date().getTime(),
		{
			method: 'get',
			asynchronous: true,
			onSuccess: onSucc,
			onFailure: onError
		}
		);
		function onSucc(response)
		{
			try{
				self.new_data = eval(response.responseText);
				if(self.new_data == -1) return;
			}catch(e){
				return;
			}
			if(bind_comment) self.bindCommentInfo(self.new_data[self.info_html]);
			var data = self.new_data.sum;
			self.data_sum = data;
			if ($('c_count'))
			{
				$('c_count').innerHTML = data.origin_count?data.origin_count:'0';
			}

			if (data.origin_count == 0)
			{
				self.updateHeight();
			}

			for (var i = 0; i < self.count_array.length; ++i)
			{
				var count_elem = window.top.document.getElementById(self.count_array[i]);
				if (count_elem)
				{
					if (data.origin_count)
					{
						count_elem.innerHTML = data.origin_count;
					}
					else
					{
						count_elem.innerHTML = '0';
					}
				}
			}

			if (self.show == 0)
			{
				return;
			}

			if (self.replyPerPage == 0)
			{
				self.updateHeight();
				return;
			}
			self.totalReply = data[self.mode];

			if (self.mode == 'origin_count' && self.data_sum['top_count'] != 0)
			{
				self.bindTopReply();
			}
			else
			{
				self.bindReplyList();
			}
		}
		function onError()
		{
			if ($('c_count'))
			{
				$('c_count').innerHTML = '0';
			}
			for (var i = 0; i < self.count_array.length; ++i)
			{
				var count_elem = window.top.document.getElementById(self.count_array[i]);
				if (count_elem)
				{
					count_elem.innerHTML = '0';
				}
			}
			self.updateHeight();
		}
	},
	bindTopReply: function()
	{
		var self = this;
		var top_show_sum = 3;
		self.replyPerPage = self.replyPerPageConst;
		if(top_show_sum > self.replyPerPage) top_show_sum = self.replyPerPage;
		self.topReplyList = self.new_data.replys_top.slice(0, top_show_sum);
		self.replyPerPage -= self.topReplyList.length;
		self.bindReplyList();
	},
	bindReplyList: function()
	{
		if (this.totalReply == 0)
		{
			this.updateHeight();
			return;
		}
		if (this.replyPerPage == 1)
		{
			this.replyPerPage = 2;
		}

		if (this.replyPerPage == 0)
		{
			this.bindReplys(new Array());
			return;
		}
		if(this.mode == 'top_count') this.bindReplys(this.new_data.replys_top.slice(0,this.replyPerPage));
		else this.bindReplys(this.new_data.replys_normal.slice(0,this.replyPerPage));
	},
	bindReplys: function(replys)
	{
		var self = this;
		var replySum = replys.length;
		var comment_container = 'Comment_bottom';
		if (this.submit_pos == 1)
		{
			comment_container = 'Comment_top';
		}

		if ($('Comment'))
		{
			comment_container = 'Comment';
		}
		if ($(comment_container))
		{
			$(comment_container).innerHTML = '';
		}

		if (self.topReplyList && self.mode == 'origin_count' && self.currPage == 1)
		{
			replys = self.topReplyList.concat(replys);
		}
		
		var safe_array_beg = 0;
		var safe_array_end = replys.length;
		if (safe_array_end > 30)
		{
			safe_array_beg = safe_array_end - 30;
		}
		
		for (var i = safe_array_beg; i < safe_array_end; ++i)
		{
			var dlReply = $C('dl');
			dlReply.className = 'cmt';
			$(comment_container).appendChild(dlReply);
			new getReply(i, dlReply);
		}
		function getReply(index, dlReply)
		{
			var commentId = replys[index].comment_id;
			var replyKey = replys[index].reply_key;
			var date =  new Date();
			var curTime =  date.getTime();
			var data = replys[index];
			if (data.is_del == '1')
			{
				return;
			}
			if ((data.reply_type == '4' || data.is_del == '2') && self.mode == 'top_count')
			{
				return;
			}
			var ret = Comment.ContentFormat.collapse(data.content);
			data.title = data.title.trim();
			var buffer = new StringBuffer();
			buffer.append('<dt><span class="bolds b1">' + Comment.Define.getReplyType(data.reply_type) + '</span>');
			buffer.append(getCommentUserLinkEx(data.uin, data.nickname, data.ip));
			buffer.append(' 发表评论：<span id="r_pk_' + index + '"></span>');
			buffer.append('<span id="comment_title_' + index + '"></span></dt>');
			buffer.append((data.title != '' ? '<dd class="p" style="text-indent:0"><div class="p_title_div"><span class="p_title_span">[' + data.title + ']</span></div></dd>' : ''));
			buffer.append('<dd class="p" id="content_left_' + index + '">' + ret[1]);
			buffer.append((ret[0] ? ' <span><a href="#" id="content_href_' + index + '">[查看全文]</a></span>' : ''));
			buffer.append('</dd>');
			buffer.append('<dd class="r" id="r_r_' + index + '"></dd>');
			dlReply.innerHTML = buffer.toString();
			function  getCommentUserLinkEx(uin, nick, ip){
				var res = '';
				if (Comment.Toolkit.isMobile(ip) && (uin == '' || uin == '0'))
				{
					res = '腾讯手机网友';
				}
				else
				{
					res = ''
						+ ((uin == '' || uin == '0') ?(nick ? nick:'腾讯网友'): '<span class="have_login">'+Comment.UrlFactory.getCommentUserLink(uin, nick)+'</span>');
				}
				return res;
			}
			if (self.is_group)
			{
				self.bindCommentTitle(commentId, $('comment_title_' + index), data.comment_title);
			}
			if (ret[0])
			{
				$('content_href_' + index).onclick = function()
				{
					$('content_left_' + index).innerHTML = data.content;
					self.updateHeight();
					return false;
				}
			}
			if (data.reply_key != '' && data.cite_valid)
			{
				getReply(data.reply_key);
			}
			if(data.sums){
				var replysums = data.sums.split('|');
				/*************************屏蔽******************************
				$('r_pk_' + index).innerHTML = '[支持:' + replysums[0] + '人 '
					+ '反对:' + replysums[1] + '人 '
					+ '回帖:' + replysums[3] + '人]';
				*************************屏蔽******************************/
			}

			function getReply(key)
			{
				var sReplyUrl = Comment.Configure.php_dir + 'gciteReply.php?r_id=' + key + '&c=1';
				new Ajax.Request(
					sReplyUrl,
					{
						method: 'get',
						asynchronous: true,
						onSuccess: onGetReply,
						onFailure: function(){}
					}
				);
				function onGetReply(response)
				{
					try{
						var replys = eval(response.responseText);
					}catch(e){
						return;
					}
					if(replys.length == 0) return;
					var replyData = replys[0];
					var replyParent = $('r_r_' + index);
					replyParent.className = 'r';
					replyParent.style.display = 'block';
					var reBuffer = new StringBuffer();
					reBuffer.append('[引用] 来自 ' + Comment.GetAddress(replyData.ip,replyData.source) + ' 的');
					reBuffer.append(getCommentUserLinkEx(replyData.uin, replyData.nickname, replyData.ip));
					reBuffer.append('发表于 ');
					reBuffer.append(replyData.pub_time);
					reBuffer.append(' <span id="r_quote_pk_' + index + '"></span> ');
					reBuffer.append('<span id="quote_content_' + index + '">' + replyData.content.left(Comment.Configure.quote_str_len));
					reBuffer.append((replyData.content.length > Comment.Configure.quote_str_len ? (' <span><a href="#" id="quote_content_href_' + index + '">[查看全文]</a></span>') : ''));
					reBuffer.append('</span>');
					replyParent.innerHTML = reBuffer.toString();

					if (replyData.content.length > Comment.Configure.quote_str_len)
					{
						$('quote_content_href_' + index).onclick = function()
						{
							$('quote_content_' + index).innerHTML = replyData.content;
							self.updateHeight();
							return false;
						}
					}
					self.updateHeight();
				}
			}

			if (index == replys.length - 1)
			{
				self.autoupdateHeightnum=0;
				function autoHeight()
				{
					if(self.autoupdateHeightnum<40){
						self.updateHeight();
					}
					this.autoupdateHeightnum++;
					if(self.autoupdateHeightnum==40)
						clearInterval(self.autoupdateHeight);
				}
				self.autoupdateHeight = setInterval(autoHeight,500);
			}
		}
	},
	bindCommentTitle: function(id, obj, title)
	{
		obj.innerHTML = '<a class="p_c_title_a" target="_blank" href="http://comment5.qq.com/' + Comment.UrlFactory.getCommentNormalUrl(this.site, id) + '">' + title + '</a>';
	},
	updateHeight: function()
	{
		var self = this;
		function updateHeight()
		{
			if (self.option.p_iframe_id && self.option.height == 0)
			{
				if (window.parent.document.getElementById(self.option.p_iframe_id))
				{
					window.parent.document.getElementById(self.option.p_iframe_id).style.height = document.body.scrollHeight+'px';
				}
			}
		}
		setTimeout(updateHeight, 100);
	}
}/*  |xGv00|119e54c44d820a8e1bd06675d3817232 */