var _pause = 'Pause';
var _play = 'Play';
var _photos = new Object();
var _photoIndex = 0;
var _photoCount = 0;
var _absolutePath='/';

function Photo(name,caption)
{
	this.name = name;
	this.caption = caption;
}

function ChangePhoto()
{
	if (_photos[_photoIndex] != null)
	{
		document.getElementById('propertyDetails__photoSlide__photoIndex').innerHTML = _photoIndex + 1;
		document.getElementById('propertyDetails__photoSlide__photo').src =_absolutePath + 'InfocasaEngine/Handlers/imageView.php?in=' + _photos[_photoIndex].name + '&is=medium';
		document.getElementById('propertyDetails__photoSlide__photo').title = _photos[_photoIndex].caption;
		document.getElementById('propertyDetails__photoSlide__photo').alt = _photos[_photoIndex].caption;
		document.getElementById('photoCaption').innerHTML = _photos[_photoIndex].caption;
	}
}

function FirstPhoto()
{
	_photoIndex = 0;

	ChangePhoto();
}

function LastPhoto()
{
	_photoIndex = _photoCount - 1;

	ChangePhoto();
}

function NextPhoto(absolutePath)
{
	_absolutePath=absolutePath;
	_photoIndex++;

	if (_photoIndex > (_photoCount - 1))
	{
		_photoIndex--;
	}

	ChangePhoto();
}

function PreviousPhoto(absolutePath)
{
	_absolutePath=absolutePath;
	_photoIndex--;

	if (_photoIndex < 0)
	{
		_photoIndex = 0;
	}

	ChangePhoto();
}

var _photoShow = false;

function PhotoShow()
{
	_photoIndex++;

	if (_photoIndex > (_photoCount - 1))
	{
		_photoIndex = 0;
		ChangePhoto();

		StopPhotoShow();

	}else{

		ChangePhoto();

		if (_photoShow == true)
		{
			window.setTimeout('PhotoShow();', 5000);
		}
	}
}

function ToggleShow(absolutePath)
{
	_absolutePath=absolutePath;
	if (_photoShow == false)
	{
		StartPhotoShow();
	}
	else
	{
		StopPhotoShow();
	}
}

function StartPhotoShow()
{
	if (_photoCount > 1)
	{
		_photoShow = true;
		PhotoShow();
		document.images['StartStop'].src = _absolutePath + 'InfocasaEngine/Images/Stop.png';
		document.images['StartStop'].title = _pause;
	}
}

function StopPhotoShow()
{
	_photoShow = false;
	document.images['StartStop'].src = _absolutePath + 'InfocasaEngine/Images/play.png';
	document.images['StartStop'].title = _play;
}

function ShowPhoto(elem,absolutePath)
{
	window.open(absolutePath + 'InfocasaEngine/Handlers/imageView.php?in=' + _photos[_photoIndex].name + '&is=large&ca=' + _photos[_photoIndex].caption,'','width=660,height=460,resizable=1,scrollbars=1');
}
