
$(function(){
	//こだわり条件のブロックごとに下線を引く
	var blockContainers = $("#otherConditions ul");
	if (blockContainers) {
		blockContainers.each(function(index){
			if (blockContainers.size() > (index + 1)) {
				$(this).attr("class", "c1");
			}
		});
	}
	
	selectedParentAreaCheckBox();
});

//子エリアが全て選択されていたら親エリアのチェックボックスをＯＮにする
function selectedParentAreaCheckBox() {
	$('.areaGroup').each(function() {
		var childChecked = $('.childGroup input[@checked]', this);
		var childCheckbox = $('.childGroup input[@type=checkbox]', this);
		if (childChecked.size() == childCheckbox.size()) {
			$('.parentSelect', this).attr('checked', true);
		}
	});
}

//親エリアのチェックボックス選択時のイベント
function checkParentAreaEvent(index) {
	if ($('#parentSelect' + index).attr('checked')) {
		$('.childSelect' + index).attr('checked', true);
	} else {
		$('.childSelect' + index).attr('checked', false);
	}
}

//子エリアのチェックボックス選択時のイベント
function checkChildAreaEvent(index) {
	$('#parentSelect' + index).attr('checked', isAllChildAreaSelected(index));
}

//子エリアのチェックボックスが全て選択されているか判定
function isAllChildAreaSelected(index) {
	var allCheckFlag = true;
	$('.childSelect' + index).each(function() {
		if (!this.checked) {
			allCheckFlag = false;
		}
	});
	return allCheckFlag;
}

