

function PropertySlideShow (slideWidth)
{
	that = this; //for lambda calls

	this.slides      = jQuery("div.slides-container a");
	this.container   = jQuery("div.slides-container");

	this.pageSize    = 5;
	this.opacity     = 0.75;
	this.currentPage = -1;
	this.slideWidth  = slideWidth;
	this.pageWidth   = slideWidth * this.pageSize;
	this.totalPages  = Math.ceil(this.slides.length / this.pageSize);


	this.init = function () 
	{
		
		for (i=0; i < this.slides.length; i++)
		{
			slide = jQuery(this.slides[i]);
			slide.css('opacity',this.opacity);
			
			slide.mouseover(
				function ()
				{
					jQuery(this).css('opacity', 1);
				}
			);			

			slide.mouseout(
				function ()
				{
					jQuery(this).css('opacity', that.opacity);
				}
			);			

		}
		
		//this.pageDisplay(0, 'block');
		//this.showScrollButtons();			

		jQuery(this.container).css('margin-left', -1 * this.pageWidth * this.currentPage);
		
		this.advanceRight();
		
				
		
		jQuery("a.house-left").click(
			function ()
			{
				that.advanceLeft();
			}
		);

		jQuery("a.house-right").click(
			function ()
			{
				that.advanceRight();
			}
		);
	};
	
	
	this.advanceLeft = function ()
	{
		if (this.currentPage > 0)
		{
			this.advance(-1);
		}
	};

	this.advanceRight = function ()
	{
		if (this.currentPage < this.totalPages-1)
		{
			this.advance(1);
		}
	};
	
	
	this.advance = function (direction) 
	{
		prevPage = this.currentPage;
		this.currentPage+= direction;
	
		//show the ones scrolling in
	
		this.pageDisplay( this.currentPage, 'block' );
		
		//slide them in
		
		jQuery(this.container).animate(
			{ 'margin-left' : -1 * this.pageWidth * this.currentPage },
			700,
			function ()
			{
				//hide the previous page
				that.pageDisplay( prevPage, 'block' );
			}
		);
		
		//show/hide scoll buttons as needed
		
		this.showScrollButtons();
	};
	

	this.showScrollButtons = function ()
	{
		jQuery("a.house-left").css('display', (this.currentPage == 0 ? 'none' : 'block') );
		jQuery("a.house-right").css('display', (this.currentPage == this.totalPages-1 ? 'none' : 'block') );
	};

	
	this.pageDisplay = function (page, display)
	{
		for (i=this.pageSize * page; i < this.pageSize * (page+1); i++)
		{
			jQuery(this.slides[i]).css('display',display);
		}
	};
	
	
	this.init();

}

	


