var _listentrenous;
var avisTesteurs = Class.create();
avisTesteurs.prototype = {
	initialize: function(id,init_tri,modeblank) {
		this.tri = (init_tri!="") ? init_tri : "recent";		
		
		this.btnRecent = $('btnRecent');
		this.btnBestnote = $('btnBestnote');
		this.btnRecent.observe('mouseover',this.rollOverBtnRecent.bind(this));
		this.btnRecent.observe('mouseout',this.rollOutBtnRecent.bind(this));
		
		this.btnBestnote.observe('mouseover',this.rollOverbtnBestnote.bind(this));
		this.btnBestnote.observe('mouseout',this.rollOutbtnBestnote.bind(this));
		this.id=id;
		
		if(modeblank && modeblank==true){
			this.btnRecent.observe('click',function(){
				document.location.href="avis-testeurs.html?tri=recent";
			});
			this.btnBestnote.observe('click',function(){
				document.location.href="avis-testeurs.html?tri=notes";
			});
		}else{
			this.btnRecent.observe('click',this.getMostRecents.bind(this));
			this.btnBestnote.observe('click',this.getBestNotes.bind(this));
			_listentrenous = new ajaxpagination({
				objName:'_listentrenous',
				nbitems:0,
				itembypage:6,
				next:'page suivante',
				previous:'page pr&eacute;c&eacute;dente',
				url:'get_avis.php',
				evalresult:true,
				updatediv:'contentItems',
				paginationdiv:'pagination',
				params:{id:this.id,tri:this.tri}
			});	
		}
		
		//Init les plus recent
		if(this.tri=="recent"){
			this.rollOverBtnRecent();
			this.rollOutbtnBestnote();
		}else{
			this.rollOutBtnRecent();
			this.rollOverbtnBestnote();
		}
	},
	rollOverBtnRecent:function(){
		this.btnRecent.src='skins/img/btn_more_recent_hov.gif';
	},
	rollOutBtnRecent:function(){
		if(this.tri!='recent') this.btnRecent.src='skins/img/btn_more_recent_off.gif';
	},
	rollOverbtnBestnote:function(){
		this.btnBestnote.src='skins/img/btn_mieux_note_hov.gif';
	},
	rollOutbtnBestnote:function(){
		if(this.tri!='notes') this.btnBestnote.src='skins/img/btn_mieux_note_off.gif';
	},	
	getMostRecents:function(){
		if(this.tri!='recent'){
			this.tri='recent';
			this.rollOverBtnRecent();
			this.rollOutbtnBestnote();
			_listentrenous.setPage(0);
			_listentrenous.setParams({id:this.id,tri:'recent'});
			_listentrenous.updateContent();
		}
	},
	getBestNotes:function(){
		if(this.tri!='notes'){
			this.tri='notes';
			this.rollOutBtnRecent();
			this.rollOverbtnBestnote();
			_listentrenous.setPage(0);
			_listentrenous.setParams({id:this.id,tri:'notes'});
			_listentrenous.updateContent();
		}
	}
}