function virtualpaginate(_1,_2,_3){
	var _3=(typeof _3=="undefined")?"div":_3;
	this.pieces=virtualpaginate.collectElementbyClass(_1,_3);
	this.chunksize=(typeof _2=="undefined")?1:(_2>0&&_2<this.pieces.length)?_2:this.pieces.length;
	this.pagecount=Math.ceil(this.pieces.length/this.chunksize);
	this.showpage(-1);
	this.currentpage=0;
	this.showpage(this.currentpage);
}
virtualpaginate.collectElementbyClass=function(_4,_5){
	var _6=new RegExp("(^|\\s+)"+_4+"($|\\s+)","i");
	var _7=[];
	var _8=document.getElementsByTagName(_5);
	for(var i=0;i<_8.length;i++){
		if(typeof _8[i].className=="string"&&_8[i].className.search(_6)!=-1){
			_7[_7.length]=_8[i];
		}
	}
	return _7;
};
virtualpaginate.prototype.showpage=function(_a){
	var _b=this.pieces.length;
	var _c=_a*this.chunksize;
	var _d=_c+this.chunksize-1;
	for(var i=0;i<_b;i++){
		if(i>=_c&&i<=_d){
			this.pieces[i].style.display="block";
		}else{
			this.pieces[i].style.display="none";
		}
	}
	this.currentpage=parseInt(_a);
	if(this.cpspan){
		this.cpspan.innerHTML="Page "+(this.currentpage+1)+"/"+this.pagecount;
	}
};
virtualpaginate.prototype.paginate_build_selectmenu=function(_f,_10){
	var _11=this;
	var _10=_10||new Array();
	this.selectmenupresent=1;
	for(var i=0;i<this.pagecount;i++){
		if(typeof _10[i]!="undefined"){
			_f.options[i]=new Option(_10[i],i);
		}else{
			_f.options[i]=new Option("Page "+(i+1)+" of "+this.pagecount,i);
		}
	}
	_f.selectedIndex=this.currentpage;
	_f.onchange=function(){
		_11.showpage(this.selectedIndex);
	};
};
virtualpaginate.prototype.paginate_build_regularlinks=function(_13){
	var _14=this;
	for(var i=0;i<_13.length;i++){
		var _16=_13[i].getAttribute("rel");
		if(_16=="previous"||_16=="next"||_16=="first"||_16=="last"){
			_13[i].onclick=function(){
				_14.navigate(this.getAttribute("rel"));
				return false;
			};
		}
	}
};
virtualpaginate.prototype.paginate_build_flatview=function(_17,_18){
	var _19=this;
	var _1a="";
	var _18=_18||new Array();
	for(var i=0;i<this.pagecount;i++){
		if(typeof _18[i]!="undefined"){
			_1a+="<a href=\"#flatview\" rel=\""+i+"\">"+_18[i]+"</a> ";
		}else{
			_1a+="<a href=\"#flatview\" rel=\""+i+"\">"+(i+1)+"</a> ";
		}
	}
	_17.innerHTML=_1a;
	this.flatviewlinks=_17.getElementsByTagName("a");
	for(var i=0;i<this.flatviewlinks.length;i++){
		this.flatviewlinks[i].onclick=function(){
			_19.flatviewlinks[_19.currentpage].className="";
			this.className="selected";
			_19.showpage(this.getAttribute("rel"));
			return false;
		};
	}
	this.flatviewlinks[this.currentpage].className="selected";
	this.flatviewpresent=true;
};
virtualpaginate.prototype.paginate_build_cpinfo=function(_1c){
	this.cpspan=_1c;
	_1c.innerHTML="Page "+(this.currentpage+1)+"/"+this.pagecount;
};
virtualpaginate.prototype.buildpagination=function(_1d,_1e){
	var _1f=this;
	var _20=document.getElementById(_1d);
	if(this.chunksize==this.pieces.length){
		_20.style.display="none";
		return;
	}
	var _21=_20.innerHTML;
	if(_20.getElementsByTagName("select").length>0){
		this.paginate_build_selectmenu(_20.getElementsByTagName("select")[0],_1e);
	}
	if(_20.getElementsByTagName("a").length>0){
		this.paginate_build_regularlinks(_20.getElementsByTagName("a"));
	}
	var _22=_20.getElementsByTagName("span");
	for(var i=0;i<_22.length;i++){
		if(_22[i].className=="flatview"){
			this.paginate_build_flatview(_22[i],_1e);
		}else{
			if(_22[i].className=="paginateinfo"){
				this.paginate_build_cpinfo(_22[i]);
			}
		}
	}
	this.paginatediv=_20;
};
virtualpaginate.prototype.navigate=function(_24){
	if(this.flatviewpresent){
		this.flatviewlinks[this.currentpage].className="";
	}
	if(_24=="previous"){
		this.currentpage=(this.currentpage>0)?this.currentpage-1:(this.currentpage==0)?this.pagecount-1:0;
	}else{
		if(_24=="next"){
			this.currentpage=(this.currentpage<this.pagecount-1)?this.currentpage+1:0;
		}else{
			if(_24=="first"){
				this.currentpage=0;
			}else{
				if(_24=="last"){
					this.currentpage=this.pieces.length-1;
				}
			}
		}
	}
	this.showpage(this.currentpage);
	if(this.selectmenupresent){
		this.paginatediv.getElementsByTagName("select")[0].selectedIndex=this.currentpage;
	}
	if(this.flatviewpresent){
		this.flatviewlinks[this.currentpage].className="selected";
	}
};


