
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].onclick=function()
    {
      var oldp=document.getElementById(picId);
      if(oldp)
      {
       oldp.parentNode.removeChild(oldp);
      }
      var nc=document.createElement('div');
      //d.parentNode.insertBefore(nc,d);
      document.body.appendChild(nc);
      nc.style.display='none';
      nc.id=picId;
      
      var newpic=document.createElement('img');
      newpic.src=this.href;
      newpic.alt=this.getElementsByTagName('img')[0].alt;
      
      
        
      var closeLink=document.createElement('a');
      closeLink.setAttribute("class", "closeLink");
      closeLink.setAttribute("className", "closeLink");
      closeLink.setAttribute("href", "#");
      closeLink.appendChild(document.createTextNode( "X Close"));
      closeLink.title='Click to return to images';
      closeLink.onclick=function()
      {
       this.parentNode.parentNode.removeChild(this.parentNode);
       return false;
      }
      
           
      //adding image element to a p tag, then into the nc container
      nc.appendChild(newpic);
      np=document.createElement('p');
      np.appendChild(document.createTextNode(this.getElementsByTagName('img')[0]. alt));
      nc.appendChild(np);
      
      
      
      //create a form
      var form = document.createElement("Form");
      form.setAttribute("target", "_blank");
      var input = document.createElement("Input");
      
      //var onclickString = "window.location.href='" + newpic.src + "'";
     
      
      form.setAttribute("action", newpic.src); 
      //form.setAttribute("onClick","www.google.com");
      
      input.setAttribute("type","submit");
      input.setAttribute("class", "openwindow");
      input.setAttribute("className", "openwindow"); 
      input.setAttribute("value","Open in new window");
      
      form.appendChild(input);
      nc.appendChild(closeLink);
      
      nc.appendChild(form);
      
      nc.style.display='block';
      return false;
    }
  }    
}

window.onload=function()
{
  if(document.getElementById && document.createTextNode)
  {
      dyngallery();  
  }
}

window.onload=function()
{
  if(document.getElementById && document.createTextNode)
  {
    document.body.onmouseover=function()
    {
      dyngallery();  
    }                    
  }
}

