
/**

 * 画像サイズと合ったポップアップウィンドウを開く関数

 * @param src string ポップアップ表示する画像

 */

function openImageSizedWindow(src){

    // 画像をロードしてサイズを取得

    var i = new Image(); i.src = src;

    // 画像のサイズに合った空ウィンドウを開く

    var pop_win = window.open(

                      "",

                      "_blank",

                      "width="+i.width+",height="+i.height+",scrollbars=no,resizable=yes"

                  );

    // 空ウィンドウに画像を出力するためのHTML

    pop_win.window.document.open();

    pop_win.window.document.write(

     '<html>'

    +'<head><title>'+i.alt+'</title></head>'

    +'<body style="margin:0;padding:0;border:0;">'

    +'<img src="'+i.src+'" width="400" alt="" />'

    +'</body>'

    +'</html>'

    );

    pop_win.window.document.close();

}