﻿var VotesList={
	type:0,
	top:12,
	period:1,
	uId:0,
	total:0,
	init:function(){
		if(VotesList.total>100)
			VotesList.total=100;
		if(VotesList.total<1){
			$("#votersList").text("暂无支持者！");
			return;
		}
		VotesList.r(1);
	},
	r:function(p){
		Loading.show();
		var url="/Pilgrimage/ajax/get.aspx?random="+parseInt(Math.random()*100);
		$.getJSON(url,{m:3,top:VotesList.top,page:p,period:VotesList.period,type:VotesList.type,uid:VotesList.uId},VotesList.h);
		showpages(VotesList.total,"VotesList.r",p,VotesList.top,10,"votesPages");
	},
	h:function(){
		var data = arguments[0];
		var newList="<div style=\"display:none;\"><ul>";
		for(var i=0;i<data.length;i++){
			newList+="<li><a href=\"/spaces/"+data[i].userId+"/\" target=\"_blank\"><img src=\""+InsertSmallToImgUrl(data[i].userHead,64)+"\" height=\"64\" width=\"64\" /><p>"+CutStr(data[i].userName,10)+"</p></a></li>";
		}
		newList+="</ul></div>";
		$("#votersList").append(newList);
		$("#votersList").find("div").eq(0).fadeOut(500,VotesList.replacing);
	},
	replacing:function(){
		$("#votersList").find("div").eq(0).remove();
		$("#votersList").find("div").eq(0).fadeIn(500,function(){Loading.close();});
	}
}
function InsertSmallToImgUrl(imgUrl,small){
	var index = imgUrl.lastIndexOf(".");
	imgUrl = imgUrl.substring(0,index)+small+imgUrl.substr(index);
	return imgUrl;
}
