﻿/* Javascript AutoSizePopup */
function autoSizePopup(img, title) 
{
    image1 = new Image();
    image1.src = (img);
    title1 = new String;
    title1 = title;
    control(img);
}

function control(img) 
{
    if ((image1.width != 0) && (image1.height != 0)) 
    {
        viewImage(img);
    }
    else 
    {
        func = "control('" + img + "')";
        interval = setTimeout(func, 20);
    }
}

function viewImage(img) 
{
    width = image1.width + 20;
    height = image1.height + 20;
    var left = (screen.width / 2) - (width / 2);
    var top = (screen.height / 2) - (height / 2);
    str = "width=" + width + ", height=" + height + ", top=" + top + ", left=" + left;
    win = window.open(img, "", str);
    win.document.write('<html><head><title>' + title1 + '</title>');
    win.document.write('<link rel="stylesheet" href="App_Themes/Theme/popup.css">');
    win.document.write('</head><body>');
    win.document.write('<div class="wrapper"><div class="title">' + title1 + '</div><div class="image"><img src="' + img + '" /></div></div>')
    win.document.write('</body></html>');
    win.document.close();
}
