var $ = function(id){return (typeof id=="object")?id:document.getElementById(id);}
var $C = function(tagName){return document.createElement(tagName);}
var $A = function(a){
	if(!a) return new Array();
	else{
		var r = new Array();
		for (var i=0; i<a.length; i++) r.push(a[i]);
		return r;
	}
};

String.prototype.trim = function(){
	return this.replace(/^\s*|\s*$/g,"");
};
String.prototype.realLength = function(){
	return this.replace(/[^\x00-\xff]/g,"**").length;
};
String.prototype.replaceTags = function(){
	var t = this.replace(/</g, '&lt;');
	t = t.replace(/>/g, '&gt;');
	return t;
};
String.prototype.toDocTitle = function(){
	return this.replace(/&acute;/g,"'")
		.replace(/&quot;/g,'"')
		.replace(/&lt;/g,'<')
		.replace(/&gt;/g,'>')
		.replace(/&amp;/g,'&');
};
String.prototype.left = function(n){
	if (this.length > n) return this.substr(0, n) + '...';
	else return this;
};
String.prototype.stripTags = function(){
	return this.replace(/<\/?[^>]+>/gi, '');
};
String.prototype.toQueryParams=function(){
	var params = {};
	var pairs=this.match(/^\??(.*)$/)[1].split('&');
	for(var i=0; i<pairs.length; ++i){
		var pair=pairs[i].split('=');
		params[pair[0]]=pair[1];
	}
	return params;
}
Array.prototype.each=function(iterator){
	for(var i=0; i<this.length; ++i) iterator(this[i]);
}
Array.prototype.remove = function(n){
	if(n < 0) return this;
	else return this.slice(0, n).concat(this.slice(n + 1, this.length));
};
Object.extend=function(destination,source){
	for(property in source) destination[property]=source[property];
	return destination;
}
var Class={
	create:function(){
		return function(){
			this.initialize.apply(this,arguments);
		}
	}
}

window.onerror = function() {return true;}

var Browser = new Object();
Browser.ua = window.navigator.userAgent.toLowerCase();
Browser.ie = /msie/.test(Browser.ua);
Browser.moz = /gecko/.test(Browser.ua);
Browser.opera = /opera/.test(Browser.ua);
Browser.safari = /safari/.test(Browser.ua);


//XmlHttp object
var XmlHttp = function(){
	if(Browser.ie){
		var msxmls = ["MSXML3", "MSXML2", "Microsoft"];
		for(var i=0; i<msxmls.length; i++){
			try{
				return new ActiveXObject(msxmls[i] + ".XmlHttp");
			}catch(e){}
		}
	}else{
		return new XMLHttpRequest();
	}
};

//AsynLoader
var AsynLoader = {
	config: {
		queueCount: 20,	//最大并发数
		curQueue: 0		//当前并发数
	},
	load: function(sUrl, oOption){
		AsynLoader.initOption(oOption);

		if(AsynLoader.config.curQueue >= AsynLoader.config.queueCount){
			if(typeof oOption.onQueue == "function"){
				oOption.onQueue();
			}
			function fn(sUrl, oOption){
				return function(){
					AsynLoader.load(sUrl, oOption);
				}
			}(sUrl, oOption);

			window.setTimeout(fn(sUrl, oOption), 100);
			return;
		}else{
			AsynLoader.config.curQueue++;
		}

		var xmlHttp = new XmlHttp();
		xmlHttp.open(oOption.method, sUrl, true);
		var _loadCount = 0;

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(_loadCount == 0){
					_loadCount++;
					AsynLoader.config.curQueue--;

					if(AsynLoader.isSuccess(xmlHttp)){
						var _xmlHttp = {
							status: xmlHttp.status,
							responseXML: xmlHttp.responseXML,
							responseText: xmlHttp.responseText
							//responseJS: xmlHttp.responseText.parseJSON()
						};

						oOption.onSuccess(_xmlHttp);
					}else{
						if(--oOption.decay){
							AsynLoader.load(sUrl, oOption);
						}
						else{
							if(typeof oOption.onFailure == "function"){
								oOption.onFailure(_xmlHttp);
							}
						}
					}
				}
			}
		}

		xmlHttp.send(oOption.data);
	},

	initOption: function(oOption){
		oOption.method = (typeof oOption.data == "undefined" || oOption.data == null) ? "get" : "post";
		oOption.asyn = oOption.asyn || true;
		oOption.decay = oOption.decay || 1;

		if(typeof oOption.data != "string" && oOption.data != null){
			//oOption.data = oOption.data.toJSONString();
		}else if(typeof oOption.data == "undefined"){
			oOption.data = null;
		}
	},

	isSuccess: function(oXmlHttp){
		return oXmlHttp.status == undefined
			|| oXmlHttp.status == 0
			|| (oXmlHttp.status >= 200 && oXmlHttp.status < 300);
	}
};

var Ajax = {};
Ajax.Request = function(url, option){
	AsynLoader.load(url, {
		method: option.method,
		asyn: option.asynchronous,
		onSuccess: option.onSuccess,
		onFailure: option.onFailure
	});
};

function addEvent(obj, type, fn){
	if(obj.attachEvent) obj.attachEvent('on'+type, fn);
	else obj.addEventListener(type, fn, false);
}

var DomReady = {
	isReady: false,
	readyList: [],
	ready: function(){
		if(!DomReady.isReady){
			DomReady.isReady = true;
			if(DomReady.readyList){
				for(var i=0; i<DomReady.readyList.length; ++i) DomReady.readyList[i]();
				DomReady.readyList = null;
			}
		}
	}
};

function onDomReady(fn){
	bindReady();
	if(DomReady.isReady) fn();
	else DomReady.readyList.push(fn);
}

var readyBound = false;
function bindReady(){
	if(readyBound) return;
	readyBound = true;

	if(document.addEventListener && !Browser.opera){
		document.addEventListener("DOMContentLoaded", DomReady.ready, false);
	}

	if(Browser.ie)(function(){
		if(DomReady.isReady) return;
		try {
			var el = document.createElement('div');
			document.documentElement.doScroll("left");
			document.body.appendChild(el);
			el.innerHTML = "left";
			el.parentNode.removeChild(el);
		}catch(error){
			setTimeout(arguments.callee, 0);
			return;
		}
		DomReady.ready();
	})();

	if(Browser.opera)
		document.addEventListener("DOMContentLoaded", function () {
			if(DomReady.isReady) return;
			for(var i=0; i<document.styleSheets.length; ++i)
				if(document.styleSheets[i].disabled){
					setTimeout(arguments.callee, 0);
					return;
				}
			DomReady.ready();
		}, false);

	if(Browser.safari){
		(function(){
			if(DomReady.isReady) return;
			if(document.readyState != "loaded" && document.readyState != "complete"){
				setTimeout(arguments.callee, 0);
				return;
			}
			DomReady.ready();
		})();
	}

	addEvent(window, 'load', function(){
		DomReady.ready()
	});
}

function getCookieVal (offset){
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break;
	}
	return null;
}

function setCookie(cookieName,cookieValue){
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	if(expires!=null)	{
		var LargeExpDate = new Date (); 
		LargeExpDate.setTime(LargeExpDate.getTime() + expires);
	}
	document.cookie = cookieName+"="+escape(cookieValue) + ";path=/;domain=.qq.com"+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()));
}

function delCookie(sName){
	var date = new Date();
	document.cookie = sName + "=;path=/;domain=.qq.com;expires=" + date.toGMTString();
}

function getUserUin(){
	var tmp = getCookie('uin') || getCookie('luin');
	if (!tmp)
	{
		return '';
	}
	var uin = '';
	var start = 0;
	for (i = 0; i < tmp.length; ++i)
	{
		var c = tmp.charAt(i);
		if (c == 'o' || c == '0' && start == 0)
		{
			continue;
		}
		else
		{
			start = 1;
			uin += c;
		}
	}
	return uin;
}

function getUserUin2() {
	var qq=getUserUin()
	var cmt_uin = getCookie("comment_uin");
	var web_uin =getCookie("web_user");
	if(!cmt_uin)
	{
		if(web_uin) return web_uin;
		else return qq;
		
	}
	var temp = cmt_uin.split(" ");
	var cmt_qq = temp[0];
	var nick = cmt_uin.substr(cmt_uin.indexOf(" ")+1);
	return nick;
}

function showLoginStat(login, site){
	if (site == 'kid')
	{
		return;
	}
	var res = '';
	var skey = getCookie('skey');
	if (skey == null)
	{
		res = '温馨提示：您尚未登录评论系统';
		if (login)
		{
			res += '，请<a class="b2" href="#to_user_login">点此登录</a>';
		}
	}
	else
	{
		var url = window.location.href;
		if (url.indexOf('#') != -1)
		{
			url = url.substr(0, url.indexOf('#'));
		}
		url = encodeURIComponent(url);
		var uin = getUserUin();
		res = '<span style="font-color:red">亲爱的QQ用户' + uin + '已登录，<a class="b2" href="comment_user.htm?uin=' + uin + '" target="_blank">查看我发表过的评论</a></span> <a class="b2" href="http://input.comment.qq.com/cgi-bin/qqlogout?url=' + url + '">退出</a>';
	}
	document.write(res);
}
/**************************************************************************************************************************/
function showlogging(){
	
	if (islogging()) {
		if($('to_login2'))
			hideElement('to_login2');
		if($('nick_div'))
			hideElement('nick_div');
		var uin = getUserUin();
		if(!uin)
		{
			  var cmt_uin = getCookie("comment_uin");
			  if(!!cmt_uin) 
			  {
				  var temp = cmt_uin.split(" ");
				  uin= temp[0];
			  }
			
		}
     	user_cb_old(uin,getUserUin2());
	}
	else{
		if($('ctrlLogin'))
			if($('b_login_frame'))
				$('ctrlLogin').innerHTML	= '<a class="b2" id="to_login" href="#to_user_login">登录</a>';
/*		if($('to_login2'))
			showElement('to_login2');
		if($('nick_div'))
		{			
		  //  if($('user_nick'))
		    {
			    var user_nick=cmt_cf.getCookie('user_nick');
				    $('user_nick').value=user_nick||Comment.Configure.default_user_nick;
		 //    }
		     showElement('nick_div');
		}*/
		if($('to_login')){
			$('to_login').onclick = function(){
				$('b_login_frame').src = 'i_login.htm?b_login_frame&&true';
				showElement('b_login_post');
				if($('to_login2'))
		            hideElement('to_login2');
		        if($('nick_div'))
		           	hideElement('nick_div');
			}
		}
	}
	//去除昵称
	if($('nick_div'))
		hideElement('nick_div');
}

function sPost_showlogging(){
	if(islogging())
	{
		if($('sPost_to_login2'))
			hideElement('sPost_to_login2');
		if($('sPost_nick_div'))
		    hideElement('sPost_nick_div');
	}
	else
	{
/*		if($('sPost_to_login2'))
			showElement('sPost_to_login2');
		if($('sPost_nick_div'))
		{
		//    if($('sPost_user_nick'))
		    {
		    	var user_nick=cmt_cf.getCookie('user_nick');
				   $('sPost_user_nick').value=user_nick||Comment.Configure.default_user_nick;
		 //   }			
		    showElement('sPost_nick_div');
		}*/
	}
	if($('sPost_nick_div'))
	   hideElement('sPost_nick_div');
}

function user_cb_old(uin, nick){
	var templet;
	if (uin != 0 && uin != '') {
		var url = window.location.href;
		if (url.indexOf('#') != -1)
		{
			url = url.substr(0, url.indexOf('#'));
		}
		url = encodeURIComponent(url);
		nick = (nick == undefined) ? uin : nick;
		templet = nick + '，欢迎登录：<a class="b2" href="http://comment5.qq.com/comment_user2.htm?uin='+uin+'" target="_blank">查看我的积分</a>，<a class="b2" href="http://input.comment.qq.com/cgi-bin/qqlogout">更换用户</a>';
	}
	else templet = nick + ',欢迎登录 | <a class="b2" href="http://input.comment.qq.com/cgi-bin/qqlogout">更换用户</a>' 
    if ($('ctrlLogin'))
	{
		$('ctrlLogin').innerHTML	= templet;
	}
}
function islogging()
{
	return !!(getCookie('uin') || getCookie('luin')||getCookie("comment_uin")||getCookie("web_user"));
}


function findPosX(obj) 
{
	var curleft = 0;
	if (obj && obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj && obj.x) curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj && obj.offsetParent) 
	{
		while (obj.offsetParent) 
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} 
	else if (obj && obj.y) curtop += obj.y;
	return curtop;
}
//Element
var Element = {
	isEmpty: function(e)
	{
		return /^\s*$/.test($(e).innerHTML);
	},

	isVisible: function(e)
	{
		return $(e).style.display != 'none';
	},

	show: function(s)
	{
		if (s == undefined)
		{
			s = "";
		}
		for (var i=1; i<arguments.length; i++)
		{
			$(arguments[i]).style.display = s;
		}
	},

	hide: function()
	{
		for (var i=0; i<arguments.length; i++)
		{
			$(arguments[i]).style.display = "none";
		}
	},

	toggle: function()
	{
		for (var i=0; i<arguments.length; i++)
		{
			Element[Element.isVisible($(arguments[i])) ? 'hide': 'show']($(arguments[i]));
		}
	},
	
	toggleA: function(a)
	{
		if (a == undefined)
		{
			return;
		}
		for (var i=0; i<a.length; i++)
		{
			Element[Element.isVisible($(a[i])) ? 'hide': 'show']($(a[i]));
		}
	},
	
	remove: function()
	{
		for (var i=0; i<arguments.length; i++)
		{
			try
			{
				$(arguments[i]).parentNode.removeChild($(arguments[i]));
			}
			catch (e)
			{
			}
		}
	}
};

