// inicializace js fce noveho okna
window.onload = updateAnchors;


  // nastavime "oclassovanym" odkazum js fci
  function updateAnchors(){

    var linksClass = "popup";

    if(!document.getElementsByTagName) return false;
    var links = document.getElementsByTagName("a");

    for (var i=0; i < links.length; i++){

      if(links[i].className.match(linksClass)){

        links[i].onclick = function(){
        showImage(this.href); return false;
        }

      }

    }

  }


  // vytvorime nove okno, vlozime do nej obrazek a zavolame "prizpusobeni"
  function showImage(img){

    var js = "../js/popup.js";
    var settings = "left=100,top=80,width=400,height=250, menubar=no,toolbar=no,location=no,status=yes";
    var css = "*{margin:0; padding:0;} a img{border:0px;} body{background:#ffffff;}"
    var title = "Detail produktu";
    var html = "";

    win = window.open("","a",settings);

    html  = "<html><head><title>"+title+"</title>";
    html += "<style type='text/css'>"+css+"</style>";
    html += "<script type='text/javascript' src='"+js+"'></script></head>";
    html += "<body>";
    html += "<a onclick='window.close()'><img src='"+img+"' onload='fitImage();'></a>";
    html += "</body></html>";

    win.document.write(html);
    win.document.close();

  }


  // prizpusobime velikost okna obrazku
  function fitImage(){

    iWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    iHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    iWidth = document.images[0].width - iWidth;
    iHeight = document.images[0].height - iHeight;

    leftPo = (screen.availWidth - document.images[0].width)/2;
    topPo = (screen.availHeight - document.images[0].height)/2;

    window.resizeBy(iWidth, iHeight);
    window.moveTo(leftPo, topPo);

    self.focus();

  }
