function CTinyImg(title, url, address, cityState, price, mls, detailPage)
{
	this.ID = 0;
	this.Title = title;
	this.URL = url;
	//this.cache = new Image;
	//this.cache.src = url;
	this.Address = address;
	this.CityState = cityState;
	this.Price = price;
	this.MLS = mls;
	this.DetailPage = detailPage;
}
function CTinyImgs()
{
	var pointer = -1;
	var timerID;
	//setting properties
	var p = new CTinyImgsConfiguration();
	for (prop in p)
		this[prop] = p[prop];
	p = null;
	//Imgs holds all of the images
	this.Imgs = new Array();
	//followings are the APIs
//	this.ShowTable = showTable;
	this.AddImg = addImg;
	this.ShowFirst = first;
	this.ShowLast = last;
	this.ShowPrevious = previous;
	this.ShowNext = next;
	this.ShowImg = show;
	//this.SlideShow = play;//does not work
	this.Stop = stop;
	/*
	function AddImg(img)
	{
		this.Imgs[this.Imgs.length] = img;
	}
	*/
	function addImg(title, url, address, cityState, price, mls, detailPage)
	{
		var img = new CTinyImg(title, url, address, cityState, price, mls, detailPage);
		img.ID = this.Imgs.length;
		this.Imgs[this.Imgs.length] = img;
	}
	function previous()
	{
		pointer--;
		if (pointer < 0 )
			pointer = this.Imgs.length - 1 ;
		this.ShowImg();
	}
	function next()
	{
		pointer++;
		if (pointer >= this.Imgs.length)
			pointer = 0;
		this.ShowImg();
	}
/*	function showTable(startPict)
	{
		objName = "ActList" + idx;
		document.getElementById(objName).src = this.Imgs[startPict].URL;
		objName = "ALPrice" + idx;
		document.getElementById(objName).innerHTML = this.Imgs[startPict].Price;
		objName = "ALCityZip" + idx;
		document.getElementById(objName).innerHTML = this.Imgs[startPict].CityState;
		objName = "HiddenURL" + idx;
		document.getElementById(objName).value = this.Imgs[startPict].DetailPage;
		startPict++;
		if(startPict>=this.Imgs.length)
		{
			startPict=0;
		}
		// Set Timer and next starting photo
		window.setTimeout('CTinyImgs.ShowTable(' + startPict + ')',500);	//this.ImgShowTime);
	}
*/	
	function show()
	{
	//	alert('Here: ' + pointer);
		if( window.tinyCrossfade ) {
			tinyCrossfade(document.getElementById(this.DisplayImgCellID),document.getElementById(this.DisplayImgCellID + "Dupe"),this.Imgs[pointer].URL,'1',this.Imgs[pointer].Title);	
		}
		else {
			document.getElementById(this.DisplayImgCellID).src = this.Imgs[pointer].URL;
		}
	//	document.getElementById(this.DisplayImgTitleID).innerHTML = this.Imgs[pointer].Title;
	//	document.getElementById(this.DisplayNumberID).innerHTML = (pointer + 1) + "/" + this.Imgs.length;
	//	document.getElementById(this.ListingAddress).innerHTML = this.Imgs[pointer].Address;
	//	document.getElementById(this.ListingCityState).innerHTML = this.Imgs[pointer].CityState;
	//	document.getElementById(this.ListingMLS).innerHTML = this.Imgs[pointer].MLS;
	//	document.getElementById(this.ListingPrice).innerHTML = this.Imgs[pointer].Price;
		document.getElementById(this.HiddenURL).value = this.Imgs[pointer].DetailPage;
	}
	function first()
	{
	//	alert("first);
		pointer = 0;
		this.ShowImg();
	}
	function last()
	{
		pointer = this.Imgs.length - 1;
		this.ShowImg();
	}
	/*
	function play()
	{
		tTimerID = window.setInterval(next, this.ImgShowTime);
	}
	*/
	function stop()
	{
		try
		{
			window.clearInterval(tTimerID);
		}
		catch(e){}
	}			
}


/*
//followings will be created by server side code
var tinyImgs = new CTinyImgs();
	tinyImgs.AddImg("Title_" + i++, "http://localhost/LPSites/Uploads/1/1/Photos/front.jpg");
	tinyImgs.AddImg("Title_" + i++, "http://localhost/LPSites/Uploads/1/1/Photos/HomeShow02.jpg");
	tinyImgs.AddImg("Title_" + i++, "http://localhost/LPSites/Uploads/1/1/Photos/LivingRoom.jpg");
	tinyImgs.AddImg("Title_" + i++, "http://localhost/LPSites/Uploads/1/1/Photos/familyRoom.jpg");
	tinyImgs.AddImg("Title_" + i++, "http://localhost/LPSites/Uploads/1/1/Photos/HomeShow01.jpg");
	tinyImgs.AddImg("Title_" + i++, "http://localhost/LPSites/Uploads/1/1/Photos/LivingRoom.bmp");
	tinyImgs.AddImg("Title_" + i++, "http://www.baynetsites.com/images/miniature1.jpg");
	tinyImgs.AddImg("Title_" + i++, "http://localhost/LPSites/Uploads/1/1/Photos/BackYard.jpg");
	tinyImgs.AddImg("Title_" + i++, "http://localhost/LPSites/Uploads/1/1/Photos/Kitchen.jpg");
	tinyImgs.AddImg("Title_" + i++, "http://localhost/LPSites/Uploads/1/1/Photos/entertainment.jpg");
*/
			
//client use: event handlers
function ShowTinyImg(action)
{
	switch(action)
	{
		case "-1":
			tinyImgs.ShowPrevious();
			break;
		case "+1":
			tinyImgs.ShowNext();
			break;
		case "first":
			tinyImgs.ShowFirst();
			break;
		case "last":
			tinyImgs.ShowLast();
			break;
		case "play":
			tTimerID = window.setInterval("ShowTinyImg('+1')", tinyImgs.ImgShowTime);
			break;
		case "stop":
			try
			{
				window.clearInterval(tTimerID);
			}
			catch(e){}
			//imgs.Stop();
			break;
	}
}
