﻿// 詳細画面用のJScriptファイル

document.write('<script type="text/javascript" src="./js/Common.js"></script>');

formLoad();

// -- 起動時用 -------
function formLoad() {
    
    // --印刷ボタンの制御
    /*
    if(document.getElementById("btnPrint") != null){
        ua = navigator.userAgent;
        if(ua.indexOf("MSIE") != -1){
            document.getElementById("btnPrint").style.display = "inline";
            document.getElementById("btnPrint").style.visibility = "visible";
        }else{
            document.getElementById("btnPrint").style.display = "none";
            document.getElementById("btnPrint").style.visibility = "hidden";
        }  
    }  */

    // --初期表示タブの制御
    if(document.getElementById("Tab_Tabstock") != null){
        switch (document.getElementById("hidTabIndex").value) {
            case "0": { TabSelect('Tab_Tabce_tabHce'); break; }
            case "1": { TabSelect('Tab_Tabop_tabHop'); break; }
            case "2": { TabSelect('Tab_Tabap_tabHap'); break; }
            case "9": { break; }
            default : { TabSelect('Tab_Tabstock_tabHstock'); break; }
        }
    }
}

// -- 印刷用 ------------
/*
function PrintPreview()
{
    // プレビュー表示
    if(window.ActiveXObject == null || document.body.insertAdjacentHTML == null) return;
    var sWebBrowserCode = '<object width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>'; 
    document.body.insertAdjacentHTML('beforeEnd', sWebBrowserCode); 
    var objWebBrowser = document.body.lastChild;
    if(objWebBrowser == null) return;
    objWebBrowser.ExecWB(7, 1);
    document.body.removeChild(objWebBrowser);
}*/

// -- TabCe指定用 -------
function setCeTab(){
    if(document.getElementById("Tab_Tabstock") != null){
        document.getElementById("Tab_Tabstock").style.display = "none";
        document.getElementById("Tab_Tabstock").style.visibility = "hidden";
    }
    if(document.getElementById("Tab_Tabop") != null){
        document.getElementById("Tab_Tabop").style.display = "none";
        document.getElementById("Tab_Tabop").style.visibility = "hidden";
    }
    if(document.getElementById("Tab_Tabap") != null){
        document.getElementById("Tab_Tabap").style.display = "none";
        document.getElementById("Tab_Tabap").style.visibility = "hidden";
    }
    if(document.getElementById("Tab_Tabdown") != null){
        document.getElementById("Tab_Tabdown").style.display = "none";
        document.getElementById("Tab_Tabdown").style.visibility = "hidden";
    }
    if(document.getElementById("Tab_Tabfaq") != null){
        document.getElementById("Tab_Tabfaq").style.display = "none";
        document.getElementById("Tab_Tabfaq").style.visibility = "hidden";
    }
    if(document.getElementById("Tab_Tabinfo") != null){
        document.getElementById("Tab_Tabinfo").style.display = "none";
        document.getElementById("Tab_Tabinfo").style.visibility = "hidden";
    }

    if(document.getElementById("Tab_Tabce") != null){
        document.getElementById("Tab_Tabce").style.display = "inline";
        document.getElementById("Tab_Tabce").style.visibility = "visible";
        TabSelect('Tab_Tabce_tabHce');
    }

    location.hash = "#tab_aria"; 
 }

