/* ************************************************

	東急コミュニティ 賃貸・売買パートナー
	search-detail.js
	要jQuery.js ver.1.3.2 以上
	
************************************************* */


/* ---------------------------------------------------
	地域別の表示／非表示
------------------------------------------------------ */

$(function(){
		   
	$('#search-box > div:not([class="SEARCH"])').hide();
	
	$('#search-box .KANTO').show();
	
	$('#area-nav > li > a').click(
							  
		function(){
			
			$('#search-box > div:not([class="SEARCH"])').hide();
			
			var areaID = $(this).parent().attr('id');
			//alert(areaID);
			switch(areaID){
				
				case 'nav_HOKKAIDO' : $('.HOKKAIDO').show();
				break;
				case 'nav_TOHOKU' : $('.TOHOKU').show();
				break;
				case 'nav_KANTO' : $('.KANTO').show();
				break;
				case 'nav_TOKAI' : $('.TOKAI').show();
				break;
				case 'nav_KANSAI' : $('.KANSAI').show();
				break;
				case 'nav_CYUGOKU' : $('.CYUGOKU').show();
				break;
				case 'nav_KYUSYU' : $('.KYUSYU').show();
				break;
				
				default: $('#search-box > div').show();
			}
		}
	);

});

/*

$(function(){
		   
	$('#search-box > div:not([class="SEARCH"])').hide();
	
	$('#search-box .KANTO').show();
	
	$('#area-nav > li').click(
							  
		function(){
			
			$('#search-box > div:not([class="SEARCH"])').hide();
			
			var areaID = $(this).attr('id');
			//alert(areaID);
			switch(areaID){
				
				case 'nav_HOKKAIDO' : $('.HOKKAIDO').show();
				break;
				case 'nav_TOHOKU' : $('.TOHOKU').show();
				break;
				case 'nav_KANTO' : $('.KANTO').show();
				break;
				case 'nav_TOKAI' : $('.TOKAI').show();
				break;
				case 'nav_KANSAI' : $('.KANSAI').show();
				break;
				case 'nav_CYUGOKU' : $('.CYUGOKU').show();
				break;
				case 'nav_KYUSYU' : $('.KYUSYU').show();
				break;
				
				default: ;
			}
		}
	);

});
*/


/* ---------------------------------------------------
	検索フォームの詳細表示／非表示
------------------------------------------------------ */

$(function(){
	
	//$('.area-detail').hide();
	
	// クラス名「openbox」をarea-detailのdivに追加すると、デフォルトがオープン
	$('.openbox').show();
	$('.openbox').parent().find('.open-detail').css("backgroundPositionY","bottom");
	$('.openbox').parent().find('.open-detail').css("backgroundPosition","left bottom");
	
	$('.open-detail').toggle(
		function(){
			var a = $(this).parent().parent().find('.area-detail').attr('class');
			//alert(a);
			if(a == 'area-detail clearfix openbox'){
				var btnIndex = $('.open-detail').index(this);
				$('.area-detail').eq(btnIndex).hide();
				$(this).css("backgroundPositionY","top");
				$(this).css("backgroundPosition","left top");
			}else{
				var btnIndex = $('.open-detail').index(this);
				//alert(btnIndex);
				$('.area-detail').eq(btnIndex).show();
				$(this).css("backgroundPositionY","bottom");
				$(this).css("backgroundPosition","left bottom");
			}
		},
		function(){
			var a = $(this).parent().parent().find('.area-detail').attr('class');
			//alert(a);
			if(a == 'area-detail clearfix openbox'){
				var btnIndex = $('.open-detail').index(this);
				//alert(btnIndex);
				$('.area-detail').eq(btnIndex).show();
				$(this).css("backgroundPositionY","bottom");
				$(this).css("backgroundPosition","left bottom");
			}else{
				var btnIndex = $('.open-detail').index(this);
				$('.area-detail').eq(btnIndex).hide();
				$(this).css("backgroundPositionY","top");
				$(this).css("backgroundPosition","left top");
			}
		}
	);
});

/* ---------------------------------------------------
	検索フォームの詳細の体裁揃え
------------------------------------------------------ */

$(function(){
	
	$('.area-detail span:nth-child(4n)').addClass('last');
	$('.area-detail span:nth-child(4n)').after('<div class="clr"></div>');
	
});

/*
$(function(){
	
	$('.area-detail > span:nth-child(4n)').addClass('last');
	$('.area-detail > span:nth-child(4n)').after('<div class="clr"></div>');
	
});
*/


/* ---------------------------------------------------
	チェックボックスのまとめチェック
------------------------------------------------------ */

$(function(){
		   
	var check = false;
	
	// まとめて選択
	$(".all-ch").click(function(){
			if($(this).attr('checked')==true){
				$(this).parent().parent().next().find('.ch').attr("checked","checked");
			}else{
				$(this).parent().parent().next().find('.ch').removeAttr("checked");
			}
	});
	
	
	// まとめたあと、個別にチェックはずすと、まとめてチェックのチェックがはずれる
	$(".ch").click(function(){
		//check = false;
		//alert(check);
		var CH = $(this).parent().parent().parent().find('.all-ch');
		
		if(CH.attr("checked") == true){
		CH.removeAttr("checked");
			//check = true;
		}
	});
		   
});


/* ---------------------------------------------------
	チェックボックス無効化
------------------------------------------------------ */

$(function(){
	$('.area-detail > span > .no_ch').attr('disabled','disabled');
	$('.area-detail > span > .no_ch').parent().css("color","#999");
});
