function dyngallery()
{
	var picId='bigDynPic';
	var loadingId='loadingmessage';
	var hiddenframeid='hiddenframe';
	var d=document.getElementById('thumbs');
	if(!d){return;}
	if(!document.getElementById(loadingId))
	{
		var lo=document.createElement('div');
		var throbber = document.createElement('img');
		throbber.src="./img/loading.gif";
		lo.appendChild(throbber);
		lo.appendChild(document.createTextNode('Loading image'));
		d.parentNode.insertBefore(lo,d);
		lo.id=loadingId;
		lo.style.display='none';
	}
	var piclinks=d.getElementsByTagName('a');
	for(var i=0;i<piclinks.length;i++)
	{
		piclinks[i].onclick=function()
		{
			document.getElementById(loadingId).style.display='block';
			var oldp=document.getElementById(picId);
			if(oldp)
			{
			 oldp.parentNode.removeChild(oldp);
			}
			var nc=document.createElement('div');
			d.parentNode.insertBefore(nc,d);
			nc.style.display='none';
			nc.id=picId;
			var newpic=document.createElement('img');
			//newpic.src=this.href;
			//newpic.alt=this.getElementsByTagName('img')[0].alt;
			newpic.alt=this.title;
			newpic.title='Click to return to images';
			newpic.onload=function()
			{
				document.getElementById(loadingId).style.display='none';
				document.getElementById(hiddenframeid).src=this.src;       // this is a hack untill we think of a bettwer way of doing it. it's not very bandwidth friendly ATM depending on how we do it.
			}
			newpic.onclick=function()
			{
				this.parentNode.parentNode.removeChild(this.parentNode);
			}
			newpic.src=this.href;
			nc.appendChild(newpic);
			np=document.createElement('p');
			//np.appendChild(document.createTextNode(this.getElementsByTagName('img')[0].alt))
			np.appendChild(document.createTextNode(this.title))
			nc.appendChild(np);
			nc.style.display='block';
			return false;
		}
	}
}

window.onload=function()
{
	if(document.getElementById && document.createTextNode)
	{
		document.body.onmouseover=function()
		{
			dyngallery();	
		}																
		
	}
}

