   function popupPictureAuto(pictPath)
/* 
   30-aug-2005 / Karel Altmann
   see also Auto-Resizable-Pop-Up in http://javascript.internet.com/
   javaScript for automatic sized popup pictures.jpg
   do not use blanks or special character in picture file name
   14-sep-2007
   show whole picture within the screen in correct dimensions
   14-jan-2008
   filename pattern   min|dot|sla   will be replaced in 
   picture title by   "-"|"."|"/"
   19-aug-2008
   check/resize picture, position in the middle of the screen 
   01-nov-2009 / code review
*/
{
   pict     = new Image();
   pict.src = (pictPath);
   checkPicture(pictPath);
}

   function checkPicture(pictPath)
{
   if ((pict.width!=0) && (pict.height!=0))
   {
      showPicture(pictPath);
   }
   else
   {
      rekursiv = "checkPicture('"+pictPath+"')";
      interval = setTimeout(rekursiv,50);
   }
}

   function showPicture(pictPath)
{
   altText  = "bild mit klick schliessen";
   pictTitl = "";
   for (var i=pict.src.length ; i>=0 ; i--)
   {
       if (pict.src.substring(i-1,i) == "/")
       {
          pictTitl = pict.src.slice(i,pict.src.length-4);
          break;
       }
   }
   pictW = pict.width;             // set picture size & position
   pictH = pict.height;
   pictL = (screen.width  - pictW) / 2;
   pictT = (screen.height - pictH) / 2;
   while (pictL < 50 || pictT < 70) 
   {     if (pictL < 50) 
         {  pictW = screen.width-130;
            pictH = pictW * (pict.height / pict.width);
         }
         if (pictT < 70) 
         {  pictH = screen.height-160;
            pictW = pictH * (pict.width / pict.height);
         } 
         pictL = (screen.width  - pictW) / 2;
         pictT = (screen.height - pictH) / 2;
   }

   pictT = parseInt(pictT);
   pictL = parseInt(pictL);
   pictW = parseInt(pictW);
   pictH = parseInt(pictH);
   pictStrg = "width="+pictW+",height="+pictH+",left="+pictL+",top="+pictT;
// altText  = "pictPath="+pictPath+" "+pictStrg ;                  // check size
// altText  = altText+",screen="+screen.width+"/"+screen.height ;  // check size
   pictStrg = pictStrg+",resizable=yes";

   Popup = window.open(pictPath,pictTitl,pictStrg);
   Prog  = Popup.document;
       pictTitl = pictTitl.replace(/min/g,"&#45;");   // minus key "-"
       pictTitl = pictTitl.replace(/dot/g,"&#46;");   // dot key   "."
       pictTitl = pictTitl.replace(/sla/g,"&#47;");   // slash key "/"
       pictTitl = pictTitl.replace(/_/g," ");
   var Input  = '<HTML><HEAD>                         \n'
       Input += '<TITLE>' + pictTitl + '</TITLE>      \n'
       Input += '</HEAD>                              \n'
       Input += '<BODY BGCOLOR="#FFB546"              \n'
       Input += ' leftmargin="0" topmargin="0">       \n'
       Input += '<A HREF="" onClick="self.close()">   \n'
       Input += '<IMG BORDER="0" SRC=' +pictPath+ '   \n'
       Input += ' WIDTH=' +pictW+ ' HEIGHT=' +pictH+ '\n'
       Input += ' ALT="'+altText+'"></A>              \n'
       Input += '</BODY></HTML>'
   Prog.open();
   Prog.clear();
   Prog.write(Input);
   Prog.close();
   Popup.focus();
}



