function getVal(Name, Flg, TheForm) {
	for (i = 0; i < TheForm.elements.length; i++) {
		if (TheForm.elements[i].name == Name) {
			switch (Flg) {
				case 'V':
					return TheForm.elements[i].value;
					break;
				case 'C':
					return TheForm.elements[i].checked;
					break;
				case 'SV':
					return TheForm.elements[i].options[TheForm.elements[i].selectedIndex].value;
					break;
				case 'SI':
					return TheForm.elements[i].selectedIndex;
					break;
				case 'DR':
					if (TheForm.elements[i].value != '再表示'){ break; }
				case 'OB':
					obj = new Object;
					obj = TheForm.elements[i];
					return obj;
					break;
			}
		}
	}
}

// -------------------------------
// send to sch_area_lp.php
// -------------------------------
function mapSearch(){

	//	is not checked all case
	if((getVal('Mapping_Bukken[0]', 'C', document.FormMap) == false) &&
		 (getVal('Mapping_Bukken[1]', 'C', document.FormMap) == false) &&
		 (getVal('Mapping_Bukken[2]', 'C', document.FormMap) == false) &&
		 (getVal('Mapping_Bukken[3]', 'C', document.FormMap) == false)){
		getVal('Bukken_Kind[0]', 'OB', document.FormMap).value = "2";		//	umansion
		getVal('Bukken_Kind[1]', 'OB', document.FormMap).value = "1";		//	nhouse
		getVal('Bukken_Kind[2]', 'OB', document.FormMap).value = "2";		//	uhouse
		getVal('Bukken_Type[2]', 'OB', document.FormMap).value = "1";		//	land
	} else {
		//	umansion
		if(getVal('Mapping_Bukken[0]', 'C', document.FormMap) == true){
			getVal('Bukken_Kind[0]', 'OB', document.FormMap).value = "2";
		} else {
			getVal('Bukken_Kind[0]', 'OB', document.FormMap).value = "0";
		}
		//	nhouse
		if(getVal('Mapping_Bukken[1]', 'C', document.FormMap) == true){
			getVal('Bukken_Kind[1]', 'OB', document.FormMap).value = "1";
		} else {
			getVal('Bukken_Kind[1]', 'OB', document.FormMap).value = "0";
		}
		//	uhouse
		if(getVal('Mapping_Bukken[2]', 'C', document.FormMap) == true){
			getVal('Bukken_Kind[2]', 'OB', document.FormMap).value = "2";
		} else {
			getVal('Bukken_Kind[2]', 'OB', document.FormMap).value = "0";
		}
		//	land
		if(getVal('Mapping_Bukken[3]', 'C', document.FormMap) == true){
			getVal('Bukken_Type[2]', 'OB', document.FormMap).value = "1";
		} else {
			getVal('Bukken_Type[2]', 'OB', document.FormMap).value = "0";
		}
	}

	// send logic FormMap

	var _clear = false;
	for (var i = 0; i < arguments.length; i+=2) {
		if (document.FormMap.elements[arguments[i]].name.substring(0,5) == 'Addr[') {
			_clear = true;
		}
	}
	if (_clear) {
		for (var i = 0; i < document.FormMap.elements.length; i++) {
			if (document.FormMap.elements[i].name.substring(0,5) == 'Addr[') {
				document.FormMap.elements[i].defaultValue = document.FormMap.elements[i].value;
				document.FormMap.elements[i].value = '';
			}
		}
	}
	for (var i = 0; i < arguments.length; i++) {
		if (!_clear) document.FormMap.elements[arguments[i]].defaultValue = document.FormMap.elements[arguments[i]].value;
		document.FormMap.elements[arguments[i]].value = arguments[++i];
	}
	document.FormMap.action = "/buy/sch_area_lp.php";
	document.FormMap.target='_blank';

	// ELCID SETTING START
	var lherf = location.href; // URL を取得
	var _s = lherf.lastIndexOf("/") + 1;
	var page = lherf.substring(_s).split('\?')[0]; // ファイル名のみ取得
	var page = lherf.substring(_s).split('#tab')[0]; // タブ削除
	
	var len    = arguments.length;
	
	var elcids = [];
	// 第３引数には以下の値の合計値を設定。 0 => 15
	// 中古マンション：１		新築一戸建て：２
	// 中古一戸建て：４	土地：８
	elcids['area_umansion_23group.html'] = [];
	elcids['area_umansion_23group.html']['Addr[0],13101'] = ['0000350','0000014','0000038','0000110','0000062','0000134','0000182','0000254','0000086','0000158','0000206','0000278','0000230','0000302','0000326','0000350']; // 千代田区
	elcids['area_umansion_23group.html']['Addr[0],13102'] = ['0000351','0000015','0000039','0000111','0000063','0000135','0000183','0000255','0000087','0000159','0000207','0000279','0000231','0000303','0000327','0000351']; // 中央区
	elcids['area_umansion_23group.html']['Addr[0],13103'] = ['0000352','0000016','0000040','0000112','0000064','0000136','0000184','0000256','0000088','0000160','0000208','0000280','0000232','0000304','0000328','0000352']; // 港区
	elcids['area_umansion_23group.html']['Addr[0],13104'] = ['0000353','0000017','0000041','0000113','0000065','0000137','0000185','0000257','0000089','0000161','0000209','0000281','0000233','0000305','0000329','0000353']; // 新宿区
	elcids['area_umansion_23group.html']['Addr[0],13105'] = ['0000354','0000018','0000042','0000114','0000066','0000138','0000186','0000258','0000090','0000162','0000210','0000282','0000234','0000306','0000330','0000354']; // 文京区
	elcids['area_umansion_23group.html']['Addr[0],13106'] = ['0000355','0000019','0000043','0000115','0000067','0000139','0000187','0000259','0000091','0000163','0000211','0000283','0000235','0000307','0000331','0000355']; // 台東区
	elcids['area_umansion_23group.html']['Addr[0],13107'] = ['0000356','0000020','0000044','0000116','0000068','0000140','0000188','0000260','0000092','0000164','0000212','0000284','0000236','0000308','0000332','0000356']; // 墨田区
	elcids['area_umansion_23group.html']['Addr[0],13108'] = ['0000357','0000021','0000045','0000117','0000069','0000141','0000189','0000261','0000093','0000165','0000213','0000285','0000237','0000309','0000333','0000357']; // 江東区
	elcids['area_umansion_23group.html']['Addr[0],13109'] = ['0000358','0000022','0000046','0000118','0000070','0000142','0000190','0000262','0000094','0000166','0000214','0000286','0000238','0000310','0000334','0000358']; // 品川区
	elcids['area_umansion_23group.html']['Addr[0],13110'] = ['0000359','0000023','0000047','0000119','0000071','0000143','0000191','0000263','0000095','0000167','0000215','0000287','0000239','0000311','0000335','0000359']; // 目黒区
	elcids['area_umansion_23group.html']['Addr[0],13111'] = ['0000360','0000024','0000048','0000120','0000072','0000144','0000192','0000264','0000096','0000168','0000216','0000288','0000240','0000312','0000336','0000360']; // 大田区
	elcids['area_umansion_23group.html']['Addr[0],13112'] = ['0000361','0000025','0000049','0000121','0000073','0000145','0000193','0000265','0000097','0000169','0000217','0000289','0000241','0000313','0000337','0000361']; // 世田谷区
	elcids['area_umansion_23group.html']['Addr[0],13113'] = ['0000362','0000026','0000050','0000122','0000074','0000146','0000194','0000266','0000098','0000170','0000218','0000290','0000242','0000314','0000338','0000362']; // 渋谷区
	elcids['area_umansion_23group.html']['Addr[0],13114'] = ['0000363','0000027','0000051','0000123','0000075','0000147','0000195','0000267','0000099','0000171','0000219','0000291','0000243','0000315','0000339','0000363']; // 中野区
	elcids['area_umansion_23group.html']['Addr[0],13115'] = ['0000364','0000028','0000052','0000124','0000076','0000148','0000196','0000268','0000100','0000172','0000220','0000292','0000244','0000316','0000340','0000364']; // 杉並区
	elcids['area_umansion_23group.html']['Addr[0],13116'] = ['0000365','0000029','0000053','0000125','0000077','0000149','0000197','0000269','0000101','0000173','0000221','0000293','0000245','0000317','0000341','0000365']; // 豊島区
	elcids['area_umansion_23group.html']['Addr[0],13117'] = ['0000366','0000030','0000054','0000126','0000078','0000150','0000198','0000270','0000102','0000174','0000222','0000294','0000246','0000318','0000342','0000366']; // 北区
	elcids['area_umansion_23group.html']['Addr[0],13118'] = ['0000367','0000031','0000055','0000127','0000079','0000151','0000199','0000271','0000103','0000175','0000223','0000295','0000247','0000319','0000343','0000367']; // 荒川区
	elcids['area_umansion_23group.html']['Addr[0],13119'] = ['0000368','0000032','0000056','0000128','0000080','0000152','0000200','0000272','0000104','0000176','0000224','0000296','0000248','0000320','0000344','0000368']; // 板橋区
	elcids['area_umansion_23group.html']['Addr[0],13120'] = ['0000369','0000033','0000057','0000129','0000081','0000153','0000201','0000273','0000105','0000177','0000225','0000297','0000249','0000321','0000345','0000369']; // 練馬区
	elcids['area_umansion_23group.html']['Addr[0],13121'] = ['0000370','0000034','0000058','0000130','0000082','0000154','0000202','0000274','0000106','0000178','0000226','0000298','0000250','0000322','0000346','0000370']; // 足立区
	elcids['area_umansion_23group.html']['Addr[0],13122'] = ['0000371','0000035','0000059','0000131','0000083','0000155','0000203','0000275','0000107','0000179','0000227','0000299','0000251','0000323','0000347','0000371']; // 葛飾区
	elcids['area_umansion_23group.html']['Addr[0],13123'] = ['0000372','0000036','0000060','0000132','0000084','0000156','0000204','0000276','0000108','0000180','0000228','0000300','0000252','0000324','0000348','0000372']; // 江戸川区
	
	if (typeof(elcids[page]) != 'undefined') {
		if (len > 0) {
			var idx = "";
			for (var x = 0; x < len; x++) {
				if (x > 0) {
					idx += ",";
				}
				idx += arguments[x];
			}
			var c0 = getVal('Mapping_Bukken[0]', 'C', document.FormMap) == true; // 中古マンション
			var c1 = getVal('Mapping_Bukken[1]', 'C', document.FormMap) == true; // 新築一戸
			var c2 = getVal('Mapping_Bukken[2]', 'C', document.FormMap) == true; // 中古一戸
			var c3 = getVal('Mapping_Bukken[3]', 'C', document.FormMap) == true; // 土地
			
			var ind = (c0 ? 1 : 0) + (c1 ? 2 : 0) + (c2 ? 4 : 0) + (c3 ? 8 : 0)
			document.FormMap.action += "?elcid=" + elcids[page][idx][ind];
		}
		
	}
	
	// ELCID SETTING END

	document.FormMap.submit();
//	location.reload(true);
	for (var i = 0; i < arguments.length; i+=2) {
		document.FormMap.elements[arguments[i]].value = document.FormMap.elements[arguments[i]].defaultValue;
		document.FormMap.elements[arguments[i]].defaultValue = '';
	}
	if (_clear) {
		for (var i = 0; i < document.FormMap.elements.length; i++) {
			if (document.FormMap.elements[i].name.substring(0,5) == 'Addr[') {
				document.FormMap.elements[i].value = document.FormMap.elements[i].defaultValue;
				document.FormMap.elements[i].defaultValue = '';
			}
		}
	}

}

