//
function doUpdate(action, name) {
    //
    var form = document.input;
    if (form == null) {
        return;
    }
    //
    if (!confirm(
        name + "を保存します。\n"
        + "よろしいですか？")) {
        return;
    }
    //
    form.operation.value = "update";
    //
    form.elements[action].value = "true";
    //
    form.submit();
}
//
function doDelete(action, name) {
    //
    var form = document.input;
    if (form == null) {
        return;
    }
    //
    if (!confirm(
        name + "を削除します。\n"
        + "よろしいですか？")) {
        return;
    }
    //
    form.operation.value = "delete";
    //
    form.elements[action].value = "true";
    //
    form.submit();
}
//
function doInitPwd() {
    //
    var form = document.input;
    if (form == null) {
        return;
    }
    //
    if (!confirm(
        "パスワードを初期化します。\n"
        + "よろしいですか？")) {
        return;
    }
    //
    form.action_user_initPwd.value = "true";
    //
    form.submit();
}
//
function doUpdateList(id, action, name) {
    var list = document.getElementById(id);
    var form = document.input;
    if (list == null || form == null) {
        return;
    }
    //
    if (!confirm(
       name + "を保存します。\n"
        + "よろしいですか？")) {
        return;
    }
    //
    form.operation.value = "update";
    //
    for (var i = 0; i < list.length; i++) {
        list.item(i).selected = true;
    }
    //
    form.elements[action].value = "true";
    //
    form.submit();
}
//
function doUpdateList2(id,id2, action, name) {
    var list = document.getElementById(id);
    var list2 = document.getElementById(id2);
    var form = document.input;
    if (list == null || list2 == null || form == null) {
        return;
    }
    //
    if (!confirm(
       name + "を保存します。\n"
        + "よろしいですか？")) {
        return;
    }
    //
    form.operation.value = "update";
    //
    for (var i = 0; i < list.length; i++) {
        list.item(i).selected = true;
    }
    //
    for (var i = 0; i < list2.length; i++) {
        list2.item(i).selected = true;
    }
    //
    form.elements[action].value = "true";
    //
    form.submit();
}

function changeApps() {
    var system = document.getElementById("newsystem");
    var type = document.getElementById("type");

    var current;
    for (var i = 0; i < system.length; i++) {
        if (system[i].selected) {
            current = system[i].value;
            break;
        }
    }

    for (var i = type.length - 1; i > 0; i--) {
        type.remove(i);
    }

    var sso_apps;
    if (current == 'agent') {
        sso_apps = agent_apps;
    } else {
        sso_apps = proxy_apps;
    }

    for (var i = 0; i < sso_apps.length; i++) {
        var opt = document.createElement("OPTION");
        opt.value = sso_apps[i][0];
        opt.text = sso_apps[i][1];
        type.add(opt);
    }
}
