﻿var isSubmit = 0;

/** カンマ編集 */
function addComma(s){
    var destStr = s;
    var tmpStr = '';

    while (destStr != (tmpStr = destStr.replace(/^([+-]?\d+)(\d\d\d)/,"$1,$2"))) {
        destStr = tmpStr;
    }

    return destStr;
}

/* ダブルクリック対応 */
function IsCheckWClick()
{
	if (window.document.readyState != null && window.document.readyState != 'complete'){
		alert("処理中です。");
		return false;
	} else {
		return true;
	}
}

//フォーカス用
function setFocusByName(name){
    var obj = document.forms[0].elements[name];
    if(obj == undefined || obj.disabled) return false;
    
	obj.focus();
    
    if(obj.type == 'text' || obj.type == 'textarea') obj.select();
    
    return true;
}


//　表示・非表示切り替えスクリプト
function displayExtended(ID)
{
	ID = document.getElementById(ID).style;
	if (ID.display == 'none') ID.display = "block";
	else ID.display = "none";
}


/**
 * Radio ボタンで check されている値を取得する。
 */
function getRadioValue(name){

    var ctrls = document.forms[0].elements;

    if(ctrls[name] == undefined) return "";

    if(ctrls[name].length == undefined){
        //radio1つ
        if(ctrls[name].checked) return ctrls[name].value;
    }else{
        for(var i = 0; i < ctrls[name].length; i++){
            if(ctrls[name][i].checked) return ctrls[name][i].value;
        }
    }    
    
    return "";
}


//== SHO2020 =====================================================================
function sho2020_dispKessai(radioBtnListId){
    
    var radio0 = document.getElementById(radioBtnListId + '_0');
    if(radio0 == undefined) return;
    
    var checkedValue = getRadioValue(radio0.name);
    
    sho2020_dispKessaiSection('1', checkedValue);
    sho2020_dispKessaiSection('2', checkedValue);
    sho2020_dispKessaiSection('3', checkedValue);
    
}

function sho2020_dispKessaiSection(targetSection, selectedSection){
    var section = document.getElementById('PAID_SECTION_' + targetSection);
    if(section == undefined) return;
    
    if(targetSection == selectedSection){
        section.style.display = '';
    }else{
        section.style.display = 'none';
    }
}
//== SHO2020 =====================================================================

//== MAN2900 =====================================================================
/* 画面出力実行 */
function execute(textSQLID, valSQLID){
    
    var textSQL = document.getElementById(textSQLID);
    var valSQL = document.getElementById(valSQLID);

    if(textSQL.value == ''){
        alert('SQLを入力して下さい');
        return;
    }
    if(valSQL.style.display != 'none') return

    var fm = document.forms[0]; 
    
    var saveAction = fm.action;
    var saveTarget = fm.target;
    fm.action='./MAN2901.aspx'; 
    fm.target='result';
    fm.submit();
    fm.action=saveAction; 
    fm.target=saveTarget;
    
}

/* CSV出力実行 */
function executeCSV(textSQLID, valSQLID, textCSVID, valCSVID){

    var textSQL = document.getElementById(textSQLID);
    var valSQL = document.getElementById(valSQLID);
    var textCSV = document.getElementById(textCSVID);
    var valCSV = document.getElementById(valCSVID);

    if(textSQL.value == ''){
        alert('SQLを入力して下さい');
        return;
    }

    if(textCSV.value == ''){
        alert('出力ファイル名を入力して下さい');
        return;
    }

    if(valSQL.style.display != 'none'|| valCSV.style.display != 'none') return


    var fm = document.forms[0]; 
    var saveAction = fm.action;
    var saveTarget = fm.target;
    fm.action='./F.ashx'; 
    fm.target='dummyFrame';
    fm.submit();
    fm.action=saveAction; 
    fm.target=saveTarget;
}


//== MAN2900 =====================================================================