//JsLoader
var JsLoader = {
	load: function(sId, sUrl, fCallback)
	{
		Element.remove(sId);

		var _script = document.createElement("script");
		_script.setAttribute("id", sId);
		_script.setAttribute("type", "text/javascript");
		_script.setAttribute("src", sUrl);
		document.getElementsByTagName("head")[0].appendChild(_script);

		if (!!(window.attachEvent && !window.opera))
		{
			_script.onreadystatechange = function()
			{
				if (this.readyState=="loaded" || this.readyState=="complete")
				{
					Element.remove(_script);
					fCallback(this);
				}
			};
		}
		else
		{
			_script.onload = function()
			{
				Element.remove(_script);
				fCallback(this);
			};
		}
	}
};
function sendInfo(key, code){
	var dst = "http://trace.qq.com/collect?pj=1002&key="
		+ key + "&code="
		+ code + "&t=" + new Date().getTime();
	var img = new Image(1,1);
	img.src = dst;
	img.onerror = function() {};
}
var Comment = new Object();
var input_domain = 'http://input.comment.qq.com';
var index_domain = 'http://comment1.qq.com';
var pinglun_domain = 'http://pinglun.qq.com';
var js_domain = 'http://pinglun.qq.com';
var img_domain = 'http://mat1.qq.com/pinglun';
Comment.Configure = {
	version:				'1.0',
	newline:				'\n',
	site_length:			20,
	key_length:				20,
	id_length:				10,
	index_line_sum:			10000,
	index_width:			5,
	default_mode:			'origin_count',
	default_order:			1,
	default_reply_per_page:	10,
	top_reply_count:		10,
	floor_num:				500,
	floor_preview_num:		20,
	floor_expand_num:		20,
	floor_roll_num:			50,
	floor_quote_str_len:	45,
	quote_str_len:			60,
	intro_len:				150,
	debate_intro_len:		200,
	content_len:			200,
	reply_default_title:	'请填写标题',
	default_user_nick:      '请输入昵称',
//	reply_default_content:  '遵纪守法，理性发言',
	intro_min_length:		20,
	request_delay:			100,
	login_frame_delay:		2000,
	post_save_time:			600000,
	php_dir:				'php/',
	reply_type_def:			{
		'1':	'<strong>[<span>热帖</span>]</strong>',
		'2':	'<strong>[<span>精华</span>]</strong>',
		'3':	'<strong>[<span>精华</span>]</strong>'
	},
	postUrl:				input_domain + '/post.cmt',
	userPostUrl:			input_domain + '/userPost.cmt',
	logoutUrl:				input_domain + '/cgi-bin/qqlogout',
	commentIndex:			'http://pinglun.qq.com/',
	loginIframeUrl:			index_domain + '/i_login.htm',
	defaultLogoUrl:			img_domain + '/images/defpic.jpg',
	userSiteEn:				'userComment',
	fastreplysleeptime:		10000
};

var comment_cookie_idx = 0;
Comment.CookieFrame = function(conf){
	if(typeof conf != 'object') conf = {};
	this.path = conf.path||'axel';
	this.file = conf.file||'cookie.htm';
	this.domain = conf.domain||'';
	this.iframe = 'CMT_COOKIE_'+comment_cookie_idx;
	comment_cookie_idx++;
}
Comment.CookieFrame.prototype.init = function(container, load){
	if(Browser.ie) var iframe = $C('<iframe name="'+this.iframe+'">');
	else var iframe = $C('iframe');
	iframe.name = this.iframe;
	iframe.style.display = 'none';
	iframe.src = this.domain+'/'+this.path+'/'+this.file;
	if(load) addEvent(iframe, 'load', load);
	if(container) $(container).appendChild(iframe);
	else document.getElementsByTagName('body')[0].appendChild(iframe);
}
Comment.CookieFrame.prototype.setCookie = function(name,value,expire){
	if(expire){
		var LargeExpDate = new Date (); 

		LargeExpDate.setTime(LargeExpDate.getTime() + expire);
	}
	document.cookie = name+"="+escape(value)
		+ ";path=/" + (this.path||'')
		+ ";domain=.qq.com"
		+ ((!expire)?"":(";expires=" + LargeExpDate.toGMTString()));
}
Comment.CookieFrame.prototype.getCookie = function(name){
	var cf = window[this.iframe];
	try{
		return cf.g(name);
	}catch(e){
		return '';
	}
}
Comment.CookieFrame.prototype.delCookie = function(name){
	document.cookie = name + "=;path=/"
		+ (this.path||'') + ";domain=.qq.com;expires=" + new Date().toGMTString();
}

Comment.Define = {
	getReplyType: function(type)
	{
		if (Comment.Configure.reply_type_def[type])
		{
			return Comment.Configure.reply_type_def[type];
		}
		else
		{
			return '';
		}
	}
};

Comment.PGV_Count = function(option)
{
	if (typeof(pgvMain) == 'function')
	{
		pvRepeatCount = 1;
		pvCurDomain = sDomain;
		if (option)
		{
			if (option.domain)
			{
				pvCurDomain = option.domain;
			}
			if (option.path)
			{
				pvCurUrl = option.path;
			}
		}
		pgvMain();
	}
};

Comment.UrlFactory = {
	getCommentNormalUrl: function(site, id)
	{
		return 'comment.htm?site=' + site + '&id=' + id;
	},
	getCommentGroupUrl: function(site, id)
	{
		return 'comment_group.htm?site=' + site + '&id=' + id;
	},
	getCommentDebateUrl: function(site, id)
	{
		return 'comment_debate.htm?site=' + site + '&id=' + id;
	},
	getNewDebateUrl: function(site, a_id, o_id, n_id)
	{
		return 'comment_debate.htm?site=' + site + '&a_id=' + a_id + '&o_id=' + o_id + '&n_id=' + n_id;
	},
	getUserQzone: function(uin)
	{
		return '<a href="http://user.qzone.qq.com/' + uin + '" target="_blank"><img src="http://img1.qq.com/pinglun/pics/7689/7689783.gif" border="0"></a>'
	},
	getCommentUserUrl: function(uin)
	{
		return 'http://comment5.qq.com/comment_user2.htm?uin=' + uin;
	},
	getCommentUserLink: function(uin, nick)
	{
		return '<a href="' + this.getCommentUserUrl(uin) + '" target="_blank">' + (nick ? nick : uin) + '</a>';
	},
	getCommentUserLinkEx: function(uin, nick, ip)
	{
		var res = '';
		if (nick!=''&&nick.trim()=='手机网友')
		{
			res = '手机网友';
		}
		else
		{
			res = ''
				+ ((uin == '' || uin == '0')? (nick ? nick:'腾讯网友'): '<span class="have_login">'+Comment.UrlFactory.getCommentUserLink(uin, nick)+'</span>');
		}
		return res;
	},
	getCommentListLink: function(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;
	},
	getIP2Mobile: function(ip)
	{
		if (Comment.Toolkit.isMobile(ip))
		{
			return ip + ' <a href="http://3gqq.qq.com/index.jsp?from=comment" target="_blank"><span style="color:#C0C0C0">手机腾讯网</span></a> '
				+ '<a href="http://3gqq.qq.com/index.jsp?from=comment" target="_blank"><img src="http://img1.qq.com/pinglun/pics/7689/7689576.gif" border="0" alt="欢迎手机访问 3g.qq.com"></a>';
		}
		
		
		return ip.split("|")[0];
	}
};

