var _pause = 'Pause';
var _play = 'Play';
var _photos = new Object();
var _photoIndex = 0;
var _photoCount = 0;
var _thumbnailUrl='/InfocasaEngine/Handlers/imageView.php?in={0}&is={1}';

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

function ChangePhoto()
{
	if (_photos[_photoIndex] != null)
	{
		u=new String(_thumbnailUrl);
		u=u.replace(/\{0\}/g,_photos[_photoIndex].name);
		//u=u.replace(/\{1\}/g,'medium');
		u=u.replace(/\{1\}/g,'543');
		//document.getElementById('propertyDetails__photoSlide__photoIndex').innerHTML = _photoIndex + 1;
		//document.getElementById('propertyDetails__photoSlide__photo').src =u;
		document.getElementById('myImage').src =u;
		//document.getElementById('propertyDetails__photoSlide__photo').title = _photos[_photoIndex].caption;
		document.getElementById('myImage').title = _photos[_photoIndex].caption;
		//document.getElementById('propertyDetails__photoSlide__photo').alt = _photos[_photoIndex].caption;
		document.getElementById('myImage').alt = _photos[_photoIndex].caption;
		//document.getElementById('photoCaption').innerHTML = _photos[_photoIndex].caption;
	}
}

function FirstPhoto(thumbnailUrl)
{
	_thumbnailUrl=thumbnailUrl;
	_photoIndex = 0;

	ChangePhoto();
}

function LastPhoto(thumbnailUrl)
{
	_thumbnailUrl=thumbnailUrl;
	_photoIndex = _photoCount - 1;

	ChangePhoto();
}

function NextPhoto(thumbnailUrl)
{
	_thumbnailUrl=thumbnailUrl;
	_photoIndex++;

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

	ChangePhoto();
}

function PreviousPhoto(thumbnailUrl)
{
	_thumbnailUrl=thumbnailUrl;
	_photoIndex--;

	if (_photoIndex < 0)
	{
		_photoIndex = _photoCount -1;
	}

	ChangePhoto();
}

var _photoShow = false;

function PhotoShow()
{
	if (_photoShow == true) {
		_photoIndex++;

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

			StopPhotoShow();

		}else{
			ChangePhoto();
			window.setTimeout('PhotoShow();', 5000);

		}
	}
}

function ToggleShow(thumbnailUrl)
{
	_thumbnailUrl=thumbnailUrl;
	if (_photoShow == false)
	{
		StartPhotoShow();
	}
	else
	{
		StopPhotoShow();
	}
}

function StartPhotoShow()
{
	if (_photoCount > 1)
	{
		_photoShow = true;
		PhotoShow();
		s = new String(document.images['StartStop'].src);
		s=s.replace(/[^/]+\.[^/]+$/g,"Stop.png");
		document.images['StartStop'].src = s;
		document.images['StartStop'].title = _pause;
	}
}

function StopPhotoShow()
{
	_photoShow = false;
	s = new String(document.images['StartStop'].src);
	s=s.replace(/[^/]+\.[^/]+$/g,"play.png");
	document.images['StartStop'].src = s;
	document.images['StartStop'].title = _play;
}

function ShowPhoto(elem,thumbnailUrl)
{
	u=new String(thumbnailUrl);
	u=u.replace(/\{0\}/g,_photos[_photoIndex].name);
	u=u.replace(/\{1\}/g,'large');
	window.open(u + '&ca=' + _photos[_photoIndex].caption,'','width=660,height=460,resizable=1,scrollbars=1');
}
function ShowPhotoLarge(num)
{
 _photoIndex = num;
 ChangePhoto();
} 
//function called on the onclick of the images in the slideshow
/*
function showPic4(whichpic, placeholder, placeholder2, titles, thumbnailUrl) {
	if (thumbnailUrl==null || thumbnailUrl=='') thumbnailUrl=_isThumbnailUrl;
	if (document.getElementById) {

		 //var photoCaption = document.getElementById('photoCaptionCentered')
		 var uMedium=new String(thumbnailUrl);
		 var uLarge=new String(thumbnailUrl);

		 uMedium=uMedium.replace(/&amp;/g,'&');
		 uMedium=uMedium.replace(/\{0\}/g,_photos[whichpic].name);
		 uMedium=uMedium.replace(/\{1\}/g,'medium');

		 uLarge=uLarge.replace(/&amp;/g,'&');
		 uLarge=uLarge.replace(/\{0\}/g,_photos[whichpic].name);
		 uLarge=uLarge.replace(/\{1\}/g,'large');
		 document.getElementById(placeholder2).href = uLarge;
		 document.getElementById(placeholder2).title = titles;
		 document.getElementById(placeholder).title= titles;
		 document.getElementById(placeholder).alt= titles;
		 //fadePhotoIn(uMedium,true,true);
		 //Set the photoCaption text
		 //if (photoCaption!=null) photoCaption.innerHTML = titles;
		 return false;
	} else {
		 return true;
	}
}
*/
