
var carousel = {
							
	inicialize: function(options){
		
		this.options = Object.extend({
			resizeDuration: 400,
			resizeTransition: Fx.Transitions.sineInOut,
			container: document.body,
			descriptions: true,
			opacity: 0.7,
			url: ''
		}, options || {});
		
		this.number_objects = $A($$('.hotels-page')).length;
		this.current_page = 1;
		
		if ( $('llistat_hotels') ) {
			this.setupArrows();
		}
	
	},

	
	
	previousPage: function() {
		
		$('page-'+this.current_page).style.display = 'none';
		
		this.current_page = this.current_page - 1;
		
		$('page-'+this.current_page).style.display = '';
		
		var myFx = new Fx.Scroll(window,{duration:0}).toElement('llistat_hotels');
		
		this.setupArrows();
				
		return false;
		
	},
	
	
	nextPage: function() {
		
		$('page-'+this.current_page).style.display = 'none';
		
		this.current_page = this.current_page + 1;
		
		$('page-'+this.current_page).style.display = '';
		
		var myFx = new Fx.Scroll(window,{duration:0}).toElement('llistat_hotels');
		
		this.setupArrows();
				
		return false;
		
	},
	
	
	setupArrows: function() {
				
		$('anterior').removeEvents('click');
		$('siguiente').removeEvents('click');
		
		
		if ( (this.current_page) > this.number_objects || this.current_page < 1 )
			this.current_page = this.number_objects;
		
		
		// Estic al principi
		if ( this.current_page == 1 ) {
						
			$('siguiente').addEvent('click', function() {
				this.nextPage();
			}.bind(this));
			
			$('anterior').style.display = 'none';
			
			if ( $('siguiente').style.display == 'none' )
				$('siguiente').style.display = '';
		}
		
		
		// No estic ni al començament ni al final
		if ( this.current_page > 1 && this.current_page < this.number_objects ) {
			
			//alert('al mig');
			
			$('anterior').addEvent('click', function() {
				this.previousPage();
			}.bind(this));
			
			$('siguiente').addEvent('click', function() {
				this.nextPage();
			}.bind(this));
			
			if ( $('anterior').style.display == 'none' )
				$('anterior').style.display = '';
			
			if ( $('siguiente').style.display == 'none' )
				$('siguiente').style.display = '';
				
		}
		
		// Estic al final
		if ( this.current_page >= this.number_objects ) {
			
			$('anterior').addEvent('click', function() {
				this.previousPage();
			}.bind(this));
			
			if ( $('anterior').style.display == 'none' && this.number_objects > 1 )
				$('anterior').style.display = '';
						
			$('siguiente').style.display = 'none';
		}
		
		return false;
		
	}	
	
};