// -------------------------------
// send to sch_area_d.php
// -------------------------------
function othermapSearch() {

	//	is not checked all case
	if((getVal('Mapping_Bukken[0]', 'C', document.FormMap) == false) &&
		 (getVal('Mapping_Bukken[1]', 'C', document.FormMap) == false) &&
		 (getVal('Mapping_Bukken[2]', 'C', document.FormMap) == false) &&
		 (getVal('Mapping_Bukken[3]', 'C', document.FormMap) == false)){
		getVal('Bukken_Kind[0]', 'OB', document.FormOtherMap).value = "2";		//	umansion
		getVal('Bukken_Kind[1]', 'OB', document.FormOtherMap).value = "1";		//	nhouse
		getVal('Bukken_Kind[2]', 'OB', document.FormOtherMap).value = "2";		//	uhouse
		getVal('Bukken_Type[2]', 'OB', document.FormOtherMap).value = "1";		//	land
	} else {
		//	umanshon
		if(getVal('Mapping_Bukken[0]', 'C', document.FormMap) == true){
			getVal('Bukken_Kind[0]', 'OB', document.FormOtherMap).value = "2";
		} else {
			getVal('Bukken_Kind[0]', 'OB', document.FormOtherMap).value = "0";
		}
		//	nhouse
		if(getVal('Mapping_Bukken[1]', 'C', document.FormMap) == true){
			getVal('Bukken_Kind[1]', 'OB', document.FormOtherMap).value = "1";
		} else {
			getVal('Bukken_Kind[1]', 'OB', document.FormOtherMap).value = "0";
		}
		//	uhouse
		if(getVal('Mapping_Bukken[2]', 'C', document.FormMap) == true){
			getVal('Bukken_Kind[2]', 'OB', document.FormOtherMap).value = "2";
		} else {
			getVal('Bukken_Kind[2]', 'OB', document.FormOtherMap).value = "0";
		}
		//	land
		if(getVal('Mapping_Bukken[3]', 'C', document.FormMap) == true){
			getVal('Bukken_Type[2]', 'OB', document.FormOtherMap).value = "1";
		} else {
			getVal('Bukken_Type[2]', 'OB', document.FormOtherMap).value = "0";
		}
	}

	document.FormOtherMap.NowPage.value = 1;

	document.FormOtherMap.action = "../buy/sch_area_d.php";
	document.FormOtherMap.target='_blank';

	// ELCID SETTING START
	var lherf = location.href; // URL を取得
	var _s = lherf.lastIndexOf("/") + 1;
	var page = lherf.substring(_s).split('\?')[0]; // ファイル名のみ取得
	var page = lherf.substring(_s).split('#tab')[0]; // タブ削除
	
	var len    = arguments.length;
	
	var elcids = [];
	// 第３引数には以下の値の合計値を設定。 0 => 15
	// 中古マンション：１		新築一戸建て：２
	// 中古一戸建て：４	土地：８
	elcids['area_umansion_23group.html'] = ['0000373','0000037','0000061','0000133','0000085','0000157','0000205','0000277','0000109','0000181','0000229','0000301','0000253','0000325','0000349','0000373']; // その他
	
	var Mapping_Bukken = [];
	if (typeof(elcids[page]) != 'undefined') {
			var c0 = getVal('Mapping_Bukken[0]', 'C', document.FormMap) == true; // 中古マンション
			var c1 = getVal('Mapping_Bukken[1]', 'C', document.FormMap) == true; // 新築一戸
			var c2 = getVal('Mapping_Bukken[2]', 'C', document.FormMap) == true; // 中古一戸
			var c3 = getVal('Mapping_Bukken[3]', 'C', document.FormMap) == true; // 土地
			var ind = (c0 ? 1 : 0) + (c1 ? 2 : 0) + (c2 ? 4 : 0) + (c3 ? 8 : 0)
			document.FormOtherMap.action += "?elcid=" + elcids[page][ind];
	}
	
	// ELCID SETTING END
	document.FormOtherMap.submit();

}

