
function expandThumbnail(theTarget)
{
	var theBody = document.getElementsByTagName("body")[0];
	var theCanvasShadow = document.getElementById("canvasShadow");
	var theIDNum = 0;

	var theContainer = document.createElement("div");
	var theCloseLink = document.createElement("a");
	var theImageCloseLink = document.createElement("a");
	var theImage = document.createElement("img");
	var theSpan1 = document.createElement("div");
	var theSpan2 = document.createElement("span");
	var theBreak = document.createElement("br");
	
	var hrefSrc = this.href.replace(/\?.*/, "");
	var hrefWidth = this.href.replace(/.*\?(.*),.*/, "$1");
	var hrefHeight = this.href.replace(/.*,/, "");
 
        var bodyHeight = 0;
        var bodyWidth = 0;

	if(hrefSrc.substr(hrefSrc.length-4,4) == ".pic")
	{
	   var idx = hrefSrc.lastIndexOf("/");
	   var tmpstr = hrefSrc.substr(idx,hrefSrc.length-4);
	   var picname = tmpstr.substr(2,tmpstr.length-6);
	   hrefSrc = hrefSrc.substr(0,idx+1) + "thassos-" + picname + ".jpg";
	}



   if  (typeof(window.innerWidth) == 'number') bodyWidth = window.innerWidth;
   if  (typeof(window.document.body.clientWidth) == 'number') bodyWidth = window.document.body.clientWidth;
   if  (typeof(window.innerHeight) == 'number') bodyHeight = window.innerHeight;
   if  (typeof(window.document.body.clientHeight) == 'number') bodyHeight = window.document.body.clientHeight;

   //alert(bodyWidth + " x " + bodyHeight);

   if(bodyWidth > 0 && bodyHeight > 0)
   {

      var maxW = bodyWidth / 100 * 80;
      var maxH = bodyHeight / 100 * 80;
      
      if(hrefWidth > maxW)
      {
         var percent = maxW * 100 / hrefWidth;
      	 hrefWidth = maxW;
         hrefHeight = hrefHeight / 100 * percent;
      }

      if(hrefHeight > maxH)
      {
         var percent = maxH * 100 / hrefHeight;
      	 hrefHeight = maxH;
         hrefWidth = hrefWidth / 100 * percent;
      }
      

   }



	theIDNum = parseInt(this.id.replace(/.*thumbnailLink(.).*/, "$1"));

	theCanvasShadow.innerHTML = "";

	theBody.style.backgroundColor = "#EDEDED";
	theCanvasShadow.className = "on";
	
	theContainer.id = "popupContainer";
	theContainer.style.width = hrefWidth + "px";

	theCloseLink.id = "closeLink";	
	theCloseLink.href = "#";
	theCloseLink.onclick = closeThumbnail;
	theCloseLink.title = "Bild schließen";
	theCloseLink.innerHTML = "";
	
	theSpan1.appendChild(theCloseLink);
	theSpan1.style.width = hrefWidth;
	theSpan1.id = "linkContainer";

	theImage.id = "PopupImage";
	theImage.src = hrefSrc;
	theImage.width = hrefWidth;
	theImage.height = hrefHeight;
	theImage.alt = this.title.replace(/View full size /, "");
	theImage.onclick = closeThumbnail;

	theImageCloseLink.id = "closeImage";	
	theImageCloseLink.href = "#";
	theImageCloseLink.onclick = closeThumbnail;
	theImageCloseLink.title = "Bild schließen";
	theImageCloseLink.appendChild(theImage);

	theSpan2.innerHTML = theImage.alt;
	
	theContainer.appendChild(theSpan1);
	theContainer.appendChild(theImageCloseLink);
	theContainer.appendChild(theBreak);
	theContainer.appendChild(theSpan2);
	theCanvasShadow.appendChild(theContainer);

	return false;
}

function closeThumbnail()
{
	var theBody = document.getElementsByTagName("body")[0];
	var theCanvasShadow = document.getElementById("canvasShadow");
	theBody.style.backgroundColor = "#EDEDED";
	theCanvasShadow.className = "";
	return false;
}