/**
 * 標準幅指定ウィンドウオープン処理(infobox標準横幅指定。縦幅指定なし。メニュー、ツールバーなし。)
 * @returns false
 */
function openStandardWindow(path) {
    window.open(path, '_blank', 'width=1100, toolbar=no, menubar=no,location=yes, status=yes, resizable=yes, scrollbars=yes');
    return false;
}
/**
 * 外部サイトオープン処理(縦横幅指定なし。メニュー、ツールバーあり。)
 * @returns false
 */
function openExternalWindow(path) {
    window.open(path, '_blank', 'toolbar=yes, menubar=yes, location=yes, status=yes, resizable=yes, scrollbars=yes');
    return false;
}

/**
 * 添付文書オープン処理
 * @param packagePath 添付文書のパス
 * @param titleText タイトル
 * @returns false
 */
function openPackageWindow(packagePath, titleText){
    var childWindow = window.open(packagePath, '_blank', 'width=780, height=600, toolbar=no, menubar=no, location=yes, status=yes, resizable=yes, scrollbars=yes');

    // 対象ウィンドウのロード後にタイトルを設定する
    addLoadEvent(childWindow, function() {
        childWindow.document.title = titleText;
    });

    return false;
}

/**
 * 対象ウィンドウのロード後に実行する関数を登録する
 * 
 * @param targetWindow ロード対象ウィンドウ
 * @param func 対象ウィンドウのロード後に実行する関数
 * @returns true:関数を登録できた場合/false:関数を登録できなかった場合
 */
function addLoadEvent(targetWindow, func) {
    if(typeof targetWindow.addEventListener == 'function'){
        targetWindow.addEventListener('load', func, false);
        return true;
    } else if(typeof targetWindow.attachEvent == 'object'){
        targetWindow.attachEvent('onload', func);
        return true;
    }

    var oldonload = targetWindow.onload;
    if (typeof targetWindow.onload != 'function') {
        targetWindow.onload = func;
        return true;
    } else {
        targetWindow.onload = function() {
            oldonload();
            func();
        }
        return true;
    }
}

/**
 * IEかどうか判定する
 * @returns true:IEの場合/false:IEでない場合
 */
function isIe(){
    return window.navigator.userAgent.toUpperCase().indexOf("MSIE") > -1;
}

/**
 * Firefoxかどうか判定する
 * @returns true:Firefoxの場合/false:Firefoxでない場合
 */
function isFirefox(){
    return window.navigator.userAgent.toUpperCase().indexOf("FIREFOX") > -1;
}

/**
 * Safariかどうか判定する
 * @returns true:Safariの場合/false:Safariでない場合
 */
function isSafari(){
    var agent = navigator.userAgent.toUpperCase();
    return agent.indexOf("SAFARI") >= 0;
}
/**
 * ウィンドウクローズ処理
 */
function closeWindow() {
    if(isSafari()){
        // サファリ用
        window.opener = window;
        var win = window.open( location.href, "_self" );
        win.close();
    } else {
        // 確認ウィンドウ防止
        window.opener = null;
        window.close();
    }
}

function postParams(form, action) {
    form.action = action;
    form.method = "POST";
    form.submit();
}
