var lesstyles = Class.create();
lesstyles.prototype = {
	initialize: function() {
		this.n				= '_lesstyles';
		this.params			= new Object();
		this.id_style		= 1;
		this.page			= 0;
		this.label_previous = 'pr&eacute;c&eacute;dent';
		this.label_next 	= 'suivant';
		this.content={
			items:'',
			total:40,
			id:null
		};
		this.setPage(0);
	},
	updateNbPage:function(){
		this.nbpage 	= this.content.total-1;
		this.pagination();
	},
	setPage:function(p){
		this.page=p;
		this.pagination();
		this.updateView();
	},
	pagination:function(){
		var html 		= '';
		var prev 		= (this.page==0) ? 0 : this.page-1;
		var next 		= (this.page==this.nbpage) ? this.nbpage-1 : this.page+1;
		if(this.nbpage<=1 || isNaN(this.nbpage)){
			html+='<li class="prev disabled"><a href="javascript:void(0);" title="'+this.label_previous+'">'+this.label_previous+'</a></li>';
			html+='<li class="next disabled"><a href="javascript:void(0);" title="'+this.label_next+'">'+this.label_next+'</a></li>';
		}else{	
			if (this.page==0){
				html+='<li class="prev disabled"><a href="javascript:void(0);" title="'+this.label_previous+'">'+this.label_previous+'</a></li>';
			}else{
				html+='<li class="prev"><a href="javascript:void(0);" onclick="'+this.n+'.setPage('+prev+');" title="'+this.label_previous+'">'+this.label_previous+'</a></li>';
			}
			if(this.page==this.nbpage){
				html+='<li class="next disabled"><a href="javascript:void(0);" title="'+this.label_next+'">'+this.label_next+'</a></li>';
			}else{
				html+='<li class="next"><a href="javascript:void(0);" onclick="'+this.n+'.setPage('+next+');" title="'+this.label_next+'">'+this.label_next+'</a></li>';
			}
		}
		$('pagination').update(html);
	
	},	
	updateView:function(){
		this.params.start 		= this.page;
		this.params.id_style 	= this.id_style
		new Ajax.Request(
			'les_styles_items.php',{
				parameters:this.params,
				method: 'get',
				onSuccess:this.display.bind(this)
			}
		);	
	},
	display:function(e){
		this.content = eval(e.responseText)[0];
		this.updateNbPage();
		this.pagination();
		$('content').update(this.content.items);
		setTimeout(function(){
			if($("pct_title"))
				FLIR.replace($("pct_title") , new FLIRStyle({  cFont:'nivme' ,mode:'wrap' }) );
			if($("prev_pct_title"))
				FLIR.replace($("prev_pct_title") , new FLIRStyle({  cFont:'nivme' ,mode:'wrap' }) );
			if($("next_pct_title"))
				FLIR.replace($("next_pct_title") , new FLIRStyle({  cFont:'nivme' ,mode:'wrap' }) );
		},100);
	},
	participate:function(){
	},
	submit:function(){
	}
}