<!--
/* ====================================================================================== * 
 * Project : JavaScript 関数ライブラリ
 * File    : funclib.js
 * Author  : System House ACT
 * History : 1.00.00 初版 ($Rev: 11 $)
 *           $Date:: 2008-12-28 18:26:43 #$ $Author: tyamaguchi $
 *
 * openImageWindow(src, title) ... 画像を別ウィンドウで開く
 * 
 * Copyright 2009 System House ACT All rights reserved.
 * ====================================================================================== *
 */  
/* ====================================================================================== *
 * 画像を別ウィンドウで開く
 *   引数 : src ..... 画像ファイルのURI
 *          title ... 画像ファイルのタイトル
 *   戻値 : なし
 * ====================================================================================== *
 */
function openImageWindow(src, title) {
  var img = new Image();

  // タイトルが省略された場合は、画像ファイルのURIのファイル名を設定する
  var file;
  if (title == undefined) {
    file = src.substring(src.lastIndexOf("/") + 1, src.length);
  } else {
    file = title;
  }

  // 画像のonloadハンドラを定義する
  img.onload = function() {
    var popup = window.open(
                  img.src,
                  "popup",
                  "width=" + img.width + ", height=" + img.height
              + ", scrollbars=no, resizable=yes"
                  );
    if (popup) {
      // ポップアップウィンドウが開けた場合は画像を表示する
      popup.window.document.open();
      popup.window.document.write(
        '<html>'
      + '<head><title>' + file + '</title></head>'
      + '<body style="margin:0; padding:0; border:0;">'
      + '<img src="' + img.src + '" width="100%" alt="' + file + '" />'
      + '</body>'
      + '</html>'
        );
      popup.window.document.close();
    } else {
      // ポップアップウィンドウがブロックされた場合は画像へ遷移する
      location.href = img.src;
    }
    // ポップアップループを抑止する
    img.onload = function(){};
  }
  img.src = src;
}

//-->