    $(document).ready(function(){
        $(".screens ul li a").click(function(){
            img = new Image();
            img.src = this.href;
            var contents = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="pl">'
            contents += '<head><meta http-equiv="Content-type" content="text/html; charset=utf-8" /><title>';
            contents += this.title;
            // get image name without path
            var mystring = img.src;
            var myarray = mystring.split('/');
            var myimg = myarray[myarray.length-1];
            contents += '<\/title><link rel="stylesheet" href="' + webroot + '/themes/default/css/screens.css" type="text/css" /><\/head><body>';
            contents += '<div id="wrapper"><a href="javascript:window.close();"><img id="popupimg" src="' + webroot + '/images/Image/' + myimg + '" alt="' + $(this).find("img").attr("alt") + '" onLoad=mypic(this.id) \/></a><p>' + this.title + '</p><p><a href="javascript:window.close();">Zamknij okno</a></p><\/div>';
            
            contents += '<script> function mypic(id){ var myimg = document.getElementById(id); window.resizeTo(myimg.width+50,myimg.height+150); }</script>';
            contents += '<\/body><\/html>';
            
            popup = window.open('about:blank','popup','location=no,menubar=no,status=no,toolbar=no,width=680,height=440');
            popup.document.open();
            popup.document.write(contents);
            popup.document.close();
            popup.focus();
            return false;
        });
    });
    
    
    function popupLoaded(){
        $(".screens ul li a").click(function(){
            img = new Image();
            img.src = this.href;
            var contents = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="pl">'
            contents += '<head><meta http-equiv="Content-type" content="text/html; charset=utf-8" /><title>';
            contents += this.title;
            // get image name without path
            var mystring = img.src;
            var myarray = mystring.split('/');
            var myimg = myarray[myarray.length-1];
            contents += '<\/title><link rel="stylesheet" href="' + webroot + '/themes/default/css/screens.css" type="text/css" /><\/head><body>';
            contents += '<div id="wrapper"><a href="javascript:window.close();"><img id="popupimg" src="' + webroot + '/images/Image/' + myimg + '" alt="' + $(this).find("img").attr("alt") + '" onLoad=mypic(this.id) \/></a><p>' + this.title + '</p><p><a href="javascript:window.close();">Zamknij okno</a></p><\/div>';
            
            contents += '<script> function mypic(id){ var myimg = document.getElementById(id); window.resizeTo(myimg.width+50,myimg.height+150); }</script>';
            contents += '<\/body><\/html>';
            
            popup = window.open('about:blank','popup','location=no,menubar=no,status=no,toolbar=no,width=680,height=440');
            popup.document.open();
            popup.document.write(contents);
            popup.document.close();
            popup.focus();
            return false;
        });
    }
