var refreshtime=30000;
var pagerefresh=15000;
var isdesc=false;

//按倒序获取信息
function desc() {
	myRequest(document.getElementById("ulmessage"),"data/descmessage.js?fresh"+new Date().getTime());
	var mdesc = document.getElementById("messagedesc");
	var masc = document.getElementById("messageasc")
	if (mdesc!=null) mdesc.className="btnnow";
	if (masc!=null) masc.className="btnwill";
	isdesc=true;
}
//按正序获取信息
function asc() {
	myRequest(document.getElementById("ulmessage"),"data/message.js?fresh"+new Date().getTime());
	var mdesc = document.getElementById("messagedesc");
	var masc = document.getElementById("messageasc");
	if (mdesc!=null) mdesc.className="btnwill";
	if (masc!=null) masc.className="btnnow";
	isdesc=false;
}
//刷新信息区
function refreshmessage() {
	if(isdesc) {
		myRequest(document.getElementById("ulmessage"),"data/descmessage.js?fresh"+new Date().getTime());
	} else {
		myRequest(document.getElementById("ulmessage"),"data/message.js?fresh"+new Date().getTime());
	}
	setTimeout(function(){refreshmessage();},pagerefresh);
}
//刷新图片区
function refreshpicture() {
	myRequest(document.getElementById("ulpicture"),"data/picture.js?fresh"+new Date().getTime());
	setTimeout(function(){refreshpicture();},20000);
}
//刷新背景资料区
function refreshrelationinfo() {
	myRequest(document.getElementById("ulrelationinfo"),"data/relationinfo.js?fresh"+new Date().getTime());
	setTimeout(function(){refreshrelationinfo();},21000);
}
//刷新摘要区
function refreshabstract() {
	myRequest(document.getElementById("ulabstract"),"data/abstract.js?fresh"+new Date().getTime());
	setTimeout(function(){refreshabstract();},22000);
}
//刷新提问区
function refreshquestion() {
	myRequest(document.getElementById("ulquestion"),"data/question.js?fresh"+new Date().getTime());
	setTimeout(function(){refreshquestion();},23000);
}
//初始化页面
function initpage() {
	//发言控制
	var speaktag = "";
	if (speakcontrol==1) {
		speaktag = "意见征集";
	} else if (speakcontrol==2) {
		speaktag = "提 问";
	}
	var ntop = document.getElementById("now_top");
	var nbottom = document.getElementById("now_bottom");
	if (ntop!=null) ntop.innerText = speaktag;
	if (nbottom!=null) nbottom.innerText = speaktag;

	//刷新控制
	refreshtime=parseInt(refreshtime);
	pagerefresh=parseInt(pagerefresh);

	var tempselect=document.getElementById("chktime");
	if (tempselect!=null) {
		for(var i=0;tempselect.options[i].value<refreshtime;i++)
			tempselect.remove(0);
		var len = tempselect.options.length;
		for(var i=0;i<len-4;i++)
			tempselect.remove(4);
		tempselect.options[2].selected = true;
		pagerefresh=tempselect.options[2].value;
	}
	
	//Ajax获取消息
	var time = new Date();
	time = time.getTime();
	Cookie.set('refreshtime',time);
	myRequest(document.getElementById("ulmessage"),"data/message.js?fresh"+new Date().getTime());
		
	setTimeout(function(){refreshmessage();},15000);
	setTimeout(function(){refreshpicture();},20000);
	setTimeout(function(){refreshrelationinfo();},21000);
	setTimeout(function(){refreshabstract();},22000);	
	setTimeout(function(){refreshquestion();},23000);	
}
//设置刷新约束
function settime(time) {
	refreshtime = time;
}
//设置刷新时间
function resetTimer(time) {
	pagerefresh = time;
}
