function slideshow(thisSlides,thisContainer, thisProps){
	var parent = this;
	parent.slides = thisSlides;
	parent.container = thisContainer
	parent.props = thisProps;
	parent.current_index = 0;
	parent.next_index=0;
	parent.image_current = null;
	parent.image_next = null;
	parent.sizing = "natural";
	parent.scale_max = 1;
	parent.scale_min = 0;
	parent.align_h = "left"
	parent.next_loaded = true;
	parent.show_next = true
	parent.width=0
	parent.height = 0
	parent.duration = 3000;
	parent.auto_play = true;
	
	//
	//---------------------------------------------------------------
	// Set Props
	//---------------------------------------------------------------
	for (p in this.props){
		this[p] = this.props[p]
	}

	this.requestNext=function(){
		parent.show_next = true;
		if(parent.next_loaded){
			parent.displayNext();
		}else if(parent.image_next==null){
			parent.requestIndex(parent.getNextIndex());
		}
	}
	
	this.requestIndex=function(thisIndex) {
		parent.show_next = true;
		parent.next_index = thisIndex;
		parent.loadIndex(parent.next_index);
		
	}
	this.loadNext=function(){
		parent.loadIndex(parent.getNextIndex());
	}
	this.loadIndex=function(thisIndex){
		parent.next_loaded = false;
		var mySrc = parent.slides[thisIndex];
		parent.image_next = jQuery("<img>");
		parent.image_next.hide();
		parent.image_next.load(parent.nextLoaded);
		parent.image_next.attr("id","slide_"+thisIndex);
		parent.image_next.attr("src",mySrc);
	}
	this.nextLoaded=function(){
		parent.next_loaded = true;
		if(parent.show_next){
			parent.displayNext();
		}
	}
	this.displayNext = function(thisElement){
		if(parent.next_loaded){
			jQuery(parent.image_next).appendTo(parent.container); 
			parent.size(parent.width,parent.height)
			jQuery(parent.image_next).fadeIn("slow",parent.nextDisplayed);
			parent.show_next = false
		}
	}
	this.nextDisplayed = function(){
		if(parent.image_current!=null){
			jQuery(parent.image_current).remove();
		}
		parent.image_current = parent.image_next;
		parent.image_next = null;
		parent.current_index = parent.next_index;
		parent.next_index = parent.getNextIndex();
		//
		// added this one without testing it too much for 
		// a playing slideshow
		if(parent.auto_play){
			parent.loadNext();
			setTimeout(parent.requestNext, parent.duration);
		}
	}
	//
	 this.size = function(thisWidth,thisHeight){
		parent.width = thisWidth
		parent.height = thisHeight
		if(parent.image_next!=null){
			parent.arrangeSlide(parent.image_next)
		}
		if(parent.image_current!=null){
			parent.arrangeSlide(parent.image_current)
		}
	}
	this.arrangeSlide = function(thisImage){
		//
		//-----------------------------------------------------------
		// Adjust Size
		//-----------------------------------------------------------
		var myWidth = parent.width
		var myHeight = parent.height
		thisImage.width("");
		thisImage.height("");
		var myImageWidth = thisImage.width();
		var myImageHeight = thisImage.height();
		var mySizing = parent.sizing
		var myScale;
		var myDisplayWidth;
		var myDisplayHeight;

		// might also look at adding in proportion_x and proportion_y to work in conjuction with scale
		switch (mySizing){
			case "absolute":
				myDisplayWidth = myWidth;
				myDisplayHeight = myHeight;
				break
			case "scale":
			case "scale_min":
				myScale = Math.min(parent.scale_max,myWidth / myImageWidth, myHeight / myImageHeight);
				myDisplayWidth = myImageWidth*myScale;
				myDisplayHeight = myImageHeight*myScale;
				break
			case "scale_max":
				myScale = Math.max(parent.scale_min,myWidth / myImageWidth, myHeight / myImageHeight);
				myDisplayWidth = myImageWidth*myScale;
				myDisplayHeight = myImageHeight*myScale;
				break
			case "width":
				// might want to add in a max height function by using pHeight value later
				myDisplayWidth = myWidth;
				myScale = myDisplayWidth/myImageWidth;
				myDisplayHeight = myImageHeight*myScale;
				break
			case "height":
				// might want to add in a max width function by using pWidth value later
				myDisplayHeight = myHeight;
				myScale = myDisplayHeight/myImageHeight;
				myDisplayWidth = myImageWidth*myScale;
				break
			case "natural":
				// Leave both as they are
				myDisplayWidth = myImageWidth;
				myDisplayHeight = myImageHeight;
				break
		}
		//
		//
		// SCALE
		thisImage.css("width",myDisplayWidth);
		thisImage.css("height",myDisplayHeight);
		//
		//
		// POSITION
		var myAlignH = parent.align_h;
		var myLeft = 0;
		var myTop = 0;
		switch(myAlignH){
			case "left":
				break
			case "right":
				myLeft = myWidth-myDisplayWidth;
				break
			case "center":
				break
		}
		
		thisImage.css("left", myLeft);
		thisImage.css("position", "absolute");
	}

	this.getNextIndex=function(){
		var myIndex = parent.current_index+1;
		if(myIndex>=parent.slides.length){
			myIndex = 0;
		}
		return myIndex;
	}
	//
	this.requestIndex(0);
}
