//roomid,face,nick,iclass,fansnum
var TopListFirstFansStr='<li class="first"><p class="pic"><a href="/{0}"><img src="{1}" onerror="this.src=images/face.png"></a></p><dl><dt><a href="/{0}">{2}</a>&nbsp;&nbsp;<img src="/images/pixel.gif" class="{3}"></dt><dd>粉丝：<em>{4}个</em></dd></dl></li>';
var TopListFirstStr='<li class="first"><p class="pic"><a href="/{0}"><img src="{1}" onerror="this.src=images/face.png"></a></p><dl><dt><a href="/{0}">{2}</a>&nbsp;&nbsp;<img src="/images/pixel.gif" class="{3}"></dt><dd>（<em>{0}</em>）</dd></dl></li>';
var TopListStr='<li><div class="l"><a target="_blank" href="/{0}">{2}</a><strong class="hit">({0})</strong></div><div class="r"><img src="/images/pixel.gif" class="{3} userLevelSmall"></div></li>';

InitCD();
function InitCD()
{
	//toplist day
	if(typeof(TopListReDay)!="undefined")
	{
		var DayObj = eval("("+TopListReDay+")");
		var Ct = DayObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24)
		{
			GetAjaxTopList("Day");
			return false;
		}
		$("#TopList1").html("");
		$.each(DayObj.data1,function(i,e){
			if(i==0)
			{
				$("#TopList1").append($.format(TopListFirstStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
			else
			{
				$("#TopList1").append($.format(TopListStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
		});
		$("#TopList2").html("");
		$.each(DayObj.data2,function(i,e){
			if(i==0)
			{
				$("#TopList2").append($.format(TopListFirstStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
			else
			{
				$("#TopList2").append($.format(TopListStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
		});
		$("#TopList3").html("");
		$.each(DayObj.data3,function(i,e){
			if(i==0)
			{
				$("#TopList3").append($.format(TopListFirstFansStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
			else
			{
				$("#TopList3").append($.format(TopListStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
		});
	}
	else
	{
		GetAjaxTopList("Day");
	}
}

function GetAjaxTopList(str)
{
	$.get("/f/CreatTopUser20.asp",{ac:str,t:GetSendTime},function(){
		var TopListRe = eval("TopListRe"+str);
		var DayObj = eval("("+TopListRe+")");
		$("#TopList1").html("");
		$.each(DayObj.data1,function(i,e){
			if(i==0)
			{
				$("#TopList1").append($.format(TopListFirstStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
			else
			{
				$("#TopList1").append($.format(TopListStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
		});
		$("#TopList2").html("");
		$.each(DayObj.data2,function(i,e){
			if(i==0)
			{
				$("#TopList2").append($.format(TopListFirstStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
			else
			{
				$("#TopList2").append($.format(TopListStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
		});
		$("#TopList3").html("");
		$.each(DayObj.data3,function(i,e){
			if(i==0)
			{
				$("#TopList3").append($.format(TopListFirstFansStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
			else
			{
				$("#TopList3").append($.format(TopListStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
		});
	},"script");
}


function CD(y,c)
{
	//toplist day
	if(typeof(TopListReDay)!="undefined")
	{
		var DayObj = eval("("+TopListReDay+")");
		var Ct = DayObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24)
		{
			TopOnClickAjax(y,'Day');
			return false;
		}
		TopOnClick(y,DayObj);
	}
	else
	{
		TopOnClickAjax(y,'Day');
	}
	$(c).parent().parent().find(".on").removeClass("on");
	$(c).addClass("on");
}

function CW(y,c)
{
	//toplist day
	if(typeof(TopListReWeek)!="undefined")
	{
		var DayObj = eval("("+TopListReWeek+")");
		var Ct = DayObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24*7)
		{
			TopOnClickAjax(y,'Week');
			return false;
		}
		TopOnClick(y,DayObj);
	}
	else
	{
		TopOnClickAjax(y,'Week');
	}
	$(c).parent().parent().find(".on").removeClass("on");
	$(c).addClass("on");
}

function CM(y,c)
{
	//toplist day
	if(typeof(TopListReMonth)!="undefined")
	{
		var DayObj = eval("("+TopListReMonth+")");
		var Ct = DayObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24*31)
		{
			TopOnClickAjax(y,'Month');
			return false;
		}
		TopOnClick(y,DayObj);
	}
	else
	{
		TopOnClickAjax(y,'Month');
	}
	$(c).parent().parent().find(".on").removeClass("on");
	$(c).addClass("on");
}

function CS(y,c)
{
	//toplist day
	if(typeof(TopListReSupper)!="undefined")
	{
		var DayObj = eval("("+TopListReSupper+")");
		var Ct = DayObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24)
		{
			TopOnClickAjax(y,'Supper');
			return false;
		}
		TopOnClick(y,DayObj);
	}
	else
	{
		TopOnClickAjax(y,'Supper');
	}
	$(c).parent().parent().find(".on").removeClass("on");
	$(c).addClass("on");
}

function TopOnClick(y,DayObj)
{
	if(y==1)
	{
		$("#TopList1").html("");
		$.each(DayObj.data1,function(i,e){
			if(i==0)
			{
				$("#TopList1").append($.format(TopListFirstStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
			else
			{
				$("#TopList1").append($.format(TopListStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
		});
	}
	else if(y==2)
	{
		$("#TopList2").html("");
		$.each(DayObj.data2,function(i,e){
			if(i==0)
			{
				$("#TopList2").append($.format(TopListFirstStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
			else
			{
				$("#TopList2").append($.format(TopListStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
		});
	}
	else if(y==3)
	{
		$("#TopList3").html("");
		$.each(DayObj.data3,function(i,e){
			if(i==0)
			{
				$("#TopList3").append($.format(TopListFirstFansStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
			else
			{
				$("#TopList3").append($.format(TopListStr,e.roomid,e.face!=""?e.face:"/i/v1/images/face.png",e.nick,e.iclass,e.fansnum));
			}
		});
	}
}

function TopOnClickAjax(y,str)
{
	$.get("/f/CreatTopUser20.asp",{ac:str,t:GetSendTime},function(){
		var TopListRe = eval("TopListRe"+str);
		var DayObj = eval("("+TopListRe+")");
		TopOnClick(y,DayObj);
	},"script");
}

