var g_count_array = [];
function cb(c_array) {

	if (c_array[1])
	{
		$('c_count').innerHTML = c_array[1];
	}
	else
	{
		$('c_count').innerHTML = '0';
	}
	for (var i = 0; i < g_count_array.length; ++i)
	{
		var count_elem = window.top.document.getElementById(g_count_array[i]);
		if (count_elem)
		{
			if (c_array[1])
			{
				count_elem.innerHTML = c_array[1];
			}
			else
			{
				count_elem.innerHTML = '0';
			}
		}
	}
}


Comment.Page.MiniNormal1 = {
	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;
			this.path = 'group';
			this.info_html = 'groupinfo';
			this.commentTitle = new Object();
		}
		else
		{
			this.is_group = false;
			this.path = 'normal';
			this.info_html = 'commentinfo';
		}
		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://comment4.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);
					g_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';
		}

		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;
		if (this.replyPerPage > 30)
		{
			this.replyPerPage = 30;
		}
		this.replyPerPageConst = this.replyPerPage;
		this.currPage = 1;
		this.index_line_len = Comment.Configure.key_length + Comment.Configure.newline.length;
		if (this.is_group)
		{
			this.index_line_len = Comment.Configure.id_length
			+ (':').length
			+ Comment.Configure.key_length
			+ Comment.Configure.newline.length;
		}
		this.order = 1;	/* 0:正向 1:逆向 */
		if (this.show == 1
		&& (this.replyPerPage != 0
		|| this.is_group
		|| this.allow_group.indexOf('|' + self.site + '|') != -1)
		)
		{
			this.bindCommentInfo();
		}
		else
		{
			if ($('site_nav'))
			{
				$('site_nav').style.display = 'none';
			}
			this.sort_en = 'defaultcatalog';
			this.commentId = this.unique_id; // // kevinliu add 2006-10-08
		}

		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 + '/axel/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 + '/axel/comment.htm?site=' + this.site + '&id=' + this.unique_id;
			}
		}
		this.bindPageInfo2(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.bindPageInfo2(this.mode);
		/* pgv start */
		var pgv_path = "/nolist.htm";		
		Comment.PGV_Count({
			domain:	self.pgv_domain,
			path:	pgv_path
		});
		/* pgv end */
	},
	bindCommentInfo: function()
	{
		//showLoading();
		var self = this;
		var sCommentInfoUrl = '/' + this.site + '/' + this.path + '/'
		+ Comment.UrlFactory.getCommentUrl(self.unique_id)
		+ this.info_html + '.htm';
		new Ajax.Request(
		sCommentInfoUrl,
		{
			method: 		'get',
			asynchronous:	true,
			onSuccess: 	onSucc,
			onFailure:		onError
		}
		);

		function onSucc(response)
		{
			var data = Comment.DataObjectFactory(response.responseText, self.info_html);
			self.data_commentinfo = data;
			self.comment_title = data.title;
			if (self.is_group)
			{
				self.commentId = data.comment_id;
				document.title = '评论组：' + data.title + ' - 腾讯网';
			}
			else
			{
				self.comment_g_id = data.group_id;
				self.commentId = self.unique_id; 
				self.sort_en = data.sort_en;
				document.title = '评论：' + data.title + ' - 腾讯网';
			}

			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; <a href="axel/list.htm?' + self.site + '." target="_blank" class="b1">'
					+ data.site_cn
					+ '</a>';
				}
				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; '
							+ '<a href="axel/list.htm?' + site_en + '." ' + className + ' target="_blank">' + site_cn + '</a> &gt;&gt; '
							+ '<a href="axel/list.htm?' + site_en + '.' + sort_en + '" ' + className + ' target="_blank">' + sort_cn + '</a>';
					}
					obj.innerHTML = getCommentListLink(self.site, data.site_cn, data.sort_en, data.sort_cn, 'b0');
				}
			}
		}

		function onError()
		{
			//alert('很抱歉，不存在这个评论！');
			//hideLoading();
		}
	},
	bindPageInfo2: function(mode)
	{
		//call json
		if (this.submit_pos == 0)
		{
			$('Comment_top').className = 'topno';
		}
		var self = this;
		if (typeof(i_comment_domain) == 'undefined')
		{
			i_comment_domain = 'comment2.qq.com';
		}
		
		var sCommentSumUrl = 'http://' + i_comment_domain + '/' + this.site + '/' + this.path + '/'
		+ Comment.UrlFactory.getCommentUrl(self.unique_id)
		+ 'sum.js';
		var s=document.createElement("SCRIPT");
		document.getElementsByTagName("HEAD")[0].appendChild(s);
		s.src=sCommentSumUrl;
		self.updateHeight();
		
	},
	updateHeight: function()
	{
		if (this.show == 0)
		{
			return;
		}
		var self = this;
		setTimeout(updateHeight, 100);
		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';
				}
			}
		}
	}
}
/*  |xGv00|e1dae536be954acaffb4b2435fd222ac */