var topicname,
	topicid,
	page = 1,
	lock = false;

$(function() {
	$(window).scroll(function() {　　
		var scrollTop = $(this).scrollTop();　　
		var scrollHeight = $(document).height();　　
		var windowHeight = $(this).height();　　
		if(scrollTop + windowHeight == scrollHeight) {　　　　
			if(!lock) {
				lock = true;
				$('#add').attr('style', '');
				setTimeout(function() {
					callbackObj.web_talk_callback(topicid, topicname, page + "");
					page++;
					
					
				}, 500);
			}　　
		}
	});
	//alert('open!');
	$('#alert-loading').modal("open");
	topicname = decodeURIComponent(getQueryString("k"));
	$('#topicname').html(topicname);
	topicid = getQueryString("id");
	setTimeout(function() {
		callbackObj.web_talk_callback(topicid, topicname, page + "");
		page++;
	}, 500);

	$('#reload').click(function() {
		location.reload();
	});
	$('#firebtn').click(function(){
		$('#hot-cover').attr('style','');
		$('#panel-hot').attr('style','');
		$('body').attr('style','overflow: hidden');
	});
	$('#hot-cover').click(function(){
		$('body').attr('style','');
		$('#hot-cover').attr('style','display: none');
		$('#panel-hot').attr('style','display: none');
	});
})
function addtalks(title,num,id,ishot)
{
	if(ishot=="2")
	{
		$("#hot-add").after('<hr data-am-widget="divider" style="" class="am-divider am-divider-default hot-hr" />'+
				'<div onclick="callbackObj.web_hot_see(\''+id+'\',\''+title+'\')" class="hot-list"><p>'+title+'</p><i class="am-icon am-icon-fire" aria-hidden="true"></i><span class="am-badge am-badge-primary am-radius">贴数：'
				+num+'</span></div>');
	}
	else
	{
		$("#hot-add").after('<hr data-am-widget="divider" style="" class="am-divider am-divider-default hot-hr"" />'+
				'<div onclick="callbackObj.web_hot_see(\''+id+'\',\''+title+'\')" class="hot-list"><p>'+title+'</p><span class="am-badge am-badge-primary am-radius">贴数：'
				+num+'</span></div>');
	}
}
function addtalk(tid, title, content, replynum, tbname, author, avatar, time, err) {
	if(err == "0") {
		lock = false;
		$('#add').attr('style', 'display: none');
		$('#addtalk').before('<article class="am-comment">' +
			'<a onclick="callbackObj.web_user_see(\'' + author + '\')"> <img class="am-comment-avatar" src="' + avatar + '"/></a>' +
			'<div class="am-comment-main"><header class="am-comment-hd">' +
			'<h3 onclick="callbackObj.web_thread_enter(\'' + tid + '\',\'' + tbname + '\')" class="am-comment-title">' + title + '</h3>' +
			'<div class="am-comment-meta">' +
			'<span onclick="callbackObj.web_searchbar_tb(\'' + tbname + '\')" class="am-badge am-badge-primary am-radius">' + tbname + '吧</span>' +
			'     ' +
			'<a onclick="callbackObj.web_user_see(\'' + author + '\')" class="am-comment-author">' + author + '</a>于 <time datetime="">' + time + '</time></div></header>' +
			'<div class="am-comment-bd">' +
			content +
			'</div></div>' +
			'</article>')
	} else {
		if(err == "1") {
			lock = true;
			$('#add').attr('style', 'display: none');
		} else {
			lock = true;
			$('#add').attr('style', 'display: none');
			$('#alert-info').text("获取新消息失败");
			$('#alert').modal("open");
		}
	}
}

function addtalkmsg(num, tid, title, content, replynum, tbname, author, time, err) {
	$('#alert-loading').modal("close");
	if(err == "0") {
		$('#topicnum').html(num);
		$('#addtalkmsg').before('<article class="am-comment">' +
			'<a onclick="callbackObj.web_user_see(\'' + author + '\')"> <img class="am-comment-avatar" src="./img/timg.jpg"/></a>' +
			'<div class="am-comment-main"><header class="am-comment-hd">' +
			'<h3 onclick="callbackObj.web_thread_enter(\'' + tid + '\',\'' + tbname + '\')" class="am-comment-title">' + title + '</h3>' +
			'<div class="am-comment-meta">' +
			'<span onclick="callbackObj.web_searchbar_tb(\'' + tbname + '\')" class="am-badge am-badge-primary am-radius">' + tbname + '</span>' +
			'     ' +
			'<a onclick="callbackObj.web_user_see(\'' + author + '\')" class="am-comment-author">' + author + '</a>于 <time datetime="">' + time + '</time></div></header>' +
			'<div class="am-comment-bd">' +
			content +
			'</div></div>' +
			'</article>')
	} else {

		$('#alert-info').text("获取话题信息失败");
		$('#alert').modal("open");

	}
}