var maxpage = 0,
	page = 1,
	keyword;

$(function() {
	$('#alert-loading').modal("open");
	keyword = decodeURI(getQueryString("k"));
	setTimeout(function() {
		callbackObj.web_search_callback(keyword, page + "")
		if(maxpage <= page) {
			lock = true;
		} else {
			lock = false;
		}
	}, 500);
	$('#reload').click(function() {
		location.reload();
	});
	$(window).scroll(function() {　　
		var scrollTop = $(this).scrollTop();　　
		var scrollHeight = $(document).height();　　
		var windowHeight = $(this).height();　　
		if(scrollTop + windowHeight == scrollHeight) {　　　　
			if(!lock) {
				lock = true;
				$('#btn-add').attr('style', '');
				page++;
				setTimeout(function() {
					callbackObj.web_search_callback(keyword, page + "");
					$('#btn-add').attr('style', 'display:none ;');
					if(maxpage <= page) {
						lock = true;
					} else {
						lock = false;
					}
				}, 500);
			}　　
		}
	});
});

//添加结果
function addre(title, content, tbname, user, time, tid) {
	lock = false;
	$('#alert-loading').modal("close");
	$('#add').before('<div class="am-panel am-panel-default"><div class="am-panel-bd search-re" style="padding-bottom: 2px;"><a onclick="callbackObj.web_thread_enter(\'' + tid + '\',\'' + tbname + '\')" >' + title + '</a><br /><p>' + content + '</p><span class="am-icon-user ">   ' + user + '</span><span class="am-icon-list">   ' + tbname + '吧</span><p style="display: inline-block; float: right;">' + time + '</p></div></div>');
}

function errcallback(info) {
	$('#alert-info').text(info);
	$('#alert').modal("close");
}