function dyngallery()
{
	var picId='bigDynPic';
	var d=document.getElementById('thumbs');
	
	if(!d){return;}
	
	var piclinks=d.getElementsByTagName('a');
	for(var i=0;i<piclinks.length;i++)
	{
    piclinks[i].i=i;

		piclinks[i].onclick=function()
		{
      if(!/sequential/.test(d.className))
      {
      	d.className='sequential';
      }
      
      for(var j=0;j<piclinks.length;j++)
      {
        piclinks[j].parentNode.className=(j==this.i)?'current':'';
        piclinks[j].parentNode.style.display=(j<this.i-1 || j>this.i+1)?'none':'block';
      }
      
  		// Check if there is already an element with the same ID as picId
  		// If that is the case, remove this element - this is necessary to make the element "shrink-wrap" 
  		// around our image.
			var oldp=document.getElementById(picId);
			if(oldp)
			{
			  oldp.parentNode.removeChild(oldp);
			}
			
      // Create a new DIV element with the ID defined in picId.
			var nc=document.createElement('div');
			d.parentNode.insertBefore(nc,d);
			nc.style.display='none';
			nc.id=picId;
			
      // Create a new image with the same source the thumbnail-link points to.
			var newpic=document.createElement('img');
			newpic.src=this.href;
      
      // Set the alternative text of the image.
			newpic.alt=this.getElementsByTagName('img')[0].alt;
      
      // Add a title to the image, telling the visitor that clicking the image will get her back to 
      // the thumbnails.
			newpic.title='Click to return to images';
			
      // Adding a function to the image that reloads the window when the big image is clicked.
			newpic.onclick=function()
			{
        window.location=window.location;
			}
			
			nc.appendChild(newpic);
			np=document.createElement('p');
			np.appendChild(document.createTextNode(this.getElementsByTagName('img')[0].alt))
			nc.appendChild(np);
			nc.style.display='block';
			
			return false;
		}
	}		
}

window.onload=function()
{
	if(document.getElementById && document.createTextNode)
	{
		document.body.onmouseover=function()
		{
			dyngallery();	
		}																
		
	}
}

