function replaceSelectTag(v, disval, indval) {
	
	// 値の指定あり
	if (v) {
		replaceSelectTagHelper(v, document.form1.ind, eval("document.datasource.ind_regi" + v + ".options"), '--身体の症状--');
		document.form1.ind.disabled = false;
		if (indval) {
			var opts = document.form1.ind.options;
			for(var i = 0; i < opts.length; i++) {
				if (opts[i].value == indval) {
					opts[i].selected = true;
					break;
				}
			}
		}
		replaceSelectTagHelper(v, document.form1.dis, eval("document.datasource.dis_regi" + v + ".options"), '--病名・怪我名--');
		document.form1.dis.disabled = false;
		if (disval) {
			var opts = document.form1.dis.options;
			for(var i = 0; i < opts.length; i++) {
				if (opts[i].value == disval) {
					opts[i].selected = true;
					break;
				}
			}
		}
	} else {
		// 初期化
		replaceSelectTagHelper(v, document.form1.ind, null, '--身体の症状--');
		replaceSelectTagHelper(v, document.form1.dis, null, '--病名・怪我名--');
		
		document.form1.ind.disabled = true;
		document.form1.dis.disabled = true;
	}
}
function changeSportsTag(v, spv) {
	if (v.indexOf("sports_group") == 0) {
		if (v.indexOf("sports_group_all") == 0) {
			var options = new Array();
			var count = 0;
			for(var i = 1; i <= 21; i++) {	// スポーツは21グループ
				var opts = eval("document.datasource.sports_group" + i + ".options");
				for(var j = 0; j < opts.length; j++) {
					if (opts[j].value == '') continue;
					options.push(opts[j]);
					count++;
				}
			}
			replaceSelectTagHelper(v, document.form1.spsub, options);
		} else {
			replaceSelectTagHelper(v, document.form1.spsub, eval("document.datasource." + v + ".options"));
		}
		var opts = document.form1.spsub.options;
		for(var i = 0; i < opts.length; i++) {
			if (opts[i].value == spv) {
				opts[i].selected = true;
				break;
			}
		}
		document.form1.spsub.style.display = 'inline';
	} else {
		replaceSelectTagHelper(v, document.form1.spsub);
		document.form1.spsub.style.display = 'none';
	}
}

function replaceSelectTagHelper(v, to, from_opts, default_title) {
    var to_opts = to.options;

    // カラにする
    for (var i = to_opts.length; i >= 0; i--) {
        if (navigator.appName.charAt(0) == "M") {
            to_opts.remove(i);
        } else {
            to.remove(i);
        }
    }
    
    // 生成
    var j = 0;
	if (default_title) {
		var n = document.createElement("OPTION");
		n.value = '';
		n.text = default_title;
	    if (navigator.appName.charAt(0) == "M") {
	        to_opts.add(n, j);
	    } else {
	        to.options[j] = n;
	    }
	    j++;
	}
	if (from_opts) {
	    for (var i = 0; i < from_opts.length; i++) {
	        var n = document.createElement("OPTION");
	        n.value = from_opts[i].value;
	        n.text = from_opts[i].text;
	        if (navigator.appName.charAt(0) == "M") {
	            to_opts.add(n, j);
	        } else {
	            to.options[j] = n;
	        }
			j++;
	    }
    }
}