// -------------------------------
// write information on the cookie for area checkbox
// -------------------------------

function write_map_options(transurl){
// 08/08/18 comment out
/*
	if((getVal('Mapping_Bukken[0]', 'C', document.FormMap) == false) &&
		 (getVal('Mapping_Bukken[1]', 'C', document.FormMap) == false) &&
		 (getVal('Mapping_Bukken[2]', 'C', document.FormMap) == false) &&
		 (getVal('Mapping_Bukken[3]', 'C', document.FormMap) == false)){
	} else {
		cookie_name = "sumai_area_map";
		val_uman = "0";
		val_nhou = "0";
		val_uhou = "0";
		val_land = "0";
		//	umanshon
		if(getVal('Mapping_Bukken[0]', 'C', document.FormMap) == true){
			val_uman = "1";
		}
		//	nhouse
		if(getVal('Mapping_Bukken[1]', 'C', document.FormMap) == true){
			val_nhou = "1";
		}
		//	uhouse
		if(getVal('Mapping_Bukken[2]', 'C', document.FormMap) == true){
			val_uhou = "1";
		}
		//	land
		if(getVal('Mapping_Bukken[3]', 'C', document.FormMap) == true){
			val_land = "1";
		}
		document.cookie = cookie_name + "=" + val_uman + val_nhou + val_uhou + val_land;
	}
*/
	act_url = "/buy_area/" + transurl;
	location.href= act_url;
}

// -------------------------------
// load information on the cookie for area checkbox
// -------------------------------
function load_map_options(){
// 08/08/18 comment out
/*
	now_date = new Date();
	cookie_name = "sumai_area_map=";
	the_cookie = document.cookie ; ";";
	start = the_cookie.indexOf(cookie_name);
	end = the_cookie.indexOf(";",start);
	cookie_val = unescape(the_cookie.substring(start + cookie_name.length, end));
	if(cookie_val){
		for(var i = 0; i <= 3; i++){
			if(cookie_val.substring(i,i + 1) == "1"){
				getVal('Mapping_Bukken['+i+']', 'OB', document.FormMap).checked = true;
			}
		}
	}
	//	delete document.cookie.sumai_area_map
	document.cookie = cookie_name + ";expires=" + now_date;
*/
}

