﻿
function SwitchMenu(obj, btn) {
    if (document.getElementById) {
        var el = document.getElementById(obj);
        var ar = document.getElementsByTagName("table");
        if (el.style.display != "block") {
            for (var i = 0; i < ar.length; i++) {
                if (ar[i].className == "detail")
                    ar[i].style.display = "none";
            }
            el.style.display = "block";
            document.getElementById(btn).style.display = "none";
        } else {
            el.style.display = "none";
            document.getElementById(btn).style.display = "block";

        }
    }
}


function expOpen() {
    var element = document.getElementById("expBox");
    element.style.display = "block";
}

function expClose() {
    var element = document.getElementById("expBox");
    element.style.display = "none";
}

function popOpen(url) {
    w = window.open(url, 'win', 'width=595, height=500, menubar=no, toolbar=no, scrollbars=yes');
    w.focus();
}


var fontSizeUnit = "%";
var perOrder = 10;

var defaultSize = 100;

var ckName = "fude_size";
var ckDays = 2;

// クッキーのパス
var ckPath = "/"

var fsCK = GetCookie(ckName);
if (fsCK == null) {
    var currentSize = defaultSize;          //クッキーが無ければ現在の値を初期状態の値に設定
}
else {
    var currentSize = eval(fsCK);          //クッキーがあれば現在の値をクッキーの値に設定
}

/*========== ::: head内にstyle要素を出力 ::: ==========*/
document.writeln('<style type="text/css" media="screen,tv">');
document.write('body{font-size:' + currentSize + fontSizeUnit + '}');
document.writeln('</style>');

/*===================================
[関数 fsc]
引数CMDに渡される値に応じて
変更後の値を算出しクッキーに書き込む。
====================================*/

function fsc(CMD) {
    if (CMD == "larger") {
        var cookie_size = GetCookie(ckName);
        cookie_size = cookie_size - 0;

        if (!cookie_size) {
            cookie_size = currentSize;
        }

        var newSize = Number(cookie_size + perOrder);
        SetCookie(ckName, newSize);
    }
    // 元に戻す：操作後の値を初期値にする
    if (CMD == "default") {
        DeleteCookie(ckName);
        var newSize = defaultSize;
        SetCookie(ckName, newSize);
    }
    document.body.style.fontSize = newSize + fontSizeUnit;
}

/*===================================
[関数 SetCookie]
クッキーに値を書き込む
====================================*/
function SetCookie(name, value) {
    var dobj = new Date();
    dobj.setTime(dobj.getTime() + 24 * 60 * 60 * ckDays * 1000);
    var expiryDate = dobj.toGMTString();
    document.cookie = name + '=' + escape(value) + ';expires=' + expiryDate + ';path=' + ckPath;
}

/*===================================
[関数 GetCookie]
クッキーを取得する
====================================*/
function GetCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

/*===================================
[関数 getCookieVal]
クッキーの値を抽出する
====================================*/
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

/*===================================
[関数 DeleteCookie]
クッキーを削除する
====================================*/
function DeleteCookie(name) {
    if (GetCookie(name)) {
        document.cookie = name + '=' +
    '; expires=Thu, 01-Jan-70 00:00:01 GMT;path=' + ckPath;
    }
}

/*===================================
[関数 checksb]
トップ画面において、入力の必須チェックを行う
====================================*/
function checksb() {
    //var cert = document.serchSite.Certificate.value;
    var cardno = document.form1.cardno1.value + document.form1.cardno2.value + document.form1.cardno3.value + document.form1.cardno4.value;
    var pinno = document.form1.pinno.value;
    var applyno = document.form1.applyno.value;
    if (cardno == null || cardno.length == 0) {
        alert('カード番号を入力してください');
        return false;
    }
    if (pinno == null || pinno.length == 0) {
        alert('PIN番号を入力してください');
        return false;
    }
    /*
    お申込番号は必須ではない
    */
    document.form1.cardno.value = cardno;
    
    var oldloc = location.href;
    var newloc = oldloc;
    newloc = oldloc.replace('http://', 'https://'); // ←SSLがある環境用
    newloc = newloc.replace('Default.aspx', '');
    document.form1.action = newloc + 'form/Default.aspx';
    
    return true;
}
