var waitFocus;
function deferredFocus(wnd) {
    waitFocus = wnd;
    setTimeout("receiveFocus()", 1000);
}
function receiveFocus() {
    if (waitFocus) {
        waitFocus.focus();
        if (waitFocus.setActive) waitFocus.setActive();
    }
    waitFocus = null;
}
var _showPicture;

function openPicture(name, href, title) {
    if (!title) title = "";
    title = ".::   ::. " + title;
    img = new Image();
    img.src = href;
    img.name = name;
    img.title = title;
    _showPicture = img;
    setTimeout("showPicture('"+name+"')", 100);
}

function showPicture(name) {
    if (!name) name = "_blank";
    img = _showPicture;
    if (!img) return ;
    if (!img.complete) {
        setTimeout("showPicture('"+name+"')", 1000);
        return ;
    }
    href = img.src;

    w = img.width;
    h = img.height;
    title = img.title;
    if (!title) title = ".::   ::.";
    if (!w) {
        w = 600;
    } 
    if (!h) {
        h = 400;
    } 
    if (w > 800) w = 800;
    if (h > 600) h = 600;
    l = 200;
    t = 100;
    try {
        // wnd = open(href, "personImage", "resizable,scrollbars,width="+w+",height="+h+",left="+l+",top"+t);
        //if (window.createPopup) {
        if (false) {
            var p = window.createPopup();
            var b = p.document.body;
            b.style.border = "solid black 1px";
            b.innerHTML = '<img src="'+href+'" border=0 style="margin:0; padding:0">';
            p.show(10, 10, w, h, document.body);
        } else {
            wnd = window.open('', name, "resizable,left="+l+",top"+t+",maximized=no");
            if (!wnd.document.getElementById("image")) {
                wnd.document.write('<html><head><title>kinoros.ru</title></head><body><img id="image" src="'+ href +'" border=0 style="margin:0; padding:0"></body></html>');
            } else {
                wnd.resizeTo(0, 0);
                img = wnd.document.images[0];
                img.src = href;
            }
            wnd.document.title = title;
            wnd.resizeTo(w + 30, h + 60);
            //wnd.document.close();
            deferredFocus(wnd);
        }
    } catch (e) {
        alert(e);
    }
    return false;
}
