function homeSlideShow(options){

	//Optional options object 	
	this.Options = {
		'fadeDelay': 3000,
		'fadeInterval': 3000,
		'picWrapperName' : 'picFadeWrapper',
		'outerWrapperName' : 'wrapper',
		'numberedChoosers' : false,
		'hideChoosers' : false,
		'hideFadeControl' : false,
		'useArrowChoosers' : false,
		'chooserLeftOffset' : 15,
		'chooserLeftPadding' : 4
	};
	
	//assign Options with custom or default values 
	if ( options != null ) {
		for( var index in this.Options ) {
			this.Options[index] = (typeof options[index] != "undefined") ? options[index] : this.Options[index];
		}
	}
	
	//initial slideShow vars
	var slideHolder = $(this.Options.picWrapperName);
	var wrapper = $(this.Options.outerWrapperName);
	var fadeSlides = slideHolder.childElements();
	var slideCount = fadeSlides.length;
	var arrowHolder;
	var leftArrow;
	var rightArrow;
	var currFadeIn = 1;
	var currFadeOut = 0;
	var currClickForward = 1;
	var currClickBack = slideCount - 1;
	var isFading = true;
	var fadeControl;
	
	var slideArray = new Array();
	
	//constant for global 'this'
	var uberThis = this;
	
	//init the application
	this.init = function(){
		if (slideCount > 1) {
			
			//create a div to pause and restart the fading
			fadeControl = new Element('div', {
				className: 'fadeController'
			});
			wrapper.insert(fadeControl);
			
			//create a div to hold the clickers
			var clickerHolder = new Element('div', {'className': 'clickerHolder'});
			
			
			//if user arrow options are turned on
			if(this.Options.useArrowChoosers)
			{
				//create a div to hold the arrow clickers
				arrowHolder = new Element('div', {'className': 'arrowHolder'});
				
				//create a left arrow clicker
				leftArrow = new Element('div', {'className': 'leftArrow'});
				
				//mouse events to handle user interaction with arrows
				leftArrow.observe("mouseover", function(){
					$(leftArrow.parentNode).className = 'arrowHolder left';
				});
				
				leftArrow.observe("mouseout", function(){
					$(leftArrow.parentNode).className = 'arrowHolder';
				});
				
				leftArrow.observe("click", function(){
					isFading = false;
					uberThis.showSlide(currClickBack);
					uberThis.updateBackInfo();
				});
				
				//create a right arrow clicker
				rightArrow = new Element('div', {'className': 'rightArrow'});
				
				//mouse events to handle user interaction with arrows
				rightArrow.observe("mouseover", function(){
					$(leftArrow.parentNode).className = 'arrowHolder right';
				});
				
				rightArrow.observe("mouseout", function(){
					$(leftArrow.parentNode).className = 'arrowHolder';
				});
				
				rightArrow.observe("click", function(){
					isFading = false;
					uberThis.showSlide(currClickForward);
					uberThis.updateForwardInfo();
				});
				
				//set initial innerHTML for arrow buttons
				leftArrow.innerHTML = 1;
				rightArrow.innerHTML = slideCount;
				
				//add the arrows to the DOM
				arrowHolder.insert(leftArrow);
				arrowHolder.insert(rightArrow);
				
				//insert the chooser into the slideHolder
				slideHolder.insert(arrowHolder);
			}
			
			//create a button to go directly to that button's corresponding slide
			fadeSlides.each(function(n, i){
				//create the actual button
				var clickClass = i == 0 ? 'clicker clicked' : 'clicker';
				var slideControl = new Element('div', {
					className: clickClass
				});
				
				//create the left offset for each button
				//slideControl.style.left = (i * uberThis.Options.chooserLeftOffset) + uberThis.Options.chooserLeftPadding + 'px';
				
				//add numbers to the chooser class if desired by client
				if(uberThis.Options.numberedChoosers)
				{
					slideControl.innerHTML = i + 1;	
				}
				
				//hide all choosers if desired by client
				if(uberThis.Options.hideChoosers)
				{
					slideControl.hide();
				}
				
				//hide play and pause controls if desired by client
				if(uberThis.Options.hideFadeControl)
				{
					fadeControl.hide();		
				}
				
				
				//create an object to link all elements of a fading picture
				var slideObject = new Object();
				slideObject = {
					slide: fadeSlides[i],
					clicker: slideControl,
					counter: i
				};
				
				slideArray.push(slideObject);
				
				//event handler for each button
				slideControl.observe('click', function(){
					//show the necessary picture
					uberThis.showSlide(i);
					//pause the slideshow
					fadeControl.className = 'fadeController paused';
					//make the related chooser button highlighted 
					uberThis.sortButtons(i);
				});
				
				//insert the chooser into the slideHolder
				clickerHolder.insert(slideControl);
				
			});
			slideHolder.insert(clickerHolder);
			
			//pause / play control for slideshow
			fadeControl.observe("click", function(){
				if (fadeControl.className == "fadeController") {
					fadeControl.className = "fadeController paused";
					isFading = false;
				}
				else {
					fadeControl.className = "fadeController";
					isFading = true;
					uberThis.reFade();
				}
			});
			
			//start the slide show
			setTimeout(this.triggerReFade.bind(this), this.Options.fadeDelay);
		}
	}

	//sets the class state of the chooser buttons
	this.sortButtons = function(currNum){
	
		slideArray.each(function(n, i){
			if (currNum == i) {
				slideArray[i].clicker.className = 'clicker clicked';
			}
			else {
				slideArray[i].clicker.className = 'clicker';
			}
		});
	}
	
	//fades the individual slides
	this.fadeCurrSlides = function(){
		if (slideCount > 1) {
			//temp vars for the fade slides
			var fadeInDiv = fadeSlides[currFadeIn];
			var fadeOutDiv = fadeSlides[currFadeOut];
			
			//update the z-index for the slide fading in
			fadeOutDiv.style.zIndex = 1;
			fadeInDiv.style.zIndex = 2;
			
			//sort chooser buttons class states
			this.sortButtons(currFadeIn);
			
			//actual fading
			new Effect.Appear(fadeOutDiv, {
				//duration: 3.0,
				duration: this.Options.fadeInterval,
				from: 1.0,
				to: 0.0,
				afterFinish: this.triggerReFade.bind(this)
			});
			new Effect.Appear(fadeInDiv, {
				//duration: 3.0,
				duration: this.Options.fadeInterval,
				from: 0.0,
				to: 1.0
			});
			
			//update the left arrow number if being used
			if(this.Options.useArrowChoosers)
			{
				leftArrow.innerHTML = currFadeIn + 1;
				uberThis.updateForwardInfo();
			}
			
			//update fade numbers
			currFadeOut = uberThis.getFadeOrder(currFadeOut);
			currFadeIn = uberThis.getFadeOrder(currFadeIn);
		}
	}
	
	//triggers the next fade
	this.triggerReFade = function(){
		setTimeout(this.reFade.bind(this), this.Options.fadeDelay);
	}

	//calls the actual fade
	this.reFade = function(){
		if (isFading == true) {
			this.fadeCurrSlides();
		}				
	}

	//shows the correct pic based on the chooser button that is clicked
	this.showSlide = function(currSlide){
		//prevent additional fading
		isFading = false;
			
		//update the left arrow number if being used
		if(this.Options.useArrowChoosers)
		{
			leftArrow.innerHTML = currSlide + 1;
		}
		
		//show chosen slide, hide the rest
		fadeSlides.each(function(n, i){
			if (currSlide == i) {
				fadeSlides[i].show();
				fadeSlides[i].setOpacity(1.0);
				
				//update fade order
				currFadeOut = i;
				currFadeIn = uberThis.getFadeOrder(i);
			}
			else {
				fadeSlides[i].hide();
				fadeSlides[i].setOpacity(0.0);
			}
		});
	}
	
	//updates counters to set correct fade order
	this.getFadeOrder = function(currSlide){
		currSlide < slideCount - 1 ? currSlide++ : currSlide = 0;
		return currSlide;
	}
	
	this.checkBackNum = function(){
		if(currClickBack < 0){
			currClickBack = slideCount - 1;
		}		
		if(currClickForward < 0){
			currClickForward = slideCount - 1;
		}		
	}
	this.checkForwardNum = function (){
		if(currClickForward == slideCount){
			currClickForward = 0;
		}
		if(currClickBack == slideCount){
			currClickBack = 0;
		}
	}
	this.updateForwardInfo = function(){
		currClickBack++;
		currClickForward++;
		uberThis.checkForwardNum();
	}
	this.updateBackInfo = function(){
		currClickBack--;
		currClickForward--;
		uberThis.checkBackNum();
	}
}