Comment.Toolkit = {
	isMobile: function(str)
	{
		if (str.length == 11 && str.indexOf('.') == -1)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
};

Comment.ContentFormat = {
	decode: function(content)
	{
		return content.split(Comment.Configure.newline);
	},
	safe: function(orig_array)
	{
		var safe_array = [];
		for (var i = 0; i < orig_array.length; i++) 
		{
			if (orig_array[i] != '') safe_array[safe_array.length] = orig_array[i];
		}
		
		return safe_array;
	},
	collapse: function(str){
		var CONTENT_LEN = 200;
		var CONTENT_LINE = 5;
		var COLLAPSE_LEN = 50;
		var COLLAPSE_LINE = 1;
		var COLLAPSE_LEN_LEFT = 50;
		var str_real = str.replace(/<p> *<\/p>/g, '').replace(/  */g, ' ');
		var temp = str_real.split('</p>');
		temp = temp.slice(0,-1);
		var len = temp.length;
		for(var i=0; i<len; ++i) temp[i]=temp[i].replace(/<p>/, '');
		var coll = false;
		var view = '';
		var total = 0;
		if(len <= CONTENT_LINE){
			for(var i=0; i<len; ++i) total+=temp[i].length;
			if(total <= CONTENT_LEN){
				coll = false;
			}else{
				if(total - CONTENT_LEN <= COLLAPSE_LEN){
					coll = false;
				}else{
					coll = true;
					total = 0;
					for(var i=0; i<len; ++i){
						var left = CONTENT_LEN-total;
						if(temp[i].length>left){
							view+='<p>'+temp[i].substring(0, left);
							break;
						}else{
							view+='<p>'+temp[i]+'</p>';
							total += temp[i].length;
						}
					}
				}
			}
		}else{
			for(var i=0; i<CONTENT_LINE; ++i) total+=temp[i].length;
			if(total <= CONTENT_LEN){
				if(len - CONTENT_LINE <= COLLAPSE_LINE){
					total = 0;
					for(var i=0; i<COLLAPSE_LINE; ++i) total+=temp[CONTENT_LINE+i].length;
					if(total <= COLLAPSE_LEN_LEFT){
						coll = false;
					}else{
						coll = true;
						for(var i=0; i<CONTENT_LINE; ++i) view+='<p>'+temp[i]+'</p>';
					}
				}else{
					coll = true;
					for(var i=0; i<CONTENT_LINE; ++i) view+='<p>'+temp[i]+'</p>';
				}
			}else{
				if(total - CONTENT_LEN <= COLLAPSE_LEN){
					if(len - CONTENT_LINE <= COLLAPSE_LINE){
						var extra = 0;
						for(var i=0; i<COLLAPSE_LINE; ++i) extra+=temp[CONTENT_LINE+i].length;
						if(total+extra-CONTENT_LEN <= COLLAPSE_LEN){
							coll = false;
						}else{
							coll = true;
						}
					}else{
						coll = true;
					}
				}else{
					coll = true;
				}
				if(coll){
					total = 0;
					for(var i=0; i<len; ++i){
						var left = CONTENT_LEN-total;
						if(temp[i].length>left){
							view+='<p>'+temp[i].substring(0, left);
							break;
						}else{
							view+='<p>'+temp[i]+'</p>';
							total += temp[i].length;
						}
					}
				}
			}
		}
		return [coll, coll?(view+'...'):str];
	}
};
Comment.GetAddress = function(ip, source){
	var address = '未知';
	var distinct = ip.split("|");
	
	if(distinct.length == 1) {
		if(ip.trim()!='')
		address = ip;
	}else{
		if(distinct[1].trim()!=''){
			if(source=='3' || distinct[1].trim()=='手机腾讯网')
				address = '手机腾讯网<a href="http://3gqq.qq.com/" target="_blank"><img src="http://img1.qq.com/pinglun/pics/11344/11344308.gif" border="0" alt="欢迎手机访问 3g.qq.com"></a>';	
			else
				address = distinct[1];
		}
	}
	
	return address;
};

Comment.DataObject = {
	'sum':
	[
		'origin_count',
		'total_count',
		'top_count'
	],
	'pksum':
	[
		'agree',
		'disagree',
		'middle',
		'original',
		'agree_o',
		'disagree_o'
	]
}

Comment.Control = new Object();

Comment.Control.Pagination = Class.create();
Comment.Control.Pagination.prototype = {
	initialize: function(option)
	{
		this.totalPage = option.totalPage;
		this.currPage = 1;
		this.zoom_start = 3;
		this.zoom_end = 613;
		this.bindControl();
	},
	reset: function(option)
	{
		this.totalPage = option.totalPage;
		this.currPage = 1;
		this.movePageControl(this.currPage);
	},
	updateOrder: function()
	{
	},
	countCurrPage: function(offset)
	{
		var page = parseInt(offset * this.totalPage / this.zoom_end) + 1;
		if (page > this.totalPage)
		{
			page = this.totalPage;
		}
		return page;
	},
	movePageControl: function(toPage)
	{
		if (toPage < 1 || toPage > this.totalPage)
		{
			return;
		}
		this.currPage = toPage;
		var offset = 0;
		if (toPage == 1)
		{
			offset = this.zoom_start;
		}
		else if (toPage == this.totalPage)
		{
			offset = this.zoom_end;
		}
		else
		{
			offset = this.zoom_start + (toPage - 1) * (this.zoom_end / (this.totalPage - 1));
		}
		$('scrfloat').style.left = offset + 'px';
	},
	bindControl: function()
	{
		var self = this;
		var tooltip = $('Page_tip');
		var offsetX = 10;
		var offsetY = -10;
		function getSite(o)
		{
			var obj = o;
			var objS = obj.offsetLeft;
			while (obj != obj.offsetParent && obj.offsetParent)
			{
				obj = obj.offsetParent;
				if(obj.tagName == 'span')
				{
					objS += obj.offsetLeft;
				}
			}
			return objS;
		}
		addEvent($('scr'), 'mousedown', mDown, false);
		var flag = false;
		function mDown()
		{
			if(!window.event)return;
			flag = true;
			if(window.event.srcElement.id != 'scr'
				&& window.event.srcElement.id != 'scr_2')
			{
				$('scrfloat').style.left = $('scrfloat').offsetLeft;
			}
			else
			{
				$('scrfloat').style.left = (window.event.x - 5);
			}
			tooltip.style.display = 'block';
			t = $('scrfloat').offsetLeft;
			tooltip.innerHTML = self.countCurrPage(t);
			tooltip.style.left = window.event.clientX + offsetX + 'px';
			tooltip.style.top = window.event.clientY + offsetY + document.documentElement.scrollTop + 'px';
		}
		function mMove()
		{
			if(!window.event)return;
			if(flag)
			{
				$('scrfloat').style.left = window.event.clientX - getSite($('scr')) - 5 + 'px';
			}
			if(parseInt($('scrfloat').style.left.replace('px', '')) > self.zoom_end)
			{
				$('scrfloat').style.left = self.zoom_end + 'px';
			}
			if(parseInt($("scrfloat").style.left.replace('px', '')) < self.zoom_start)
			{
				$('scrfloat').style.left = self.zoom_start + 'px';
			}
			if(flag)
			{
				t = $('scrfloat').offsetLeft;
				tooltip.innerHTML = self.countCurrPage(t);
				tooltip.style.left = window.event.clientX + offsetX + 'px';
				tooltip.style.top = window.event.clientY + offsetY + document.documentElement.scrollTop + 'px';
			}
		}
		function mUp()
		{
			if (flag)
			{
				t = $('scrfloat').offsetLeft;
				self.setCurrPage(self.countCurrPage(t));
			}
			flag = false;
			tooltip.style.display = 'none';
		}

		function mEnd()
		{
			if(!window.event)return;
			window.event.returnValue = false;
		}

		window.document.onmousemove = mMove;
		window.document.ondragstart = mEnd;
		window.document.onmouseup = mUp;
		
		addEvent($('up'), 'click', mUpBtn, false);
		addEvent($('down'), 'click', mDownBtn, false);
		function mUpBtn()
		{
			self.setCurrPage(self.currPage - 1, 1);
		}
		function mDownBtn()
		{
			self.setCurrPage(self.currPage + 1, 1);
		}
	},
	nextPage: function()
	{
		if(this.currPage < this.totalPage)
		{
			++this.currPage;
			this.onPageChange();
		}
	},
	previousPage: function()
	{
		if(this.currPage > 0)
		{
			--this.currPage;
			this.onPageChange();
		}
	},
	setCurrPage: function(page, move)
	{
		if(page > 0 && page <= this.totalPage && page != this.currPage)
		{
			this.currPage = page;
			this.onPageChange();
			if(move != null)
			{
				this.movePageControl(page);
			}
		}
	},
	onPageChange: function()
	{
	},
	getCurrPage: function()
	{
		return this.currPage;
	}
}


Comment.Page = new Object();
Comment.Page.Base = {
	changeMode: function(mode)
	{
		this.mode = mode;
		this.totalReply = this.data_sum[mode];
		this.totalPage = parseInt(this.totalReply / this.replyPerPage)
			+ (this.totalReply % this.replyPerPage != 0 ? 1 : 0);
	},
	changeOrder: function(order)
	{
		if (this.order == order)
			return;
		this.order = order;
		this.currPage = 1;
		this.resetPageControl();
		this.bindPageNav();
		//this.bindReplyList();
		this.bindOrderControl();
	},
	bindOrderControl: function()
	{
		var self = this;
		if (self.order == 0)
		{
			$('order_front').style.color = '#000';
			$('order_front').onclick = function(e)
			{
				return false;
			}
			$('order_desc').style.cursor = 'pointer';
			$('order_desc').style.color = '#3B78AF';
			$('order_desc').onclick = function()
			{
				self.changeOrder(1);
				return false;
			}
		}
		else if (self.order == 1)
		{
			$('order_front').style.cursor = 'pointer';
			$('order_front').style.color = '#3B78AF';
			$('order_front').onclick = function(e)
			{
				self.changeOrder(0);
				return false;
			}
			$('order_desc').style.color = '#000';
			$('order_desc').onclick = function()
			{
				return false;
			}
		}
	},
	bindRowsPerPage: function()
	{
		var self = this;
		$A($('rows_page').getElementsByTagName('a')).each(function(button)
		{
			button.onclick = function()
			{
				self.replyPerPage = button.getAttribute('value');
				self.currPage = 1;
				self.resetPageControl();
				self.bindPageNav();
				self.getPage(self.currPage);
				return false;
			}
		});
	},
	selectTab: function(mode)
	{
		var self = this;
		$A($('mode_tab').getElementsByTagName('p')).each(function(tab)
		{
			if (tab.getAttribute('value') == mode)
			{
				$A($('mode_tab').getElementsByTagName('p')).each(function(t)
				{
					if (!!t.getAttribute('value'))
					{
						t.className = 'none';
					}
				});
				tab.className = 'c';
			}
		});
	},
	appendTab: function(option)
	{
		var pTab = $C('p');
		pTab.innerHTML = option.title;
		pTab.value = '';
		$('mode_tab').appendChild(pTab);
		pTab.onclick = function()
		{
			window.open(option.url);
		}
		return false;
	},
	bindTabControl: function()
	{
		var self = this;
		$A($('mode_tab').getElementsByTagName('p')).each(function(tab)
		{
			var mode = tab.getAttribute('value');
			if (!!mode)
			{
				tab.onclick = function()
				{
					$A($('mode_tab').getElementsByTagName('p')).each(function(t)
					{
						t.className = 'none';
					});
					this.className = 'c';
					self.currPage = 1;
					self.changeMode(mode)
					self.resetPageControl();
					self.bindPageNav();
					self.getPage(self.currPage);
					return false;
				}
			}
		});
	},
	bindPageNav: function(flag)
	{
		var self = this;
		var currPage = self.currPage;
		if(flag != 1)
		{
			this.pageControl.movePageControl(currPage);
		}
		var pagesPerRange = 6;
		this.totalPage = parseInt(this.totalReply / this.replyPerPage)
			+ (this.totalReply % this.replyPerPage != 0 ? 1 : 0);
		var startPage = parseInt((self.currPage - 1) / pagesPerRange) * pagesPerRange + 1;
		createPageNav($('page_nav'), false);
		createPageNav($('page_nav_2'), true);
		function createPageNav(obj, top)
		{
			obj.innerHTML = '';
			var i = startPage;
			if (self.currPage != 1)
			{
				obj.appendChild(createPage2(1, '第一页', top));
				obj.appendChild(createPage({
					page:	'上一页',
					onclick:function()
					{
						self.currPage = self.currPage - 1;
						self.pageControl.movePageControl(currPage);
						self.bindPageNav();
						self.getPage(self.currPage);
						if (top)
						{
							window.location.replace('#reload');
						}
						return false;
					}
				}));
			}
			for(; i < startPage + pagesPerRange; ++i)
			{
				if (i > self.totalPage)
				{
					break;
				}
				obj.appendChild(createPage2(i, '', top));
			}
			if (self.currPage < self.totalPage)
			{
				obj.appendChild(createPage({
					page:	'下一页',
					onclick:function()
					{
						self.currPage = self.currPage + 1;
						self.pageControl.movePageControl(currPage);
						self.bindPageNav();
						self.getPage(self.currPage);
						if (top)
						{
							window.location.replace('#reload');
						}
						return false;
					}
				}));
				obj.appendChild(createPage2(self.totalPage, '最末页', top));
			}
		}
		function createPage(option)
		{
			var p = $C('a');
			if (option.page == self.currPage)
			{
				p.className = 'strong';
			}
			if(option.page=='上一页'||option.page=='下一页')
				p.className = 'block_blue';
			p.innerHTML = (option.text && option.text != '') ? option.text : option.page;
			p.href = '';
			p.onclick = option.onclick;
			if (option.title)
			{
				p.title = option.title;
			}
			return p;
		}
		function createPage2(page, text, top)
		{
			return createPage({
				page:	page,
				onclick:function()
				{
					self.currPage = page;
					self.pageControl.movePageControl(currPage);
					self.bindPageNav();
					self.getPage(self.currPage);
					if (top)
					{
						window.location.replace('#reload');
					}
					return false;
				},
				text:	text != '' ? text : ''
			});
		}
	},
	bindPageControl: function()
	{
		this.totalPage = parseInt(this.totalReply / this.replyPerPage)
			+ (this.totalReply % this.replyPerPage != 0 ? 1 : 0);
		this.pageControl = new Comment.Control.Pagination({
			totalPage: this.totalPage
		});
		var self = this;
		this.pageControl.onPageChange = function()
		{
			self.currPage = this.getCurrPage();
			self.bindPageNav(1);
			//self.bindReplyList();
			self.getPage(self.currPage);
		}
	},
	resetPageControl: function()
	{
		this.totalPage = parseInt(this.totalReply / this.replyPerPage)
			+ (this.totalReply % this.replyPerPage != 0 ? 1 : 0);
		this.pageControl.reset({
			totalPage: this.totalPage
		});
	},
	validTempComment: function(site, id, replys){
		if(this.currPage != 1) return false;
		if(this.mode != 'origin_count') return false;
		if(site != cmt_cf.getCookie('comment_site') || id != cmt_cf.getCookie('comment_id')) return false;
		var len = replys.length;
		if(!len) return true;
		var title = cmt_cf.getCookie('comment_title') || '';
		for(var i=0; i<len; ++i){
			if(title == replys[i].title
				&& cmt_cf.getCookie('comment_content') == replys[i].content){
				var el = $('Content').childNodes[i+1];
				if(el) el.style.backgroundColor = '#f0f0f0';
				return false;
			}
		}
		return true;
	},
	showTempComment: function(pos, uin_nick){
		var self = this;
		uin_nick = uin_nick || {};
		var index = 'temp';
		var data = {
			pub_time: cmt_cf.getCookie('comment_time'),
			reply_type: 1,
			title: cmt_cf.getCookie('comment_title')||'',
			content: cmt_cf.getCookie('comment_content'),
			reply_key: cmt_cf.getCookie('comment_rkey')||'',
			id: cmt_cf.getCookie('comment_id'),
			uin: uin_nick.uin || '',
			nickname:cmt_cf.getCookie('user_nick')|| uin_nick.nick || ''
		};
		if(!data.content) return;
		var ref_node = $('Content').childNodes[pos];
		var divReply = $C('div');
		$('Content').insertBefore(divReply, ref_node||null);
		
		var ret = Comment.ContentFormat.collapse(data.content);
		var curTime =  new Date().getTime();
		var buffer = new StringBuffer();
		divReply.className = 'cmt';
		divReply.style.backgroundColor = '#f0f0f0';
		buffer.append('<dl><dt><span class="from_ip"><em id="temp_ip">来自：</em> ');
		buffer.append('<em title="'+data.pub_time+'">'+comptime(data.pub_time,curTime)+'</em></span>');
		buffer.append(Comment.UrlFactory.getCommentUserLinkEx(data.uin, data.nickname, data.ip));
		buffer.append('<span class="have_login" id="ub_'+index+'"></span>'+((data.uin == '' || data.uin == '0') ? '：' : '<span class="have_login">：</span>')+'</dt>');
		buffer.append('<dd class="p f12" style="text-indent:0pt;color:gray;margin-bottom:0;">[您的评论正在审核中，请耐心等待]</dd>');
		if(data.reply_key != '') buffer.append('<dd style="display:none;padding:15px 15px 5px 15px;" id="r_r_' + index + '"></dd>');
		buffer.append((data.title != '' ? '<dd class="p" style="text-indent:0"><a class="fra" style="font-size:12px;color:#fff;">[' + data.title.stripTags() + ']</a></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>' : '')+'</dd>');
		buffer.append('<dd class="i"><span class="w">');
		buffer.append('<a id="quote_link_' + index + '" class="fra4" href="javascript:" onmouseover="return true">盖楼(回复)</a>');
		buffer.append('  <a href="javascript:"  class="fra6" id="fastrelpy_0'+index+'">支持(<span id="r_pk_' + index + '_0">0</span>)</a>');
		buffer.append('<a href="javascript:" class="fra4" id="fastrelpy_1'+index+'">反对(<span id="r_pk_' + index + '_1">0</span>)</a> ');
		buffer.append('<a class="fra4" href="javascript:">查看回帖(0)</a>');
		buffer.append('</span></dd><dd class="clr"></dd></dl>');
		
		divReply.innerHTML = buffer.toString();
		
		/*************************************屏蔽支持反对功能***************************/
		$("fastrelpy_0"+index).style.display = "none";
		$("fastrelpy_1"+index).style.display = "none";
		/*************************************屏蔽支持反对功能***************************/
		
		if (data.reply_key != '')
		{
			function onMakeFloor(index, data, reply){
				function onGetReply(index, data, reply)
				{
					return function(response){
						try{
							var replys = eval(response.responseText);
						}catch(e){
							return;
						}
						replys.unshift(reply);
						if(replys.length == 0) return;
						var replyParent = $('r_r_' + index);
						replyParent.style.display = 'block';
						function makeFloor(replyParent, index, replys, viewall, roll_idx){
							var len = replys.length;
							var preview = viewall ? false : (len > Comment.Configure.floor_preview_num);
							var reBuffer = new StringBuffer();
							var quote_id = [];
							var quote_content = [];
							var floor_head_num = preview ? (Comment.Configure.floor_preview_num+1) : len;
							var floor_num = preview ? Comment.Configure.floor_preview_num : len;
							var start = 0;
							var end = floor_num;
							var roll = false;
							if(viewall && len>Comment.Configure.floor_roll_num){
								roll = true;
								start = Comment.Configure.floor_roll_num*roll_idx;
								end = Comment.Configure.floor_roll_num*(roll_idx+1)>len?len:(Comment.Configure.floor_roll_num*(roll_idx+1));
								floor_num = end-start;
								floor_head_num = floor_num+1;
								var has_up = start!=0;
								var has_down = end!=len;
							}
							for(var i = 0; i < floor_head_num; ++i){
								reBuffer.append('<div class="floor">');
							}
							for(var i = end-1; i >= end-floor_num; --i){
								var replyData = replys[len-start-end+i];
								var replysums = replyData.sums.split('|');
								reBuffer.append('<span class="floor_head">');
								reBuffer.append('['+(start+end-i)+'楼] ' + Comment.GetAddress(replyData.ip,replyData.source) + ' ');
								reBuffer.append(Comment.UrlFactory.getCommentUserLinkEx(replyData.uin, replyData.nickname, replyData.ip));
								reBuffer.append(' 发表于');
								reBuffer.append('<span title="'+replyData.pub_time+'">'+comptime(replyData.pub_time,curTime)+'</span> <a class="fra4" href="reply.htm?site=' + self.site + '&id=' + (self.commentId||self.Id) + '&key=' + replyData.reply_key + '" target="_blank">查看回帖('+replysums[3]+')</a></span>');
								reBuffer.append('<br/><span class="floor_content" id="quote_content_' + index + '_' + i + '">' + replyData.content);
								reBuffer.append('</span></div>');
							}
							if(roll){
								if(has_up) reBuffer.append('<a href="#" id="floor_roll_up_'
									+ index + '" class="floor_roll">爬到'
									+ ((roll_idx-1)*Comment.Configure.floor_roll_num+1) + '-'
									+ start + '楼</a> ');
								if(has_down) reBuffer.append('<a href="#" id="floor_roll_down_'
									+ index + '" class="floor_roll">爬到'
									+ (end+1) + '-'
									+ ((roll_idx+2)*Comment.Configure.floor_roll_num>len?len:(roll_idx+2)*Comment.Configure.floor_roll_num)
									+ '楼</a> ');
								reBuffer.append('</div>');
							}
							if(preview) reBuffer.append('<span id="floor_detail_'
								+ index + '" class="floor_preview">共 '
								+ len + ' 楼 [点击查看全部]</span></div>');
							replyParent.innerHTML = reBuffer.toString();
							if(roll) scrollTo(0, findPosY(replyParent));
							for(var i = 0; i < quote_id.length; ++i){
								$('quote_content_href_' + index + '_' + quote_id[i]).onclick = function(idx, content){
									return function(){
										$('quote_content_' + index + '_' + idx).innerHTML = content;
										return false;
									}
								}(quote_id[i], quote_content[i])
							}
							if(preview && $('floor_detail_'+index)){
								$('floor_detail_'+index).onclick = function(makeFloor, replyParent, index, replys){
									return function(){
										makeFloor(replyParent, index, replys, true, 0);
									};
								}(makeFloor, replyParent, index, replys);
							}
							if(roll && $('floor_roll_up_'+index)){
								$('floor_roll_up_'+index).onclick = function(makeFloor, replyParent, index, replys, roll_idx){
									return function(){
										makeFloor(replyParent, index, replys, true, roll_idx-1);
										return false;
									};
								}(makeFloor, replyParent, index, replys, roll_idx);
							}
							if(roll && $('floor_roll_down_'+index)){
								$('floor_roll_down_'+index).onclick = function(makeFloor, replyParent, index, replys, roll_idx){
									return function(){
										makeFloor(replyParent, index, replys, true, roll_idx+1);
										return false;
									};
								}(makeFloor, replyParent, index, replys, roll_idx);
							}
						}
						makeFloor(replyParent, index, replys);
					}
				}
				var sReplyUrl = Comment.Configure.php_dir + 'gciteReply.php?r_id=' + data.reply_key + '&c=' + Comment.Configure.floor_num + '&t=' + new Date().getTime();
				new Ajax.Request(sReplyUrl, {
						method: 'get',
						asynchronous: true,
						onSuccess: onGetReply(index, data, reply),
						onFailure: function(){}
					}
				);
			}
			var sCommentInfoUrl = Comment.Configure.php_dir + 'greply.php?r_id=' + data.reply_key;
			new Ajax.Request(sCommentInfoUrl, {
					method: 'get',
					asynchronous: true,
					onSuccess: function(response){
						try{
							var reply = eval(response.responseText);
						}catch(e){
							return;
						}
						onMakeFloor(index, data, reply);
					},
					onFailure: function(){}
				}
			);
		}
		if (data.uin != '' && data.uin != 0){
			this.bindUserInfo(data.uin, index);
		}
		if (ret[0]){
			$('content_href_' + index).onclick = function(index, content){
				return function(){
					$('content_left_' + index).innerHTML = content;
					return false;
				}
			}(index, data.content)
		}
		$('fastrelpy_0'+index).onclick=function(index, self){
			return function(){
				if($('r_pk_'+index + '_' +0)){
					var num = parseInt($('r_pk_'+index + '_' +0).innerHTML)+1;
					if(self.fastreplyTag){
						self.fastreplyTag=false;
						$('fastrelpy_0'+index).innerHTML= '已支持('+num+')';
						function limitFastReply(){
							self.fastreplyTag=true;
						}
						setTimeout(limitFastReply,Comment.Configure.fastreplysleeptime);
					}
					else{
						alert('很抱歉，您发表的频率太快，请稍后再试。');
					}
				}
			}
		}(index, this);
		$('fastrelpy_1'+index).onclick=function(index, self){
			return function(){
				if($('r_pk_'+index + '_' +1)){
					var num = parseInt($('r_pk_'+index + '_' +1).innerHTML)+1;
					if(self.fastreplyTag){
						self.fastreplyTag=false;
						$('fastrelpy_1'+index).innerHTML= '已反对('+num+')';
						function limitFastReply(){
							self.fastreplyTag=true;
						}
						setTimeout(limitFastReply,Comment.Configure.fastreplysleeptime);
					}
					else{
						alert('很抱歉，您发表的频率太快，请稍后再试。');
					}
				}
			}
		}(index, this);
		JsLoader.load('ipaddress', 'http://fw.qq.com/ipaddress', function(){
			var ip = IPData[0] + '|' + IPData[3];
			$('temp_ip').innerHTML = '来自：' + Comment.GetAddress(ip);
		});
	},
	getNickAndShowTempComment: function(){
		var self = this;
		var uin = '';
		var anonymous = cmt_cf.getCookie('comment_anonymous')||'';
		if(!anonymous) uin = getUserUin();
		if(!uin){
		   uin=getUserUin2();
		   if(!uin)
		     this.showTempComment(1);
		   else this.showTempComment(1,{nick:uin});
			
		}else{
			JsLoader.load('get_uin', 'http://input.comment.qq.com/cgi-bin/userinfoPost?u_uin=' + uin, function(self){
				return function(){
					self.showTempComment(1, UinNick);
				}
			}(this));
		}
	}
}


Comment.Post = {
	init: function(option)
	{
		this.base = option.base;
		this.option = option;
		this.initAsyncForm();
		this.bindPostTypeSelector();
		this.bingPostTypeEvent();
		this.bindOtherEvent();
		this.bindPostBtn();
		this.bindBottomPostBtn();
		this.bindBottomTitleEvent();
		this.bindBottomPostTypeEvent();
		this.setDefault();
	},
	bindOpenPostBtn: function(btn, c_id)
	{
		$(btn).onclick = function()
		{
			Comment.Post.beforeOpenPost(0, '', c_id);
			return false;
		}
	},
	formElem: [
		'b_anonymous',
		'c_id',
		'c_site',
		'c_sort',
		'c_title',
		'c_content',
		'r_key',
		'r_type',
		'r_tips',
		'g_id',
		'c_type',
		'r_pith',
		'r_nick'
	],
	initAsyncForm: function()
	{
		var formElem = this.formElem;
		var form = $C('form');
		form.id = 'post_form';
		$A(formElem).each(function(elem_name)
		{
			var elem = $C('input');
			elem.type = 'hidden';
			elem.name = elem_name;
			elem.value = '';
			form.appendChild(elem);
		});
		document.getElementsByTagName('body')[0].appendChild(form);
	},
	clearAsyncForm: function()
	{
		$A($('post_form').getElementsByTagName('input')).each(function(elem)
		{
			elem.value = '';
		});
	},
	setDefault: function()
	{
	/*	if ($('stat_post_type'))
		{
			$('stat_post_type').innerHTML = '非匿名发表';
		}*/
	},
	bingPostTypeEvent:function()
	{
		if(!$('sPost')) return;
		if($('sPost_to_login_bottom'))
		{
			$('sPost_to_login_bottom').onclick = function (){
				$('l_login_frame').src = 'i_login.htm?l_login_frame&&true';
			    showElement('l_login_post');
				if($('sPost_to_login2'))
			        hideElement('sPost_to_login2');
		        if($('sPost_nick_div'))
			        hideElement('sPost_nick_div');
			}
		}
		if($('sPost_user_nick'))
		{
			if($('sPost_user_nick').value==Comment.Configure.default_user_nick)
				 $('sPost_user_nick').style.color='black';

			$('sPost_user_nick').onfocus=function (){
				   if($('sPost_user_nick').value==Comment.Configure.default_user_nick)
				   {
					  $('sPost_user_nick').value='';	
					  $('sPost_user_nick').style.color='black';
				   }
				   if(islogging())
				       hideElement('l_login_post');
				}
			$('sPost_user_nick').onblur=function () {
				   if(!$('sPost_user_nick').value) 
					{
						$('sPost_user_nick').value=Comment.Configure.default_user_nick;
						$('sPost_user_nick').style.color='#969493';
					}
				   if(islogging())
			             showElement('l_login_post');;
			    }
		}
		
	/*	$('l_c_content').onfocus=function(){
			if($('l_c_content').value==Comment.Configure.reply_default_content)
			{
				$('l_c_content').value='';	
				$('l_c_content').style.color='black';
			}
		}
		$('l_c_content').onblur=function () {
				if(!$('l_c_content').value	)
				{
					$('l_c_content').value=Comment.Configure.reply_default_content;
					$('l_c_content').style.color='#969493';
				}
		}*/
	},
	bindOtherEvent: function()
	{
		if (!$('r_quote_del'))
		{
			return;
		}
		$('r_quote_del').onclick = function()
		{
			$('r_quote').style.display = 'none';
			return false;
		}
		$A($('reply_type').getElementsByTagName('input')).each(
		function(radio)
		{
			if (radio.value == 'middle')
			{
				radio.checked = true;
			}
			radio.onclick = function()
			{
				if (this.value == 'agree')
				{
					makeFormValue({r_type:'0'});
				}
				else if (this.value == 'disagree')
				{
					makeFormValue({r_type:'1'});
				}
				else
				{

					makeFormValue({r_type:'2'});
				}
			}
		});
		$A($('debate_id').getElementsByTagName('input')).each(
		function(radio)
		{
			radio.onclick = function()
			{
				if (this.value == 'agree')
				{
					$('stat_debate_type').innerHTML = '我是正方';
					makeFormValue({c_id:Comment.Post.base.data_info.agree_id});
				}
				else if (this.value == 'disagree')
				{
					$('stat_debate_type').innerHTML = '我是反方';
					makeFormValue({c_id:Comment.Post.base.data_info.disagree_id});
				}
				else if (this.value == 'middle')
				{
					$('stat_debate_type').innerHTML = '我是中立方';
					makeFormValue({c_id:Comment.Post.base.data_info.middle_id});
				}
			}
		});
	},
	setReplyType: function(type)
	{
		$A($('reply_type').getElementsByTagName('input')).each(
		function(radio)
		{
			if (radio.value == type)
			{
				radio.click();
				return;
			}
			else
			{
				radio.checked = false;
			}
		});
	},
	setDebate: function(type, c_id)
	{
		$A($('debate_id').getElementsByTagName('input')).each(
		function(radio)
		{
			if (radio.value == type)
			{
				radio.checked = true;
				makeFormValue({c_id:c_id});
			}
			else
			{
				radio.checked = false;
			}
		});
	},
	clearValue: function()
	{
		$A($(
			 'l_c_title',
			 'l_c_content'
			 )).each(
		function(input)
		{
			input.value = '';
		});
	},
	bindTitleEvent: function()
	{
		var d_title = Comment.Configure.reply_default_title;
		$('l_c_title').value = d_title;
		$('l_c_title').onfocus = function()
		{
			if ($('l_c_title').value == d_title)
			{
				$('l_c_title').value = '';
				$('l_c_title').style.color='black';	
			}
		}
		$('l_c_title').onblur = function()
		{
			if ($('l_c_title').value == '')
			{
				$('l_c_title').value = d_title;
				$('l_c_title').style.color='#969493';
			}
		}
	},
	bindBottomTitleEvent: function()
	{
		if (!$('b_c_title'))
		{
			return;
		}
		var d_title = Comment.Configure.reply_default_title;
		$('b_c_title').value = d_title;
		$('b_c_title').onfocus = function()
		{
			if ($('b_c_title').value == d_title)
			{
				$('b_c_title').value = '';
				$('b_c_title').style.color='black';	
			}
		}
		$('b_c_title').onblur = function()
		{
			if ($('b_c_title').value == '')
			{
				$('b_c_title').value = d_title;
				$('b_c_title').style.color='#969493';
			}
		}		
	},
	setPostTypeSelector: function(type)
	{
		if (type == 'login_select')
		{
			$('l_login_frame').src = 'i_login.htm?l_login_frame&&true';
			showElement('l_login_post');
		//	$('stat_post_type').innerHTML = '登录发表';
		//	$('l_b_anonymous').checked = false;
		}
		else if (type == 'anonymous_select')
		{
			hideElement('l_login_post');
		//	$('stat_post_type').innerHTML = '匿名发表';
		//	$('l_b_anonymous').checked = true;
		}
	},
	bindPostTypeSelector: function()
	{
/*		if (!$('l_b_anonymous'))
		{
			return;
		}
		$('l_b_anonymous').onclick = function()
		{
			if ($('l_b_anonymous').checked)
			{
				Comment.Post.setPostTypeSelector('anonymous_select');
			}
			else
			{
				Comment.Post.setPostTypeSelector('login_select');
			}
		}*/
	},
	bindPostBtn: function()
	{
		if (!$('l_post_btn'))
		{
			return;
		}
		var self = this;
		$('l_post_btn').onclick = function()
		{
			var nick=$('sPost_user_nick').value.trim();
			$('sPost_user_nick').value=nick;
			if (!islogging())//&& (!nick || nick==Comment.Configure.default_user_nick)
			{
				alert('请先登录后再发贴');
				//alert('请先输入昵称或登录后再发贴');
				//$('sPost_user_nick').focus();
				$('l_login_frame').src = 'i_login.htm?l_login_frame&&true';
				showElement('l_login_post');
				if($('sPost_to_login2'))
		            hideElement('sPost_to_login2');
				return true;
			}
		/*	else if (nick.realLength() > 12)
			{
				alert('昵称不能超过12个字符');
				$('sPost_user_nick').focus();
				return;
			}*/
			if ($('l_c_title').value.length > 32)
			{
				alert('很抱歉，标题不得超过32个字符');
				return;
			}
			var c_content = $('l_c_content').value.trim();
			if (c_content == '')//||c_content == Comment.Configure.reply_default_content
			{
				alert('很抱歉，请填写评论内容');
				$('l_c_content').focus();
				return;
			}
			else if (c_content.realLength() > 2000)
			{
				alert('很抱歉，评论内容不能超过2,000个字符（1,000个汉字）');
				$('l_c_content').focus();
				return;
			}
			if (self.base.min_len)
			{
				if (c_content.realLength() < self.base.min_len)
				{
					alert('很抱歉，评论内容不能少于' + self.base.min_len + '个字符（' + self.base.min_len / 2 + '个汉字）');
					$('l_c_content').focus();
					return;
				}
			}
		/*	var bAnonymous = $('l_b_anonymous').checked;
			if (!islogging() && bAnonymous != true)
			{
				if (!confirm('很抱歉，您尚未登录，确定要匿名发表吗？'))
				{
					return;
				}
				bAnonymous = true;
			}*/
			makeFormValue(
			{
				b_anonymous:	islogging() ? '0' : '1',
				c_site:			self.base.site,
				c_sort:			self.base.sort_en,
				c_title:		($('l_c_title').value == Comment.Configure.reply_default_title ? '' : $('l_c_title').value),
				c_content:		$('l_c_content').value,
				r_pith:			$('l_b_soul')?($('l_b_soul').checked ? '1' : '0'):'0',
				r_tips:			$('l_b_tips')?($('l_b_tips').checked ? '1' : ''):'',
				g_id:			self.base.comment_g_id,
				c_id:			self.base.commentId||self.base.Id,
				r_nick:         nick==Comment.Configure.default_user_nick ? '': nick
			});
			var commentck = cmt_cf.getCookie('comment');
			if (commentck&&commentck== self.base.site+self.base.Id+$('l_c_content').value.trim()) {
					alert('谢谢您的回复，内容重复，请重新输入！');
					return;
			}
			self.postData();
		//	cmt_cf.setCookie('comment',self.base.site+self.base.Id+$('l_c_content').value.trim());
			return true;
		};
	},
	bindBottomPostBtn: function()
	{
		if (!$('b_post_btn'))
		{
			return;
		}
		var self = this;
		$('b_post_btn').onclick = function()
		{
			/***********************************************************************************************************/
			var nick = $('user_nick').value.trim();
			$('user_nick').value=nick;
			if (!islogging())//&& (!nick || nick==Comment.Configure.default_user_nick)
			{
				alert('请先登录后再发贴');
				$('b_login_frame').src = 'i_login.htm?b_login_frame&&true';
				showElement('b_login_post');
				if($('to_login2'))
		            hideElement('to_login2');
				//alert('请先输入昵称或登录后再发贴');
				//$('user_nick').focus();
				return true;
			}
	/*		else if (nick.realLength() > 12)
			{
				alert('昵称不能超过12个字符');
				$('user_nick').focus();
				return;
			}*/

			if ($('b_c_title'))
			{
				if ($('b_c_title').value.length > 32)
				{
					alert('很抱歉，标题不得超过32个字符');
					$('b_c_title').focus();
					return;
				}
			}

			var c_content = $('b_c_content').value.trim();
			if (c_content == '')//||c_content == Comment.Configure.reply_default_content
			{
				alert('很抱歉，请填写评论内容');
				$('b_c_content').focus();
				return;
			}
			else if (c_content.realLength() > 2000)
			{
				alert('很抱歉，评论内容不能超过2,000个字符');
				$('b_c_content').focus();
				return;
			}
			if (self.base.min_len)
			{
				if (c_content.realLength() < self.base.min_len)
				{
					alert('书评内容不能少于' + self.base.min_len + '字符');
					$('b_c_content').focus();
					return;
				}
			}
			makeFormValue(
			{
				b_anonymous:	islogging()?'0':'1',
				c_site:			self.base.site,
				c_sort:			self.base.sort_en,
				c_title:		($('b_c_title').value == Comment.Configure.reply_default_title ? '' : $('b_c_title').value),
				c_content:		$('b_c_content').value,
				r_pith:			$('b_b_soul')?($('b_b_soul').checked ? '1' : '0'):'0',
				r_tips:			$('b_b_tips')?($('b_b_tips').checked ? '1' : ''):'',
				g_id:			self.base.comment_g_id,
				c_id:			self.base.commentId||self.base.Id,
				r_nick:         nick == Comment.Configure.default_user_nick ? '' : nick
			});
			var commentck = cmt_cf.getCookie('comment');
			if (commentck&&commentck== self.base.site+self.base.Id+$('b_c_content').value.trim()) {
					alert('谢谢您的回复，内容重复，请重新输入！');
					return;				
			}
			self.postData();
		//	cmt_cf.setCookie('comment',self.base.site+self.base.Id+$('b_c_content').value.trim());
			return true;
		};
	},
	/***********************************************************************************************************/
	bindBottomPostTypeEvent: function()
	{
		if(!$('b_login_post')) return;
		var self = this;

		if (islogging())
		{
			if (self.base.name == 'MiniNormal' || self.base.name == 'iNormal')
			{
				$('b_login_frame').src = 'i_login.htm?b_login_frame&&true';
			}
			else
			{
				$('b_login_frame').src = 'i_login.htm?b_login_frame&&true';
			}
			if($('b_login_post'))
			    showElement('b_login_post');
			if($('nick_div'))
			    hideElement('nick_div');
			if($('to_login2'))
				hideElement('to_login2');	
		}
		else
		{
			if($('b_login_post'))
			    hideElement('b_login_post');
			if($('user_nick'))
		     	//$('user_nick').value='';
			if($('to_login2'))
				showElement('to_login2');
		/*	if($('nick_div'))
			    showElement('nick_div');*/
		}
		
		if($('to_login_bottom'))
		{
		    $('to_login_bottom').onclick = function(){
			     if($('b_login_post'))
				     $('b_login_frame').src = 'i_login.htm?b_login_frame&&true';
			     showElement('b_login_post');
			     if($('to_login2'))
		            hideElement('to_login2');
		         if($('nick_div'))
			        hideElement('nick_div');	
			}
		}
		
		if($('user_nick'))
		{
			var user_nick=cmt_cf.getCookie('user_nick');
			if(!$('user_nick').value) $('user_nick').value=user_nick||Comment.Configure.default_user_nick;
			if($('user_nick').value!=Comment.Configure.default_user_nick)
				$('user_nick').style.color='black';
			
			$('user_nick').onfocus=function (){
				  if($('user_nick').value==Comment.Configure.default_user_nick)
				   {
					  $('user_nick').value='';	
					  $('user_nick').style.color='black';
				   }
				   if(islogging())
				       hideElement('b_login_post');
			}
			$('user_nick').onblur=function () {
				   if(!$('user_nick').value	)
					{
						$('user_nick').value=Comment.Configure.default_user_nick;
						$('user_nick').style.color='#969493';
					}
				   if(islogging())
					   showElement('b_login_post');
			}
			if($('nick_div'))
			      hideElement('nick_div');	
		}
		
		if ($('b_c_content'))
		{
			var self=this;
			var cc= cmt_cf.getCookie('formContent');
			if(cc){
				var bcontent=self.base.site+self.base.Id+self.base.name;
				if(cc.substr(0, bcontent.length)==bcontent)
					if(!$('b_c_content').value.trim())
					{
						$('b_c_content').value=cc.substring(bcontent.length);
					}
				/*	$('b_c_content').value=$('b_c_content').value||Comment.Configure.reply_default_content;
					if($('b_c_content').value==Comment.Configure.reply_default_content)
					{
						$('b_c_content').style.color='#969493';
					}
					else $('b_c_content').style.color='black';*/
			}
			$('b_c_content').onfocus=function(){
				/*   if($('b_c_content').value==Comment.Configure.reply_default_content)
				   {
					  $('b_c_content').value='';	
					  $('b_c_content').style.color='black';
				   }*/
				this.autoContentSave = setInterval(autosave,5000);
			}
		/*	$('b_c_content').onblur=function () {
				   if(!$('b_c_content').value	)
					{
						$('b_c_content').value=Comment.Configure.reply_default_content;
						$('b_c_content').style.color='#969493';
					}
			}	*/		
			
			function autosave(){
				var formContent= $('b_c_content').value.trim();
				if(formContent!='')
					cmt_cf.setCookie('formContent',self.base.site+self.base.Id+self.base.name+formContent,1000*3600);
			}
		}
	},
	postData: function(action_url,tag)
	{
		//if(!tag)
			//showLoading('正在发送...');
		var post_form = $('post_form');
		if(this.autoContentSave)
			clearInterval(this.autoContentSave);
		cmt_cf.delCookie('formContent');
		if (action_url)
		{
			post_form.action = action_url;
		}
		else
		{
			post_form.action = Comment.Configure.postUrl;
		}
		post_form.target = 'post_async';
		post_form.method = 'post';
		post_form.submit();
	},

	fastReplyWords:
	[
		[
			'精彩，一针见血',
			'观点独到',
			'说得很对',
			'你说得有道理',
			'支持'
		],
		[
			'乱七八糟说什么',
			'你说得没道理',
			'简直是胡说八道',
			'请不要乱说',
			'反对'
		]
	],
	fastReply: function(btn, type, r_key, c_id)
	{
		var self = this;
		replyPost (self.fastReplyWords[type][4]);
		function replyPost(content)
		{
			makeFormValue(
			{
				b_anonymous:	(islogging() ? '0' : '1'),
				c_id:			c_id,
				c_site:			self.base.site,
				c_sort:			self.base.data_commentinfo.sort_en,
				r_key:			r_key,
				r_type:			(type == 0 ? '3' : '4'),
				r_tips:			'',
				c_title:		'',
				c_content:		content,
				g_id:			self.base.comment_g_id
			});
			
			self.postData(Comment.Configure.postUrl,true);
		}
	},
	onError: function(msg)
	{
		alert(msg);
	},
	onSucc: function()
	{
		var self = this;
		setTimeout(reload, 300);
		function reload()
		{
			self.base.reload();
			if(self.base.jumptag&&self.base.name != 'ReplyPK'){
				window.location.replace('#load');
				self.base.jumptag=false;
			}
			else
				window.location.replace('#reload');
		}
	},
	onAudit: function()
	{
		if ($('imgVerify'))
		{
			$('imgVerify').src = "http://ptlogin2.qq.com/getimage?aid=5001501&" + Math.random();
		}
		if ($('verifycode'))
		{
			$('verifycode').value = '';
		}
	},
	clearBottomInput: function()
	{
		$A($(
			'b_c_title',
			'b_c_content'
		)).each(function(elem)
		{
			if (elem)
			{
				elem.value = '';
			}
		});
	},
	logout: function()
	{
		var url = Comment.Configure.loginIframeUrl;
		if ($('l_login_frame'))
		{
			$('l_login_frame').src = Comment.Configure.logoutUrl + '?url=' + url + '?l_login_frame';
		}
		if ($('b_login_frame'))
		{
			$('b_login_frame').src = Comment.Configure.logoutUrl + '?url=' + url + '?b_login_frame';
		}
	},
	saveTempComment: function(){
		getFormValue('c_site');
		var site = this.r_type;
		getFormValue('c_id');
		var id = this.r_type;
		getFormValue('c_title');
		var title = this.r_type.replaceTags();
		getFormValue('c_content');
		var a = this.r_type.replaceTags().split('\n');
		var content = '';
		for(var i=0; i<a.length; ++i) content += '<p>' + a[i] + '</p>';
		getFormValue('r_key');
		var reply_key = this.r_type;
		getFormValue('r_type');
		var reply_type = this.r_type;
		getFormValue('b_anonymous');
		var anonymous = this.r_type;
		if(anonymous!='1') anonymous='';
		getFormValue('r_nick');
		var user_nick=this.r_type;
		cmt_cf.setCookie('comment_site', site, Comment.Configure.post_save_time);
		cmt_cf.setCookie('comment_id', id, Comment.Configure.post_save_time);
		cmt_cf.setCookie('comment_title', title, Comment.Configure.post_save_time);
		cmt_cf.setCookie('comment_content', content, Comment.Configure.post_save_time);
		cmt_cf.setCookie('comment_time', wfTime(new Date().getTime()/1000, true), Comment.Configure.post_save_time);
		cmt_cf.setCookie('comment_rkey', reply_key, Comment.Configure.post_save_time);
		cmt_cf.setCookie('comment_rtype', reply_type, Comment.Configure.post_save_time);
		cmt_cf.setCookie('comment_anonymous', anonymous, Comment.Configure.post_save_time);
		cmt_cf.setCookie('user_nick',user_nick,Comment.Configure.post_save_time);
        cmt_cf.setCookie('comment',this.base.site+this.base.Id+content);
	},
	callback: function(url)
	{
		hideLoading();
		$('post_async').src = 'about:blank';
		
		var code = url.substr(url.indexOf('code=') + 5);
		if (code == '-')
		{
			code = -1;
		}
		code = code / 1;
		getFormValue('r_type');
		if (code == -1 && Comment.Post.r_type >= 3)
		{
			code = 0;
		}
		var errMsg = '';
		switch (code)
		{
		case -1:
			errMsg = '提交成功，感谢您的参与！';
			this.saveTempComment();
			this.onAudit();
			this.onSucc();
			this.closePostLayer();
			this.clearBottomInput();
			sendInfo('comment', code);
			break;
		case 0:
			errMsg = '提交成功，感谢您的参与！';
			this.saveTempComment();
			this.onSucc();
			this.closePostLayer();
			this.clearBottomInput();
			sendInfo('comment', code);
			break;
		case 1:
			errMsg = '很抱歉，您填写的内容不完整，请重新输入您的内容。';
			break;
		case 2:
			errMsg = '很抱歉，您尚未登录或登录已经过期，请先登录。';
			this.logout();
			break;
		case 3:
			errMsg = '提交成功，感谢您的参与！';
			this.saveTempComment();
			this.onAudit();
			this.onSucc();
			this.closePostLayer();
			this.clearBottomInput();
			sendInfo('comment', code);
			break;
		case 4:
			errMsg = '您的IP地址已暂时被屏蔽。';
			break;
		case 5:
			errMsg = '您的QQ号已暂时禁止在本评论系统发言。';
			break;
		case 6:
			errMsg = '很抱歉，您的QQ号码和密码不匹配。';
			break;
		case 7:
			errMsg = '很抱歉，系统繁忙，请稍候再试。';
			break;
		case 8:
			errMsg = '很抱歉，您发表的频率太快，请稍后再试。';
			break;
		case 9:
			errMsg = '很抱歉，您的验证码输入错误。';
			break;
		case 10:
			this.closePostLayer();
			this.clearBottomInput();
			break;
		case 100:
			errMsg = '系统升级中,请稍后再试！';
			//this.saveTempComment();
			break;
		}
		if (errMsg != '')
		{
			this.onError(errMsg);
		}
	},
	openLayer: function(){
		$('sLayer').style.height = document.documentElement.scrollHeight+'px';
		$('sLayer').oncontextmenu = function(){return false};
		$('sLayer').className = 'dis';
	},
	closeLayer: function(){
		if (!$('sLayer'))
		{
			return;
		}
		$('sLayer').oncontextmenu = function(){return true};
		$('sLayer').className = 'undis';
	},
	openPostLayer: function()
	{
		var self = this;
		$('sPost').style.top  = self.base.name == 'iNormal'?((parent.document.documentElement.scrollTop - 150) < 0 ? 0 : (parent.document.documentElement.scrollTop - 150)):(ClsScreen.getBodyTop() + 100);
		$('sPost').style.left = self.base.name == 'iNormal'?(document.documentElement.scrollLeft + (document.documentElement.scrollWidth - 475)/2) : (ClsScreen.getBodyWidth() - 475)/2 + "px";
		$('sLayer').style.height = document.documentElement.scrollHeight+'px';
		$('sLayer').oncontextmenu = function(){return false};
		$('sLayer').className = 'dis';
		$('sPost').className= 'dis';
		this.auto = setInterval(setAuto, 200);
		function setAuto()
		{
			$('sPost').style.top = self.base.name == 'iNormal'?((parent.document.documentElement.scrollTop - 150) < 0 ? 0 : (parent.document.documentElement.scrollTop - 150)):(ClsScreen.getBodyTop() + 100);
		}
	},
	closePostLayer: function()
	{
		if (!$('sLayer'))
		{
			return;
		}
		$('sLayer').oncontextmenu = function(){return true};
		$('sLayer').className = 'undis';
		$('sPost').className = 'undis';
		showlogging();
		clearInterval(this.auto);
		this.bindBottomPostTypeEvent();
		this.clearAsyncForm();
		this.clearValue();
		Debug.log('clearAsyncForm');
	},
	beforeOpenPost: function(type, r_key, c_id, content)
	{
	//	sPost_showlogging();
	     if(islogging())
	     {
	      	if($('sPost_to_login2'))
		      	hideElement('sPost_to_login2');
	    	if($('sPost_nick_div'))
		       hideElement('sPost_nick_div');
       	 }
	     else
	     {
		    if($('sPost_to_login2'))
		    	showElement('sPost_to_login2');
		    if($('sPost_nick_div'))
		    {
		        if($('sPost_user_nick'))
		        {
		         	var user_nick=cmt_cf.getCookie('user_nick');
					$('sPost_user_nick').value=user_nick||Comment.Configure.default_user_nick;
				   
		         }			
		      //  showElement('sPost_nick_div');
			     hideElement('sPost_nick_div');
		    }
	     }
		 if($('sPost_user_nick'))
		 {
			 if($('sPost_user_nick').value==Comment.Configure.default_user_nick)
			 {
				 $('sPost_user_nick').style.color='#969493';
			 }
			 else
			 {
				 $('sPost_user_nick').style.color='black';
			 }
			 
		 }
		 this.bindTitleEvent();
		 if($('l_c_title'))
		 {
		//	 if($('l_c_title').value!=Comment.Configure.reply_default_title)
		//	 {		 
				 $('l_c_title').style.color='#969493';
		//	 }
	     }		
	/*	 if($('l_c_content'))
		 {
			 var content=$('l_c_content').value.trim();
			 if(!content)
			 {
				 content=Comment.Configure.reply_default_content;
				 $('l_c_content').value=content;
			 }
			 if(content==Comment.Configure.reply_default_content)
				 $('l_c_content').style.color='#969493';
			 else
				 $('l_c_content').style.color='black'; 
		 }*/
		 
	
		$('post_article').innerHTML = this.base.comment_title.left(20);
		if (islogging())
		{
			this.setPostTypeSelector('login_select');
		}
		else
		{
			this.setPostTypeSelector('anonymous_select');
		}
		switch (type)
		{
		case 0:
			hideElement('debate_id', 'reply_type', 'r_quote');
			makeFormValue(
			{
				c_id:			c_id
			});
			break;
		case 1:
			//this.setjumptag();
			hideElement('debate_id', 'reply_type');
			$('post_quote').innerHTML = (content).stripTags();
			showElement('r_quote');
			this.setReplyType('middle');
			makeFormValue(
			{
				r_key:			r_key,
				r_type:			'2',
				c_id:			c_id
			});
			break;
		case 2:
			hideElement('reply_type', 'r_quote');
			showElement('debate_id');
			break;
		}
		this.openPostLayer();
	},
	setjumptag: function(){
		var self =this;
		self.base.jumptag=true;
	},
	beforeOpenPostEx: function(obj)
	{
		this.bindTitleEvent();
		if (obj.ref_title)
		{
			$('post_article').innerHTML = obj.ref_title.left(20);
		}
		if (islogging())
		{
			this.setPostTypeSelector('login_select');
		}
		else
		{
			this.setPostTypeSelector('anonymous_select');
		}
		
		 if($('sPost_user_nick'))
		 {
			 if($('sPost_user_nick').value!=Comment.Configure.default_user_nick)
			 {
				 $('sPost_user_nick').style.color='black';
			 }
		 }
		 if($('l_c_title'))
		 {
			 if($('l_c_title').value!=Comment.Configure.reply_default_title)
			 {
				 $('l_c_title').style.color='black';
			 }
	     }
		
		hideElement('debate_id', 'reply_type');
		if (obj.ref_content)
		{
			$('post_quote').innerHTML = obj.ref_content.stripTags();
			showElement('r_quote');
		}
		else
		{
			hideElement('r_quote');
		}
		makeFormValue(obj);
		this.openPostLayer();
	},
	bindPostBtnEx: function()
	{
		if (!$('l_post_btn'))
		{
			return;
		}
		var self = this;
		$('l_post_btn').onclick = function()
		{
/*			if (!islogging() && !$('l_b_anonymous').checked)
			{
				alert('很抱歉，您尚未登录，请先登录');
				return;
			}*/
			$('sPost_user_nick').value=$('sPost_user_nick').value.trim();
			if (!islogging())//&& (!$('sPost_user_nick').value || $('sPost_user_nick').value==Comment.Configure.default_user_nick)
			{
				alert('请先登录后再发贴');
				//alert('请先输入昵称或登录后再发贴');
				//$('sPost_user_nick').focus();
				$('l_login_frame').src = 'i_login.htm?l_login_frame&&true';
				showElement('l_login_post');
				if($('sPost_to_login2'))
		            hideElement('sPost_to_login2');
				return true;
			}
			else if ($('sPost_user_nick').value.realLength() > 12)
			{
				alert('昵称不能超过12个字符');
				$('sPost_user_nick').focus();
				return;
			}
			
			var c_title = $('l_c_title').value.trim();
			if ($('l_c_title').value.length > 32)
			{
				alert('很抱歉，标题不得超过32个字符');
				$('l_c_title').focus();
				return;
			}
			var c_content = $('l_c_content').value.trim();
			if (c_content == '')//||c_content == Comment.Configure.reply_default_content
			{
				alert('很抱歉，请填写评论内容');
				$('l_c_content').focus();
				return;
			}
			else if (c_content.realLength() > 2000)
			{
				alert('很抱歉，评论内容不能超过2,000个字符（1,000个汉字）');
				$('l_c_content').focus();
				return;
			}
			
			makeFormValue(
			{
				b_anonymous:	islogging()? '0':'1',
				c_title:		($('l_c_title').value == Comment.Configure.reply_default_title ? '' : $('l_c_title').value),
				c_content:		$('l_c_content').value,
				r_nick:         $('user_nick').value == Comment.Configure.default_user_nick ? '' : $('user_nick').value
			});
			var commentck = cmt_cf.getCookie('comment');
			if (commentck&&commentck== self.base.site+self.base.Id+$('l_c_title').value.trim()) {
					alert('谢谢您的回复，内容重复，请重新输入！');
					return;
			}
			Comment.Post.postData(Comment.Configure.userPostUrl);
			cmt_cf.setCookie('comment',self.base.site+self.base.Id+$('l_c_title').value.trim());
			
			return true;
		};
	}
}

var NDEBUG = true;
var Debug = {
	init: function()
	{
		if (NDEBUG == true)
		{
			return;
		}
		var divDebug = $C('div');
		this.divDebug = divDebug;
		with (divDebug.style)
		{
			top = '10px';
			left = '10px';
			width = '300px';
			height = '200px';
			overflow = 'scroll';
			verticalAlign = 'top';
			position = 'absolute';
			backgroundColor = '#fff';
			padding = '5px';
			lineHeight = '110%';
		}
		document.getElementsByTagName('body')[0].appendChild(divDebug);
		this.auto = setInterval(setAuto, 200);
		function setAuto()
		{
			divDebug.style.top = document.documentElement.scrollTop + 10;
		}
		Debug.log('<b>Debug</b>');
		divDebug.ondblclick = function()
		{
			NDEBUG = true;
			Element.remove(divDebug);
		}
		this.height = 0;
	},
	log: function(str)
	{
		if (NDEBUG == true)
		{
			return;
		}
		var now = new Date();
		this.divDebug.innerHTML += '[' + now.getHours() + ':' 
			+ now.getMinutes() + ':'
			+ now.getSeconds() + '] ' + str + '<br>';
		this.divDebug.scrollTop = 10000000;
	}
}

var divLoading = null;
function showLoading(action)
{
	if (!divLoading)
	{
		divLoading = $C('div');
		divLoading.className = 'loading';
		document.getElementsByTagName('body')[0].appendChild(divLoading);
	}
	if (!action)
	{
		divLoading.innerHTML = '正在读取...';
	}
	else
	{
		divLoading.innerHTML = action;
	}
	divLoading.style.top = document.documentElement.scrollTop;
	divLoading.style.left = '0px';
	divLoading.style.display = 'block';
}
function hideLoading()
{
	if (!divLoading)
	{
		return;
	}
	divLoading.style.display = 'none';
}
function showElement()
{
	for (var i = 0; i < arguments.length; i++)
	{
		var element = arguments[i];
		if ($(element))
		{
			$(element).style.display = 'block';
		}
	}
}
function hideElement()
{
	for (var i = 0; i < arguments.length; i++)
	{
		var element = arguments[i];
		if ($(element))
		{
			$(element).style.display = 'none';
		}
	}
}
function getFormValue(name)
{
	var els = $('post_form').getElementsByTagName('input');
	for(var i=0; i<els.length; ++i){
		var elem = els[i];
		if (elem.name == name){
			Comment.Post.r_type = elem.value;
			return elem.value;
		}
	}
	Comment.Post.r_type = '';
	return '';
}
function makeFormValue(name2Value)
{
	Debug.log('makeFormValue start');
	$A($('post_form').getElementsByTagName('input')).each(function(elem)
	{
		if (name2Value[elem.name] != null)
		{
			elem.value = name2Value[elem.name];
		}
		Debug.log(elem.name + ': ' + elem.value);
	});
	Debug.log('makeFormValue end');
}

var sUrl = window.location.href.toString();
var sDomain = sUrl.substring(7, sUrl.indexOf('/', 7));
var sComment = sUrl.substring(7, sUrl.indexOf('.', 7));
var sPath = sUrl.substring(sUrl.indexOf('/', 7));
var sParam = '';
if (window.location.search.substr(0, 1) == '?') {
	if (sUrl.indexOf('#') == -1)
		sParam = window.location.search.substr(1);
	else if (sUrl.indexOf('?') < sUrl.indexOf('#'))
		sParam = window.location.search.substr(1);
	else
		sParam = window.location.hash.substr(1);
} else if (window.location.hash.substr(0, 1) == '#') {
	sParam = window.location.hash.substr(1);
}
var objParam = sParam.toQueryParams();
document.domain = 'qq.com';


function addJs(src){
	var el = document.createElement("SCRIPT");
	document.getElementsByTagName("HEAD")[0].appendChild(el);
	el.src = src;
}
function _cbCid(id){
	var url = 'http://comment5.qq.com/comment.htm?site='+objParam.site+'&id='+id;
	window.location.href = url;
}
function _cbGid(id){
	var url = 'http://comment5.qq.com/comment_group.htm?site='+objParam.site+'&id='+id;
	window.location.href = url;
}
function _cbDid(a_id, o_id, n_id){
	var url = 'http://comment5.qq.com/comment_debate.htm?site='+objParam.site
		+'&a_id='+a_id+'&o_id='+o_id+'&n_id='+n_id;;
	window.location.href = url;
}
/*if(objParam.site == "ent" && sPath.indexOf("i_comment")==-1)
{
	window.location.href = "http://"+sDomain +"/2009"+sPath;
}*/
if((window.location.pathname=='/axel/comment_debate.htm'||window.location.pathname=='/comment_debate.htm')
	&& objParam.id && objParam.site){
	addJs('http://comment5.qq.com/php/gdid.php?site='+objParam.site+'&d_id='+objParam.id);
}else if(sDomain.indexOf('comment5')!=-1 || sDomain=='sum.comment.qq.com'){
	var p = window.location.pathname;
	var idx = p.indexOf('/axel');
	if(idx!=-1) window.location.href = sUrl.replace('/axel','');
}else{
	if(objParam.id && objParam.id>3000000){
		var lastDomain = 'comment5';
		if(sUrl.replace(sComment,lastDomain)!=sUrl){
			var newUrl = sUrl.replace(sComment,lastDomain);
			var p = window.location.pathname;
			var idx = p.indexOf('/axel');
			if(idx!=-1) newUrl = newUrl.replace('/axel','');
			window.location.href = newUrl;
		}
	}else if(window.location.pathname=='/axel/comment.htm'||window.location.pathname=='/comment.htm'){
		if(objParam.id && objParam.site){
			addJs('http://comment5.qq.com/php/gcid.php?site='+objParam.site+'&c_id='+objParam.id);
		}
	}else if(window.location.pathname=='/axel/comment_group.htm'||window.location.pathname=='/comment_group.htm'){
		if(objParam.id && objParam.site){
			addJs('http://comment5.qq.com/php/ggid.php?site='+objParam.site+'&g_id='+objParam.id);
		}
	}else if(window.location.pathname=='/axel/comment_debate.htm'||window.location.pathname=='/comment_debate.htm'){
		if(objParam.id && objParam.site){
			addJs('http://comment5.qq.com/php/gdid.php?site='+objParam.site+'&d_id='+objParam.id);
		}
	}
}
var cmt_domains={'2008':1,'512':1,'astro':1,'auto':1,'baby':1,'bb':1,'book':1,'cd':1,'comic':1,'cq':1,'digi':1,'download':1,'edu':1,'ent':1,'face':1,'fashion':1,'finance':1,'flash':1,'fm':1,'gamezone':1,'gongyi':1,'hb':1,'house':1,'joke':1,'kid':1,'lady':1,'lequipe':1,'luxury':1,'mag':1,'news':1,'sports':1,'stock':1,'tech':1,'view':1,'xian':1};
var initWith = {
	'comment':		'Normal',
	'i_comment':		'MiniNormal',
	'i_comment2':		'MiniNormal1',
	'comment_group':	'Group',
	'comment_debate':	'Debate',
	'comment_debate_ifr':	'DebateIfr',
	'comment_reply_pk':	'ReplyPK',
	'reply':		'Reply',
	'comment_user':		'UserReply',
	'comment_user2':	'UserReply2',
	'list':			'List',
	'list2':		'ListMix',
	'i_minicomment':	'iNormal',
	'i_comment_stock': 	'MiniNormal',
	'comment_ojs08':		'Normal',
	'comment_group_ojs08':		'Group'
};

Comment.Start = function(){
	Debug.init();
	for (var url in initWith)
	{
		if (sUrl.indexOf('/' + url + '.htm') != -1)
		{
			if (url == 'list')
			{
				Comment.Page[initWith[url]].load(sUrl);
			}
			else
			{
				Comment.Page[initWith[url]].load(sParam.toQueryParams());
			}
		}
	}

	document.body.onclick = function()
	{
		if ($('fastLayer'))
		{
			$('fastLayer').style.display = 'none';
		}
	}
}

var cmt_cf;
if(sUrl.indexOf('/i_minicomment.htm') != -1){
	window.onload = function(){
		Comment.Start();
	}
}else{
	onDomReady(function(){
		cmt_cf = new Comment.CookieFrame();
		cmt_cf.init(null, Comment.Start);
		//Comment.Start();
	});
}


Comment.HotList = 
{
	siteObject:	{
		'news':	'新闻',
		'ent':	'娱乐',
		'finance':	'财经',
		'tech':	'科技',
		'auto':	'汽车',
		'gamezone':	'游戏',
		'edu':	'教育',
		'book':	'读书',
		'lady':	'女性',
		'astro':	'星座',
		'sports':	'体育',
		'comic':	'动漫',
		'luxury':	'时尚',
		'cq':	'重庆',
		'xian':	'西安',
		'view':	'说吧',
		'kid':	'儿童',
		'cd':'大成网'
	},
	getRandomSite: function()
	{
		if (!this.siteArray)
		{
			this.siteArray = new Array();
			for (var site_en in this.siteObject)
			{
				this.siteArray.push(site_en);
			}
		}
		var site_sum = this.siteArray.length;
		var rnd_site = Math.floor(Math.random() * site_sum);
		return this.siteArray[rnd_site];
	},
	bindTopHotList: function(container, site)
	{
		var topSiteSum = 6;
		if (site == 'kid')
		{
			topSiteSum = 1;
		}
		var topSite = new Object();
		if (site != '')
		{
			if (this.siteObject[site])
			{
				topSite[site] = this.siteObject[site];
				topSiteSum--;
			}
		}
		
		while (topSiteSum > 0)
		{
			var rnd_site = this.getRandomSite();
			if (topSite[rnd_site])
			{
				continue;
			}
			topSite[rnd_site] = this.siteObject[rnd_site];
			topSiteSum--;
		}
		
		var hot_index = 0;
		var hot_header = '';
		var hot_body = '';
		for (var site_en in topSite)
		{
			hot_header += '<p' + (hot_index == 0 ? ' class="c"' : '') + ' onclick="getMe(this)">' + topSite[site_en] + '</p>';
			hot_body += '<dd' + (hot_index != 0 ? ' class="undis"' : '') + ' id="Hot_Top_' + site_en + '"></dd>';
			hot_index++;
		}
		var hot_html = '<dl><dt>' + hot_header + '</dt>' + hot_body + '</dl>';
		$(container).innerHTML = hot_html;
		
		for (var site_en in topSite)
		{
			this.bindTopSite('Hot_Top_' + site_en, '/c/async_html/' + site_en + '_top.htm');
		}
	},
	bindRightHotList: function(container, site)
	{
		var topSiteSum = 3;
		if (site == 'kid')
		{
			topSiteSum = 1;
		}
		var topSite = new Object();
		if (site != '')
		{
			if (this.siteObject[site])
			{
				topSite[site] = this.siteObject[site];
				topSiteSum--;
			}
		}
		
		while (topSiteSum > 0)
		{
			var rnd_site = this.getRandomSite();
			if (topSite[rnd_site])
			{
				continue;
			}
			topSite[rnd_site] = this.siteObject[rnd_site];
			topSiteSum--;
		}
		
		var hot_body = '';
		for (var site_en in topSite)
		{
			hot_body += '<dl><dt>' + topSite[site_en] + '热评</dt><div id="Hot_Right_' + site_en + '"></div></dl>';
		}
		$(container).innerHTML = hot_body;
		
		for (var site_en in topSite)
		{
			this.bindTopSite('Hot_Right_' + site_en, '/c/async_html/' + site_en + '_right.htm');
		}
	},
	bindTopSite: function(container, url, pre)
	{
		if (pre == undefined)
			pre = '';
		function onSucc(response)
		{
			$(container).innerHTML = pre + response.responseText;
		}
		function onError()
		{
			$(container).innerHTML = pre;
		}
		new Ajax.Request(
			 url,
			 {
				 method: 		'get',
				 onSuccess: 	onSucc,
				 onFailure:		onError
			 }
		);
	}
}

var ClsScreen = {
	getPageWidth: function()
	{
		return document.documentElement.scrollWidth || document.body.scrollWidth || 0;
	},

	getPageHeight: function()
	{
		return document.documentElement.scrollHeight || document.body.scrollHeight || 0;
	},

	getBodyWidth: function()
	{
		return document.documentElement.clientWidth || document.body.clientWidth || 0;
	},

	getBodyHeight: function()
	{
		return document.documentElement.clientHeight || document.body.clientHeight || 0;
	},

	getBodyLeft: function()
	{
		return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
	},

	getBodyTop: function()
	{
		return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
	},

	getBody: function()
	{
		return {
			width	: this.getBodyWidth(),
			height	: this.getBodyHeight(),
			left	: this.getBodyLeft(),
			top	: this.getBodyTop()
		};
	},

	getScreenWidth: function()
	{
		return window.screen.width;
	},

	getScreenHeight: function()
	{
		return window.screen.height;
	}
};


function E(obj){return document.getElementById(""+obj+"")}
function setSize(v){
	E('Content').className="f"+v+"";
	if(v==12)
		E('fontCtrl').innerHTML="<a href='javascript:setSize(14)' class='b1'>大字</a>/小字";
	if(v==14)
		E('fontCtrl').innerHTML="大字/<a href='javascript:setSize(12)' class='b1'>小字</a>";
}

function getSite(o){
        var obj = o;
        var objS = obj.offsetLeft;
        while(obj!=obj.offsetParent && obj.offsetParent){
                obj=obj.offsetParent;
                if(obj.tagName=="span")objS += obj.offsetLeft;
        }
        return objS;
}

function getMe(obj){
	var theTit=E('comment_info').getElementsByTagName('p');
	var theDD=E('comment_info').getElementsByTagName('dd');
	var num=theTit.length;
	for(var i=0;i<num;i++){		
		theTit[i].className='';
		obj.className='c';
		theDD[i].className='undis';
		if(theTit[i].className=='c')
			theDD[i].className='dis';
		}
}

function picCtrl(obj)
{
	var tWidth = 401;
	var pWidth = 183;
	var All = tWidth + pWidth;
	var picWidth = obj.width; 
	var picHeight = obj.height; 
	if (picWidth / picHeight > 1.6)
	{
		obj.width = 174;
		obj.height = 150;
		return true;
	}
	else
	{
		obj.width = picWidth * 150 / picHeight;
		obj.height = 150;
		E('comment_pic').style.width = obj.width;
		E('comment_text').style.width= All - obj.width;
		return true;
	}
}

function showSiteNav(site)
{
	if (site == 'kid')
	{
		return;
	}
	document.write('<a href="http://www.qq.com" target="_blank" class="b0">腾讯首页</a> '
		+ '<a href="http://pinglun.qq.com" target="_blank" class="b0">评论首页</a> '
		+ '<a href="http://support.qq.com/portal/discuss_pdt/414_1.html" target="_blank" class="b0">用户反馈</a>');
}

function showLogo(site)
{
	if (site == 'kid')
	{
		document.write('<a href="http://kid.qq.com" target="_blank"><img src="http://img1.qq.com/pinglun/pics/7715/7715483.jpg" /></a>');
	}
	else
	{
		document.write('<a href="http://www.qq.com" target="_blank"><img src="http://img1.qq.com/pinglun/pics/7689/7689781.gif" /></a>');
	}
}
	
function wfTime(time, sec){
	var t = new Date(time * 1000);
	var vMonth = t.getMonth()+1;
	var vdate = t.getDate();
	var vHour = t.getHours();
	var vMin = t.getMinutes();
	var vSec = t.getSeconds();
	return t.getFullYear()+"-"
		+((vMonth<10 ? "0" + vMonth : vMonth) )+"-"
		+(vdate<10 ? "0" + vdate : vdate)+" "
		+(vHour<10 ? "0" + vHour : vHour)+":"
		+(vMin<10 ? "0" + vMin : vMin)
		+(sec?(":"+(vSec<10?"0"+vSec:vSec)):"");
}

function comptime(beginTime,endTime,tag){
	var showtime=beginTime;
	var beginTimes=beginTime.substring(0,10).split('-');	
	if(showtime.indexOf("-")<0){
		showtime=wfTime(beginTime);
		var secondNum = parseInt((endTime-beginTime*1000)/1000);	
	}
	else{
		beginTime=beginTimes[1]+'/'+beginTimes[2]+'/'+beginTimes[0]+' '+beginTime.substring(10,19);
		var secondNum = parseInt((endTime-Date.parse(beginTime))/1000);
	}
	if(secondNum>=0&&secondNum<60){
		return secondNum+'秒前';
	}
	else if (secondNum>=60&&secondNum<3600){
		var nTime=parseInt(secondNum/60);
		return nTime+'分钟前';
	}
	else if (secondNum>=3600&&secondNum<3600*24){
		var nTime=parseInt(secondNum/3600);
		return nTime+'小时前';
	}
	else{
		if (tag)
		{
			return showtime.substr(0,16);
		}
		return showtime;
	}
}

function StringBuffer() {
	this._strings_ = new Array;
}

StringBuffer.prototype.append = function(str) {
	this._strings_.push(str);
}

StringBuffer.prototype.toString = function() {
	return this._strings_.join("");
}

StringBuffer.prototype.reset= function() {
	this._strings_ = new Array;
}

function GetUserLevel(pt) {
	if (0<=pt&&pt<600)
	{
		return '等级一';
	}
	else if(600<=pt&&pt<1800)
	{
		return '等级二';
	}
	else if(1800<=pt&&pt<3600)
	{
		return '等级三';
	}
	else if(3600<=pt&&pt<6000)
	{
		return '等级四';
	}
	else if(6000<=pt&&pt<10800)
	{
		return '等级五';
	}
	else if(10800<pt)
	{
		return '等级六';
	}
	else 
		return '等级一';
}

function getOs()
{
	if(navigator.userAgent.indexOf("MSIE")>0)return 1;
	if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)return 2;
	if(isSafari=navigator.userAgent.indexOf("Safari")>0)return 3;  
	if(isCamino=navigator.userAgent.indexOf("Camino")>0)return 4;
	if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0)return 5;
	return 0;
}

