var b_id = {}; // 配列を初期化
var wd;


$(function(){


	/*$('#search-box input:checkbox').click(function(){
		if(this.checked){
			$(this).parent().addClass('checked');
		}else{
			$(this).parent().removeClass('checked');
		}
	});*/

	/*$('#search-box input:radio').click(function(){
		$('#search-box input:radio').parent().removeClass('checked');
		$(this).parent().addClass('checked');

	});*/

	$('#c_all').click(function(){
		if(this.checked){
			$('input.eki').attr('checked','checked');
		}else{
			$('input.eki').removeAttr('checked');
		}
	});


	$('#b_all, #b_all2').click(function(){
		if(this.checked){
			$('input.inq').attr('checked','checked');
			$('#b_all').attr('checked','checked');
			$('#b_all2').attr('checked','checked');
		}else{
			$('input.inq').removeAttr('checked');
			$('#b_all').removeAttr('checked');
			$('#b_all2').removeAttr('checked');
		}
	});

	

	/*$("#search_more").click(function(){
		if ($(this).is(".search_show")){
			$(this).removeClass("search_show");
			$(this).addClass("search_hide");
			$(this).text("詳細な条件を閉じる");
			$("#setubi_box").show();
		}else{
			$(this).removeClass("search_hide");
			$(this).addClass("search_show");
			$(this).text("もっと詳細な条件を設定する");
			$("#setubi_box").hide();
		}
	});*/


});


function kouho_wd(){
	wd = '<div id="kouho_box">';
	wd += '<p>候補ワード<span>(クリックできます。)</span></p>';
	wd += '<p class="fwd_k_wd">江坂</p>';
	wd += '<p class="fwd_k_wd">分譲</p>';
	wd += '<p class="fwd_k_wd">新築</p>';
	wd += '<p class="fwd_k_wd">駐車場</p>';
	wd += '<p class="fwd_k_wd">ペット</p>';
	wd += '<p class="fwd_k_wd">緑地公園</p>';
	wd += '</div>';
	wd += '<div id="reset_box">';
	wd += '<img src="../common/img/2011/s_reset.jpg" alt="×" />';
	wd += '</div>';
	return wd;
}
function kouho_sel(){
	alert($(this).text());
	$('#search-box input:text.free').val($(this).text());
}

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}


//*************************************************
//**** 検索条件取得 *******************************
//*************************************************
function search_add(){

	var url_condision = "";

	//フリーワード
	/*if($("input.free").val().length > 0){
		url_condision += "/fg:";
		url_condision += $("input.fg:checked").val();
		url_condision += "/fr:";
		url_condision += $("input.free").val();
	}*/

	//駅
	if($("input.eki:checked").length > 0){
		url_condision += "/eki:";
		$("input.eki:checked").each(function () {
			url_condision += $(this).val() +"-";
		});
	}

	//人気条件
	if($("input.popular:checked").length > 0){
		url_condision += "/popular:";
		$("input.popular:checked").each(function () {
			url_condision += $(this).val() +"-";
		});
	}

	//市
	if($("input.city:checked").length > 0){
		url_condision += "/city:";
		$("input.city:checked").each(function () {
			url_condision += $(this).val() +"-";
		});
	}

	//間取
	if($("input.madori:checked").length > 0){
		url_condision += "/madori:";
		$("input.madori:checked").each(function () {
			url_condision += $(this).val() +"-";
		});
	}

	//設備
	if($("input.setubi:checked").length > 0){
		url_condision += "/setubi:";
		$("input.setubi:checked").each(function () {
			url_condision += $(this).val() +"-";
		});
	}

	//下限賃料
	if($("select#tinryo_s option:selected").val()){
		url_condision += "/tinryo_s:";
		url_condision += $("select#tinryo_s option:selected").val();
	}

	//上限賃料
	if($("select#tinryo_e option:selected").val()){
		url_condision += "/tinryo_e:";
		url_condision += $("select#tinryo_e option:selected").val();
	}

	//築年月
	if($("select#tikunengetu option:selected").val()){
		url_condision += "/tikunengetu:";
		url_condision += $("select#tikunengetu option:selected").val();
	}

	//下限面積
	if($("select#menseki_s option:selected").val()){
		url_condision += "/menseki_s:";
		url_condision += $("select#menseki_s option:selected").val();
	}

	//上限面積
	if($("select#menseki_e option:selected").val()){
		url_condision += "/menseki_e:";
		url_condision += $("select#menseki_e option:selected").val();
	}

	//徒歩
	if($("select#toho option:selected").val()){
		url_condision += "/toho:";
		url_condision += $("select#toho option:selected").val();
	}

	//空室確認日
	if($("select.empty option:selected").val()){
		url_condision += "/em:";
		url_condision += $("select.empty option:selected").val();
	}

	//空室状況
	if($("input.empty:checked").length > 0){
		url_condision += "/jk:";
		$("input.empty:checked").each(function () {
			url_condision += $(this).val();
		});
	}

	//管理費
	if($("input.kanrihi:checked").length > 0){
		url_condision += "/kanrihi:";
		$("input.kanrihi:checked").each(function () {
			url_condision += $(this).val();
		});
	}

	//駅全部
	if($("input#c_all:checked").length > 0){
		url_condision += "/c_all:";
		$("input.#c_all:checked").each(function () {
			url_condision += $(this).val();
		});
	}


	return url_condision;

}

function searchPage(){

	document.location = "http://www.mukonosou.jp/search/search.php#"+search_add();
	
}


function searchPage2(){
	$("#fm").attr('action', '../search/search.php#'+search_add());
	document.frmMain.submit()
}
