var CatsSlider = new Class({

	//implements
	Implements: [Options],

	//origColor: null,
	positionsArray: new Array(),
	pageNum: 1,						//variable to hold current item in list
	direction: 0,						//flag variable (1/0) used to tell slide function to go forward or backward
	max_y: 0,							//will be used to hold the slider's maximum x position
	min_y:  null,						//will be used to hold the slider's minimum position					
	list_scroll: null,  					//I'm using this to hold my slider Fx.tween stuff (for re-use and chaining)

	//options
	options: {
	transitionTime: 750, 	//transition time (1 second = 1000) for slide animation
	container: null,			//container element
	contH: null, 				//container height
	pageH: null,				//height of one page (scroll amount)
	numPages: null,			//total number of pages (base 1)
	nextBtn: null,				//next btn element
	prevBtn: null,				//prev btn element
	thePages: null			//pagination display element
	//prevNextWidth: 24	//width of prev/next buttons
	},

	//initialization
	initialize: function(options) {
		//set options
		this.setOptions(options);
		
		//this.options.container.setStyle('overflow', "hidden");  //remove scrollbar(s)
		
		/*
		//setup slider animation
		this.list_slide = new Fx.Tween(this.options.itemsHolder, {
		     duration: this.options.transitionTime, 
		     transition: Fx.Transitions.Cubic.easeOut, 
		     link: 'cancel'
		});
		*/
		
		//setup scroll animation
		this.list_scroll = new Fx.Scroll(this.options.container, {
		     duration: this.options.transitionTime, 
		     transition: Fx.Transitions.Cubic.easeOut, 
		     link: 'cancel'
		});
		
		this.list_scroll.toTop();
		
		var pageString = this.pageNum + " / " + this.options.numPages;
		this.options.thePages.set('text', pageString);
		
		this.options.prevBtn.set('text', 'Prev');
		this.options.nextBtn.set('text', 'Next');
		
		var containerH = this.options.contH;
		var pageH = this.options.pageH;
		this.min_y = 0;
		
		//show pagination display (1/3)
		
		//prev & next buttons
		this.options.prevBtn.setStyles({
			'display' : 'block',
			'position' : 'absolute',
			'z-index': 150,
			'overflow' : 'hidden',
			'cursor' : 'pointer'
		});
		
		this.options.nextBtn.setStyles({
			'display' : 'block',
			'position' : 'absolute',
			'z-index': 150,
			'overflow' : 'hidden',
			'cursor' : 'pointer'
		});
		
		this.options.prevBtn.set('tween', { duration: 200, transition: 'cubic:out' });
		this.options.nextBtn.set('tween', { duration: 200, transition: 'cubic:out' });
		
		//hide prev button no matter what, since starting at 0
		this.options.prevBtn.setStyles({
			'opacity': '0'
			//height: containerH
		});
		
		this.options.nextBtn.setStyles({
			'opacity': '.9'
			//height: containerH
		});
		
		this.options.nextBtn.addEvents({
			'click' : this.nextPress.bindWithEvent(this),
			'mouseenter' : function() {
				this.tween('opacity', .9);
			},
			'mouseleave' : function() {
				this.tween('opacity', .8);
			}
		});
	
	},

	//a method that does whatever you want
	start: function() {
		
		//initial 'dummy' tween, fixes first tween glitch in IE/Safari
		this.list_slide.start('top', 0);
		
		this.options.container.set('tween', {duration: 1500, transition: Fx.Transitions.Cubic.easeOut});
		this.options.container.tween('opacity',1);
	},


	slideIt: function() {

		//var numItems = this.options.items.length;  //get number of slider items
		
		//get initial slide position
		var curPosition =  (this.pageNum - 1) * this.options.pageH;
		
		//change index based on value of 'direction' parameter
		if(this.direction == 0){
			if(this.pageNum < this.options.numPages){
				this.pageNum++; 
				//var newPosition =  -1 * ((this.pageNum - 1) * this.options.pageH);
				var newPosition = (this.pageNum - 1) * this.options.pageH;
				if(this.pageNum == this.options.numPages){
					this.options.nextBtn.removeEvents();
					this.options.nextBtn.tween('opacity', 0);
				}
			}
			else {
				var newPosition = curPosition;
			}
		}
		else{
			if(this.pageNum > 0){
				this.pageNum--; 
				//var newPosition =  -1 * ((this.pageNum - 1) * this.options.pageH);
				var newPosition = (this.pageNum - 1) * this.options.pageH;
				if(this.pageNum == 1){
					this.options.prevBtn.removeEvents();
					this.options.prevBtn.tween('opacity', 0);
				}
			}
			else{
				var newPosition = curPosition;
			}
		}
		
		
		if(newPosition != curPosition) {
			//this.list_slide.start({
				//'left': newPosition
			//});
			//this.list_scroll.start(newPosition);
			//this.list_scroll.toBottom();
			var pageString = this.pageNum + " / " + this.options.numPages;
			this.options.thePages.set('text', pageString);
			this.list_scroll.start(0, newPosition);
			//this.options.container.setAttribute('scrollTop', newPosition);
		}
			

	
	},
	
	//--------------------------------------------------------------------------------------------------------
	//supplementary functions  (mini-functions)
	//--------------------------------------------------------------------------------------------------------
	nextPress: function () {
		this.direction = 0;
		this.slideIt();
		
		if(this.options.prevBtn.getStyle('opacity') == 0){
			this.options.prevBtn.tween('opacity', .8);	
			
			this.options.prevBtn.addEvents({
				'click' : this.prevPress.bindWithEvent(this),
				'mouseenter' : function() {
					this.tween('opacity', .9);
				},
				'mouseleave' : function() {
					this.tween('opacity', .8);
				}
			});
			
		}
		
	},
	
	prevPress: function () {
		this.direction = 1;
		this.slideIt();
		
		if(this.options.nextBtn.getStyle('opacity') == 0){
			this.options.nextBtn.tween('opacity', .8);	
			
			this.options.nextBtn.addEvents({
				'click' : this.nextPress.bindWithEvent(this),
				'mouseenter' : function() {
					this.tween('opacity', .9);
				},
				'mouseleave' : function() {
					this.tween('opacity', .8);
				}
			});
			
		}
	}
	
	//------------------------  end supp. functions -----------------------------------------//
	
	

});

