
function editSubject(sid) {
	var targetId = getById('edit_sid');
	var targetName = getById('edit_name');
	targetId.value = sid;
	targetName.value = subs[sid].name;
	if(subs[sid].usable == '1') {
		getById('edit_usable_1').checked = true;
	} else {
		getById('edit_usable_0').checked = true;
	}
	undisplayAdd();
	displayEdit();
}

function submitEdit() {
	var targetName = getById('edit_name');
	var targetForm = getById('edit_form');
	if(targetName.value.length < 1) {
		alert("科目名を入力してください。");
	} else {
		targetForm.submit();
	}
}

function deleteSubject(sid) {
	if(confirm("削除してよろしいですか？")) {
		var targetId = getById('del_sid');
		targetId.value = sid;
		var targetForm = getById('del_form');
		targetForm.submit();
	}
}

function submitAdd() {
	var targetName = getById('add_name');
	var targetForm = getById('add_form');
	if(targetName.value.length < 1) {
		alert("科目名を入力してください。");
	} else {
		targetForm.submit();
	}
}


function displayAdd() {
	changeDisplay('sub_edit_expand', 'none');
	changeDisplay('sub_add_collapse', 'none');
	changeDisplay('sub_add_expand', 'block');
}

function undisplayAdd() {
	changeDisplay('sub_add_collapse', 'block');
	changeDisplay('sub_add_expand', 'none');
}

function displayEdit() {
	changeDisplay('sub_add_expand', 'none');
	changeDisplay('sub_add_collapse', 'block');
	changeDisplay('sub_edit_expand', 'block');
}

function undisplayEdit() {
	changeDisplay('sub_add_expand', 'none');
	changeDisplay('sub_add_collapse', 'block');
	changeDisplay('sub_edit_expand', 'none');
}

function fadeCategory() {
	var target = getById('sub_list_1');
	target.className = 'fade';
	readyToFade();
}

