// Univezalni skriptik pro otevreni noveho okna s obrazkem.
// Verze 2.6
//  -- pridan parametr iLines do showImage
//     (pokud je nastaven, prepise globalne nastaveny lineCount)       
// Verze 2.5
//  -- pridana promenna lineCount, lineHeight
//     (pocet radku a vyska textu v showImage();)       
// Verze 2.4
//  -- pridana funkce activeThumbMulti()
//     (parametr pro pocet radku popisku a zda zobrazit alt u obrazku)       
// Verze 2.3
//  -- opraveno stanoveni sirky okna pri pridani vertikalniho scrollbaru
// Verze 2.2
//  -- pridana funkce activeThumbLink()
//     (moznost deklarace odkazovaneho obrazku, na rozdil od aT(), kde se predpoklada s "a" na konci jmena)
// Verze 2.1
//  -- pridana funkce activeThumb()
// Verze 2.0, prvni cislovana
// opravy: -- testuje, zda neni okenko vetsi nez monitor a koriguje
//
// Nastav <body onUnload = "if (poc!==0) { iwin.close(); };">
// Zmen iwinTitle
// 
// ( -c- Ivosh: ivo.jancik@winet.cz)

var poc = 0;
var iwinTitle = "Hej, zmen si nastaveni...";
var lineCount = 1;
var lineHeight = 20;

// nejak nefunguje
// window.onUnload = "if (poc!==0) { iwin.close(); };";

function showImage(imgName, imWidth, imHeight, iTitle, iLines)  
    { 
      if (poc!==0) { iwin.close(); }; 

      url = imgName;
      resStr = "resizable=0,scrollbars=0";
                                                             
      if (iLines) { 
        lineNum = iLines;
        } else {
        lineNum = lineCount;
        } 

      // define window oversize
      winPlusWidth = 8;
      winPlusHeight = 30+(iLines-1)*lineHeight;
      // calculate window size
      winHeight = imHeight + winPlusHeight;
      winWidth = imWidth + winPlusWidth;
      // test if the window is not too large
			heightOK = true;
      if (winHeight>screen.availHeight)
        { winHeight = screen.availHeight-80;
      	  resStr=",resizable=1,scrollbars=1";
    			heightOK = false;
      	}
      if (heightOK==false)
        { winWidth = winWidth+22;
      	}								 
      if (winWidth>screen.width)
        { winWidth = screen.width-80;
      	  resStr=",resizable=1,scrollbars=1";
      	}								 

      // calculate centered window position
      winLeft = Math.round((screen.width-winWidth)/2);
      winTop  = Math.round((screen.availHeight-winHeight)/2);

      iwin = window.open("", "", "left="+winLeft+",top="+winTop+",height="+winHeight+",width="+winWidth+",directories=no,location=no,menubar=no,status=no,toolbar=no"+resStr);
      iwin.document.write("<html><head><title>", iwinTitle, "</title>");
      iwin.document.write("<link rel='stylesheet' type='text/css' href='imgwin.css' title='formal'>");
      iwin.document.write("</head>");
      iwin.document.write("<body class=ImgShow>");
      iwin.document.write("<a href='' onClick=\"window.close(); return false;\"><img width=", imWidth," height=", imHeight," src=\"", url, "\" alt='' border=0></a>");
      iwin.document.write("<p>", iTitle);
      iwin.document.write("</body></html>");
      poc++;
      return true;
    }


function showImageMulti(imgName, imWidth, imHeight, iTitle, lineCount)  
    { 
      if (poc!==0) { iwin.close(); }; 

      url = imgName;
      resStr = "resizable=0,scrollbars=0";

      // define window oversize
      winPlusWidth = 8;
      winPlusHeight = 30+(lineCount-1)*lineHeight;
      // calculate window size
      winHeight = imHeight + winPlusHeight;
      winWidth = imWidth + winPlusWidth;
      // test if the window is not too large
			heightOK = true;
      if (winHeight>screen.availHeight)
        { winHeight = screen.availHeight-80;
      	  resStr=",resizable=1,scrollbars=1";
    			heightOK = false;
      	}
      if (heightOK==false)
        { winWidth = winWidth+22;
      	}								 
      if (winWidth>screen.width)
        { winWidth = screen.width-80;
      	  resStr=",resizable=1,scrollbars=1";
      	}								 

      // calculate centered window position
      winLeft = Math.round((screen.width-winWidth)/2);
      winTop  = Math.round((screen.availHeight-winHeight)/2);

      iwin = window.open("", "", "left="+winLeft+",top="+winTop+",height="+winHeight+",width="+winWidth+",directories=no,location=no,menubar=no,status=no,toolbar=no"+resStr);
      iwin.document.write("<html><head><title>", iwinTitle, "</title>");
      iwin.document.write("<link rel='stylesheet' type='text/css' href='imgwin.css' title='formal'>");
      iwin.document.write("</head>");
      iwin.document.write("<body class=ImgShow>");
      iwin.document.write("<a href='' onClick=\"window.close(); return false;\"><img width=", imWidth," height=", imHeight," src=\"", url, "\" alt='' border=0></a>");
      iwin.document.write("<p>", iTitle);
      iwin.document.write("</body></html>");
      poc++;
      return true;
    }

 function activeThumb(cName, cW, cH, cvW, cvH, cAlt)
		 {								 
		  document.write("<a href=\"\" onMouseOver=\"self.status='Klikněte pro zobrazení věšího obrázku...';return true;\" onMouseOut=\"self.status='';return true;\" onClick=\"showImage('", cName, "v.jpg', ", cvW, ", ", cvH, ", '", cAlt,"'); return false;\">");
		  document.write("<img src='", cName, ".jpg' width=", cW ," height=", cH ," alt='", cAlt ,"' border=0></a>");
		 }
 function activeThumbLink(cName, cImgName, cW, cH, cvW, cvH, cAlt)
		 {								 
		  document.write("<a href=\"\" onMouseOver=\"self.status='';return true;\" onMouseOut=\"self.status='';return true;\" onClick=\"showImage('", cImgName, ".jpg', ", cvW, ", ", cvH, ", '", cAlt,"'); return false;\">");
		  document.write("<img src='", cName, ".jpg' width=", cW ," height=", cH ," alt='", cAlt ,"' border=0></a>");
		 }		 

 function activeThumbMulti(cName, cW, cH, cvW, cvH, cAlt, cLines, cAltOn)
		 {								                                                  
      if (cAltOn==0) 
        { imgAlt = ''; }
      else  
        { imgAlt = cAlt; };
		  document.write("<a href=\"\" onMouseOver=\"self.status='Klikněte pro zobrazení věšího obrázku...';return true;\" onMouseOut=\"self.status='';return true;\" onClick=\"showImageMulti('", cName, "v.jpg', ", cvW, ", ", cvH, ", '", cAlt,"', ", cLines,"); return false;\">");
		  document.write("<img src='", cName, ".jpg' width=", cW ," height=", cH ," alt='", imgAlt ,"' border=0></a>");
		 }
     

     