
function PhotoArray(id,name)
{
	this.id = id;
	this.name = name;
	this.photos = new Array();
	this.addPhoto = addPhoto;
	this.buildThumbList = buildThumbList;
	this.updateArray = updateArray;

	this.refresh=false;
	this.live=false;
	return this;
}
function PhotoElem(thumb,src,w,h,tw,th)
{
	this.thumbSrc = thumb;
	this.imageSrc = src;
	this.width = w;
	this.height = h;
	this.tWidth = tw;
	this.tHeight = th;
	return this;
}

function addPhoto(id,thumb,src,w,h,tw,th)
{
	if (this.photos.length <= id)
	{
		this.photos[id] = new PhotoElem(thumb,src,w,h,tw,th);
		this.refresh=true;
	}
}

function buildThumbList()
{
	html='';
	if (this.photos.length==0)
		html="<img src='cuts/s.gif' width=95 height=1>";
	else for (i=(this.photos.length-1);i>=0;i--)
	{
		html+='<div class="thumb" onmouseover="this.className=\'thumbover\';" onmouseout="this.className=\'thumb\';" onclick="showPhoto('+this.name+'.photos['+i+']);"><img src="'+this.photos[i].thumbSrc+'" width="'+this.photos[i].tWidth+'" height="'+this.photos[i].tHeight+'" border=0></div>';
	}
//	alert(html);
	return html;
}

function getObject(o)
{
	if (typeof o == 'object') return o
	else
	return document.getElementById(o);
}

function readData(port,source,delay)
{
	var d = new Date();
	w = eval("window.frames."+port);
//	w = getObject(port);
	w.location.href = source+'?tm='+escape(d.toString());
	t0 = setTimeout("readData('"+port+"','"+source+"','"+delay+"')",delay);
}

function updateArray()
{
	if (this.refresh && this.live)
	{
		content = this.buildThumbList();
		d = getObject("thumbList");
		if (d.filters) d.filters[0].Apply();
		d.innerHTML=content
		if (d.filters) d.filters[0].Play();
		if ((this==activeArray) && (this.photos.length > 0))  showPhoto(this.photos[this.photos.length-1]);
	}
	this.refresh = false;

}

function writeHTML(p)
{
	html='';
	if (p) html='<img src="'+p.imageSrc+'" width="'+p.width+'" height="'+p.height+'">';

	return html;
}

function showPhoto(photo)
{
	d = getObject("photoDiv");
	if (d.filters) d.filters[0].Apply();
//	d.innerHTML=writeHTML(photo);
	i = getObject("thePhoto");
	i.src = photo.imageSrc;
	if (d.filters) d.filters[0].Play();

}