// -- Tab選択時のIMGファイルを設定 -------
function TabSelect(selobj) {
   
    // -- 表示されているタブ全てをOFF設定にする
    if(document.getElementById("Tab_Tabstock_imgTabStackOn") != null){
        document.getElementById("Tab_Tabstock_imgTabStackOn").style.display = "none";
        document.getElementById("Tab_Tabstock_imgTabStackOff").style.display = "inline";
    }
    if(document.getElementById("Tab_Tabce_imgTabCeOn") != null){
        document.getElementById("Tab_Tabce_imgTabCeOn").style.display = "none";
        document.getElementById("Tab_Tabce_imgTabCeOff").style.display = "inline";
    }
    if(document.getElementById("Tab_Tabop_imgTabOpOn") != null){
        document.getElementById("Tab_Tabop_imgTabOpOn").style.display = "none";
        document.getElementById("Tab_Tabop_imgTabOpOff").style.display = "inline";
    }
    if(document.getElementById("Tab_Tabap_imgTabApOn") != null){
        document.getElementById("Tab_Tabap_imgTabApOn").style.display = "none";
        document.getElementById("Tab_Tabap_imgTabApOff").style.display = "inline";
    }
    if(document.getElementById("Tab_Tabdown_imgTabDownOn")){
        document.getElementById("Tab_Tabdown_imgTabDownOn").style.display = "none";
        document.getElementById("Tab_Tabdown_imgTabDownOff").style.display = "inline";
    }
    if(document.getElementById("Tab_Tabfaq_imgTabFaqOn") != null){
        document.getElementById("Tab_Tabfaq_imgTabFaqOn").style.display = "none";
        document.getElementById("Tab_Tabfaq_imgTabFaqOff").style.display = "inline";
    }
    if(document.getElementById("Tab_Tabinfo_imgTabInfoOn") != null){
        document.getElementById("Tab_Tabinfo_imgTabInfoOn").style.display = "none";
        document.getElementById("Tab_Tabinfo_imgTabInfoOff").style.display = "inline";
    }

    // -- 選択されたタブをON設定にする
    if (selobj == "Tab_Tabstock_tabHstock" &&
        document.getElementById("Tab_Tabstock_imgTabStackOn") != null ) {
        document.getElementById("Tab_Tabstock_imgTabStackOn").style.display = "inline";
        document.getElementById("Tab_Tabstock_imgTabStackOff").style.display = "none";
    }

    if (selobj == "Tab_Tabce_tabHce" &&
        document.getElementById("Tab_Tabce_imgTabCeOn") != null ) {
        document.getElementById("Tab_Tabce_imgTabCeOn").style.display = "inline";
        document.getElementById("Tab_Tabce_imgTabCeOff").style.display = "none";
    }

    if (selobj == "Tab_Tabop_tabHop" &&
        document.getElementById("Tab_Tabop_imgTabOpOn") != null ) {
        document.getElementById("Tab_Tabop_imgTabOpOn").style.display = "inline";
        document.getElementById("Tab_Tabop_imgTabOpOff").style.display = "none";
    }

    if (selobj == "Tab_Tabap_tabHap" &&
        document.getElementById("Tab_Tabap_imgTabApOn") != null ) {
        document.getElementById("Tab_Tabap_imgTabApOn").style.display = "inline";
        document.getElementById("Tab_Tabap_imgTabApOff").style.display = "none";
    }
    
    if (selobj == "Tab_Tabdown_tabHdown" &&
        document.getElementById("Tab_Tabdown_imgTabDownOn") != null ) {
        document.getElementById("Tab_Tabdown_imgTabDownOn").style.display = "inline";
        document.getElementById("Tab_Tabdown_imgTabDownOff").style.display = "none";
    }

    if (selobj == "Tab_Tabfaq_tabHfaq" &&
        document.getElementById("Tab_Tabfaq_imgTabFaqOn") != null ) {
        document.getElementById("Tab_Tabfaq_imgTabFaqOn").style.display = "inline";
        document.getElementById("Tab_Tabfaq_imgTabFaqOff").style.display = "none";
    }

    if (selobj == "Tab_Tabinfo_tabHinfo" &&
        document.getElementById("Tab_Tabinfo_imgTabInfoOn") != null ) {
        document.getElementById("Tab_Tabinfo_imgTabInfoOn").style.display = "inline";
        document.getElementById("Tab_Tabinfo_imgTabInfoOff").style.display = "none";
    }
    
    // -- 代替品タブは「function setCeTab()」で強制的に表示させているケースがあるので
    // -- 代替品タブ以外が選択された場合は、明示的に非表示を設定する
    if (selobj != "Tab_Tabce_tabHce" &&
        document.getElementById("Tab_Tabce") != null ){
        document.getElementById("Tab_Tabce").style.display = "none";
        document.getElementById("Tab_Tabce").style.visibility = "hidden";
    }

}

// -- 自画面遷移用 -------
function postDetailpage(url) {
     doPost("frmHeader", url);
}