function fixFF(login_frame)
{
	if(getOs() == 2)
	{
		if(islogging())$(login_frame).height = 20;
		else $(login_frame).height = 105;
		$(login_frame).setAttribute('style', '');
	}
}

function addFavorite(href, title)
{
	switch(getOs())
	{
		case 1:
			window.external.AddFavorite(href, title);
			break;
		case 2:
			window.sidebar.addPanel(title, href, '');
			break;
		default:
			break;
	}
}

function _replyBycid(baseinfo, replys_top, replys_normal){
	var rt = [];
	var rn = [];
	
	if(typeof baseinfo=='number' && baseinfo < 0) return -1;
	
	for(var i = 0; i < replys_top.length; ++i){
		rt.push({
			comment_id: baseinfo[0],
			uin: replys_top[i][1],
			nickname: replys_top[i][2],
			pub_time: wfTime(replys_top[i][3], true),
			pass_time: '',
			ip: replys_top[i][5]+'|'+replys_top[i][4],
			title: replys_top[i][6],
			content: replys_top[i][7],
			source: replys_top[i][9],
			reply_key: replys_top[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys_top[i][8],
			tips: '',
			cite_valid: 0,	// 首页置顶热帖不显示盖楼
			sums: replys_top[i][10]+'|'+replys_top[i][11]+'|'+replys_top[i][12]+'|'+(replys_top[i][13]+replys_top[i][14]+replys_top[i][15]),
			pksum: {
				agree: replys_top[i][10],
				disagree: replys_top[i][11],
				middle: replys_top[i][12],
				original: replys_top[i][13]+replys_top[i][14]+replys_top[i][15],
				agree_o: replys_top[i][13],
				disagree_o: replys_top[i][14]
			}
		});
	}
	for(var i = 0; i < replys_normal.length; ++i){
		rn.push({
			comment_id: baseinfo[0],
			uin: replys_normal[i][1],
			nickname: replys_normal[i][2],
			pub_time: wfTime(replys_normal[i][3], true),
			pass_time: '',
			ip: replys_normal[i][5]+'|'+replys_normal[i][4],
			title: replys_normal[i][6],
			content: replys_normal[i][7],
			source: replys_normal[i][9],
			reply_key: replys_normal[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys_normal[i][8],
			tips: '',
			cite_valid: replys_normal[i][16],
			sums: replys_normal[i][10]+'|'+replys_normal[i][11]+'|'+replys_normal[i][12]+'|'+(replys_normal[i][13]+replys_normal[i][14]+replys_normal[i][15]),
			pksum: {
				agree: replys_normal[i][10],
				disagree: replys_normal[i][11],
				middle: replys_normal[i][12],
				original: replys_normal[i][13]+replys_normal[i][14]+replys_normal[i][15],
				agree_o: replys_normal[i][13],
				disagree_o: replys_normal[i][14]
			}
		});
	}
	return {
		commentinfo: {
			site_cn: baseinfo[2],
			sort_en: baseinfo[3],
			sort_cn: baseinfo[4],
			source: '',
			source_url: '',
			title: baseinfo[10],
			url: baseinfo[11],
			intro: baseinfo[14],
			intro_img: baseinfo[15],
			group_id: baseinfo[9],
			intro_show: baseinfo[16],
			create_time: '',
			debate_id: 0,
			is_debate: baseinfo[17],
			debate_intro: baseinfo[18],
			a_id: baseinfo[19],
			o_id: baseinfo[20],
			n_id: baseinfo[21]
		},
		sum: {
			origin_count: baseinfo[7],
			total_count: baseinfo[6],
			top_count: baseinfo[8]
		},
		replys_top: rt,
		replys_normal: rn,
		replys: rt.concat(rn)
	};
}

function _uinGrade(){
	var res = arguments;
	return {
		uin: res[0],
		grade: res[1],
		point: res[2],
		total_count: res[3],
		top_count: res[4]
	}
}

function _originReplyBycid(baseinfo, replys){
	var rs = [];
	
	if(baseinfo == -1) return [];
	
	for(var i = 0; i < replys.length; ++i){
		rs.push({
			comment_id: baseinfo[0],
			uin: replys[i][1],
			nickname: replys[i][2],
			pub_time: wfTime(replys[i][3], true),
			pass_time: '',
			ip: replys[i][5]+'|'+replys[i][4],
			title: replys[i][6],
			content: replys[i][7],
			source: replys[i][9],
			reply_key: replys[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys[i][8],
			tips: '',
			cite_valid: replys[i][16],
			sums: replys[i][10]+'|'+replys[i][11]+'|'+replys[i][12]+'|'+(replys[i][13]+replys[i][14]+replys[i][15]),
			pksum: {
				agree: replys[i][10],
				disagree: replys[i][11],
				middle: replys[i][12],
				original: replys[i][13]+replys[i][14]+replys[i][15],
				agree_o: replys[i][13],
				disagree_o: replys[i][14]
			}
		});
	}
	return {
		replys: rs
	};
}

function _topReplyBycid(baseinfo, replys){
	return _originReplyBycid(baseinfo, replys);
}

function _reply(){
	return {
		comment_id: arguments[1],
		uin: arguments[4],
		nickname: arguments[5],
		pub_time: wfTime(arguments[6], true),
		pass_time: '',
		ip: arguments[8]+'|'+arguments[7],
		title: arguments[9],
		content: arguments[10],
		source: arguments[12],
		reply_key: arguments[0],
		is_del: 0,
		reply_kind: '',
		reply_type: arguments[11],
		tips: '',
		cite_valid: arguments[19],
		sums: arguments[13]+'|'+arguments[14]+'|'+arguments[15]+'|'+(arguments[16]+arguments[17]+arguments[18]),
		pksum: {
			agree: arguments[13],
			disagree: arguments[14],
			middle: arguments[15],
			original: arguments[16]+arguments[17]+arguments[18],
			agree_o: arguments[16],
			disagree_o: arguments[17]
		}
	};
}

function _grReplyByrid(){
	var rs = [];
	
	var replys = arguments;
	if(replys[0] == -1) return [];
	if(replys[0] == 0) return [];
	
	for(var i = 0; i < replys.length; ++i){
		rs.push({
			uin: replys[i][4],
			nickname: replys[i][5],
			pub_time: wfTime(replys[i][6], true),
			pass_time: '',
			ip: replys[i][8]+'|'+replys[i][7],
			title: replys[i][9],
			content: replys[i][10],
			source: replys[i][12],
			reply_key: replys[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys[i][11],
			tips: '',
			cite_valid: replys[i][19],
			sums: replys[i][13]+'|'+replys[i][14]+'|'+replys[i][15]+'|'+(replys[i][16]+replys[i][17]+replys[i][18]),
			pksum: {
				agree: replys[i][13],
				disagree: replys[i][14],
				middle: replys[i][15],
				original: replys[i][16]+replys[i][17]+replys[i][18],
				agree_o: replys[i][16],
				disagree_o: replys[i][17]
			}
		});
	}
	return rs;
}

function _replyBygid(baseinfo, replys_top, replys_normal){
	var rt = [];
	var rn = [];
	
	if(typeof baseinfo=='number' && baseinfo < 0) return -1;
	
	for(var i = 0; i < replys_top.length; ++i){
		rt.push({
			comment_id: replys_top[i][1],
			comment_title: replys_top[i][2],
			uin: replys_top[i][4],
			nickname: replys_top[i][5],
			pub_time: wfTime(replys_top[i][6], true),
			pass_time: '',
			ip: replys_top[i][8]+'|'+replys_top[i][7],
			title: replys_top[i][9],
			content: replys_top[i][10],
			source: replys_top[i][12],
			reply_key: replys_top[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys_top[i][11],
			tips: '',
			cite_valid: 0,	// 首页置顶热帖不显示盖楼
			sums: replys_top[i][13]+'|'+replys_top[i][14]+'|'+replys_top[i][15]+'|'+(replys_top[i][16]+replys_top[i][17]+replys_top[i][18]),
			pksum: {
				agree: replys_top[i][13],
				disagree: replys_top[i][14],
				middle: replys_top[i][15],
				original: replys_top[i][16]+replys_top[i][17]+replys_top[i][18],
				agree_o: replys_top[i][16],
				disagree_o: replys_top[i][17]
			}
		});
	}
	for(var i = 0; i < replys_normal.length; ++i){
		rn.push({
			comment_id: replys_normal[i][1],
			comment_title: replys_normal[i][2],
			uin: replys_normal[i][4],
			nickname: replys_normal[i][5],
			pub_time: wfTime(replys_normal[i][6], true),
			pass_time: '',
			ip: replys_normal[i][8]+'|'+replys_normal[i][7],
			title: replys_normal[i][9],
			content: replys_normal[i][10],
			source: replys_normal[i][12],
			reply_key: replys_normal[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys_normal[i][11],
			tips: '',
			cite_valid: replys_normal[i][19],
			sums: replys_normal[i][13]+'|'+replys_normal[i][14]+'|'+replys_normal[i][15]+'|'+(replys_normal[i][16]+replys_normal[i][17]+replys_normal[i][18]),
			pksum: {
				agree: replys_normal[i][13],
				disagree: replys_normal[i][14],
				middle: replys_normal[i][15],
				original: replys_normal[i][16]+replys_normal[i][17]+replys_normal[i][18],
				agree_o: replys_normal[i][16],
				disagree_o: replys_normal[i][17]
			}
		});
	}
	return {
		groupinfo: {
			site_cn: baseinfo[2],
			sort_en: baseinfo[3],
			sort_cn: baseinfo[4],
			source: '',
			source_url: '',
			title: baseinfo[10],
			url: baseinfo[11],
			intro: baseinfo[14],
			intro_img: baseinfo[15],
			group_id: baseinfo[9],
			intro_show: baseinfo[16],
			create_time: '',
			debate_id: 0,
			is_debate: baseinfo[17],
			debate_intro: baseinfo[18],
			a_id: baseinfo[19],
			o_id: baseinfo[20],
			n_id: baseinfo[21]
		},
		sum: {
			origin_count: baseinfo[7],
			total_count: baseinfo[6],
			top_count: baseinfo[8]
		},
		replys_top: rt,
		replys_normal: rn,
		replys: rt.concat(rn)
	};
}

function _originReplyBygid(baseinfo, replys){
	var rs = [];
	
	if(baseinfo == -1) return [];
	
	for(var i = 0; i < replys.length; ++i){
		rs.push({
			comment_id: replys[i][1],
			comment_title: replys[i][2],
			uin: replys[i][4],
			nickname: replys[i][5],
			pub_time: wfTime(replys[i][6], true),
			pass_time: '',
			ip: replys[i][8]+'|'+replys[i][7],
			title: replys[i][9],
			content: replys[i][10],
			source: replys[i][12],
			reply_key: replys[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys[i][11],
			tips: '',
			cite_valid: replys[i][19],
			sums: replys[i][13]+'|'+replys[i][14]+'|'+replys[i][15]+'|'+(replys[i][16]+replys[i][17]+replys[i][18]),
			pksum: {
				agree: replys[i][13],
				disagree: replys[i][14],
				middle: replys[i][15],
				original: replys[i][16]+replys[i][17]+replys[i][18],
				agree_o: replys[i][16],
				disagree_o: replys[i][17]
			}
		});
	}
	return {
		replys: rs
	};
}

function _topReplyBygid(baseinfo, replys){
	return _originReplyBygid(baseinfo, replys);
}

function _aonPkzoneReplyByrid(replys){
	if(typeof replys == 'undefined') return [];
	var rs = [];
	
	if(replys == -1) return [];
	
	for(var i = 0; i < replys.length; ++i){
		rs.push({
			uin: replys[i][1],
			nickname: replys[i][2],
			pub_time: wfTime(replys[i][3], true),
			pass_time: '',
			ip: replys[i][5]+'|'+replys[i][4],
			title: replys[i][6],
			content: replys[i][7],
			source: replys[i][9],
			reply_key: replys[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys[i][8],
			tips: '',
			sums: replys[i][10]+'|'+replys[i][11]+'|'+replys[i][12]+'|'+(replys[i][13]+replys[i][14]+replys[i][15])
		});
	}
	return rs;
}
function _aPkzoneReplyByrid(){
	return _aonPkzoneReplyByrid(arguments);
}
function _oPkzoneReplyByrid(){
	return _aonPkzoneReplyByrid(arguments);
}
function _nPkzoneReplyByrid(){
	return _aonPkzoneReplyByrid(arguments);
}
function _replyByuin(){
	var rs = [];
	
	var replys = arguments;
	if(replys[0] == -1) return [];
	
	for(var i = 0; i < replys.length; ++i){
		rs.push({
			comment_id: replys[i][1],
			news_title: replys[i][2],
			news_url: replys[i][3],
			site_en: replys[i][20],
			uin: replys[i][4],
			nickname: replys[i][5],
			pub_time: wfTime(replys[i][6], true),
			pass_time: '',
			ip: replys[i][8]+'|'+replys[i][7],
			title: replys[i][9],
			content: replys[i][10],
			source: replys[i][12],
			reply_key: replys[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys[i][11],
			tips: '',
			cite_valid: replys[i][19],
			sums: replys[i][13]+'|'+replys[i][14]+'|'+replys[i][15]+'|'+(replys[i][16]+replys[i][17]+replys[i][18]),
			pksum: {
				agree: replys[i][13],
				disagree: replys[i][14],
				middle: replys[i][15],
				original: replys[i][16]+replys[i][17]+replys[i][18],
				agree_o: replys[i][16],
				disagree_o: replys[i][17]
			}
		});
	}
	return rs;
}

function _citeReply(){
	var rs = [];
	
	var replys = arguments;
	if(replys[0] == -1) return [];
	if(replys[0] == 0) return [];
	
	for(var i = 0; i < replys.length; ++i){
		rs.push({
			comment_id: replys[i][1],
			news_title: replys[i][2],
			news_url: replys[i][3],
			uin: replys[i][4],
			nickname: replys[i][5],
			pub_time: wfTime(replys[i][6], true),
			pass_time: '',
			ip: replys[i][8]+'|'+replys[i][7],
			title: replys[i][9],
			content: replys[i][10],
			source: replys[i][12],
			reply_key: replys[i][0],
			is_del: 0,
			reply_kind: '',
			reply_type: replys[i][11],
			tips: '',
			sums: replys[i][13]+'|'+replys[i][14]+'|'+replys[i][15]+'|'+(replys[i][16]+replys[i][17]+replys[i][18]),
			pksum: {
				agree: replys[i][13],
				disagree: replys[i][14],
				middle: replys[i][15],
				original: replys[i][16]+replys[i][17]+replys[i][18],
				agree_o: replys[i][16],
				disagree_o: replys[i][17]
			}
		});
	}
	return rs;
}

function _cbCommnetInfo(){
	return {
		commentinfo: {
			site_cn: arguments[2],
			sort_en: arguments[3],
			sort_cn: arguments[4],
			source: '',
			source_url: '',
			title: arguments[10],
			url: arguments[11],
			intro: arguments[14],
			intro_img: arguments[15],
			group_id: arguments[9],
			intro_show: arguments[16],
			create_time: '',
			debate_id: 0,
			is_debate: arguments[17],
			debate_intro: arguments[18],
			a_id: arguments[19],
			o_id: arguments[20],
			n_id: arguments[21]
		},
		sum: {
			origin_count: arguments[7],
			total_count: arguments[6],
			top_count: arguments[8]
		}
	}
}

var UinNick = {};
function user_cb(uin, nick){
	UinNick['uin'] = uin;
	UinNick['nick'] = nick;
}

function jubao_onResize(width, height){
	login_wnd = document.getElementById("jubao_div");
	if(login_wnd){
		login_wnd.style.width = width + "px";
		login_wnd.style.height = height + "px";
		login_wnd.style.visibility = "hidden";
		login_wnd.style.visibility = "visible";
	}
}

function jubao_onClose(){
	document.getElementById("jubao_div").style.display = "none";

	Comment.Post.closeLayer();
	if (document.removeEventListener){
		window.removeEventListener("scroll", LL_moveHandler, false);
		window.removeEventListener("resize", LL_moveHandler, false);
	}else if (document.detachEvent){
		window.detachEvent('onscroll', LL_moveHandler);
		window.detachEvent('onresize', LL_moveHandler);
	}
}

var LL_moveHandler=null;
function OpenJubaoDiv(urlParam)
{
	if(!document.getElementById("jubao_div"))
	{
		var oDiv=document.createElement("div");
		oDiv.id="jubao_div";
		oDiv.style.height="483px";
		oDiv.style.width="633px";
		oDiv.style.border="0px";
		oDiv.style.padding="0px";
		oDiv.style.margin="0px";
		oDiv.style.position="absolute";
		oDiv.style.zIndex="999";
		oDiv.style.top="20%";
		oDiv.style.left="30%";
		
		//oDiv.style.visibility = "hidden";
		var oIFrame=document.createElement("iframe");
		oIFrame.id="jubao_frame";
		oIFrame.frameborder="0";
		oIFrame.scrolling="no";
		oIFrame.width="100%";
		oIFrame.height="100%";
		oIFrame.frameBorder ="0";
		oDiv.appendChild(oIFrame);
		document.body.appendChild(oDiv);
	}
	else
	{
		document.getElementById("jubao_div").style.display="block";
	}

	var url = "http://jubao.qq.com/cgi-bin/jubao?";
	if (urlParam != '')
		url += urlParam;
	document.getElementById("jubao_frame").src = url;

	if(!LL_moveHandler) LL_moveHandler=function(){
		Comment.Post.openLayer();
		var oDiv=document.getElementById("jubao_div");
		var min_clientHeight=Math.min(document.documentElement.clientHeight,document.body.clientHeight);
		var min_clientWidth=Math.min(document.documentElement.clientWidth,document.body.clientWidth);
		if(min_clientHeight==0) min_clientHeight=document.documentElement.clientHeight+document.body.clientHeight;
		if(min_clientWidth==0) min_clientWidth=document.documentElement.clientWidth+document.body.clientWidth;
		var o_top=Math.floor((document.body.scrollTop+document.documentElement.scrollTop)+(min_clientHeight-parseInt(oDiv.style.height))*0.5);
		var o_left=Math.floor((document.body.scrollLeft+document.documentElement.scrollLeft)+(min_clientWidth-parseInt(oDiv.style.width))*0.5);
		oDiv.style.top=o_top;
		oDiv.style.left=o_left;
		if(oDiv.style.top!=o_top) oDiv.style.top=o_top+"px";
		if(oDiv.style.left!=o_left) oDiv.style.left=o_left+"px";
	};
	
	LL_moveHandler();
	if (document.addEventListener) 
	{
		window.addEventListener("scroll", LL_moveHandler, false);
		window.addEventListener("resize", LL_moveHandler, false);
	}
	else if (document.attachEvent) 
	{
		window.attachEvent('onscroll', LL_moveHandler);
		window.attachEvent('onresize', LL_moveHandler);
	}
}

function OpenJubao(uin, site, id, r_id){
	var params = 'appname=webcomment&subapp=comment&jubaotype=article';
	if(uin && uin != '0') params+='&uin='+uin;
	params += '&site='+site+'&c_id='+id+'&r_id='+r_id;
	OpenJubaoDiv(params);
}

/*function onLogout(){
	if($('b_login_post'))
	{
		hideElement('b_login_post');
		if($('to_login2'))
		    showElement('to_login2');
	}
	if($('ctrlLogin'))
		if($('b_login_frame'))
			$('ctrlLogin').innerHTML	= '<a class="b2" id="to_login" href="#to_user_login">登录</a>';
	if($('to_login')){
		$('to_login').onclick = function(){
			$('b_login_frame').src = 'i_login.htm?b_login_frame&&true';
			showElement('b_login_post');
			if($('to_login2'))
		        hideElement('to_login2');
		    if($('nick_div'))
		        hideElement('nick_div');
		}
	}
	
	if('l_login_post')
	{
		hideElement('l_login_post');
		if($('sPost_to_login2'))
		    showElement('sPost_to_login2');
	}
}*/

/*  |xGv00|f92cbd8242f8126f889fbc84f0b6baf4 */