function quickSearch(Idx) {
	if (Idx) {
		document.SearchHeader.action = 'http://www.sumai.mecyes.co.jp/search/bukkenlist.php';
		document.SearchHeader.SearchKey.value = Idx;
		document.SearchHeader.Quick_Price.selectedIndex = 0;
		document.SearchHeader.Quick_Town.selectedIndex = 0;
		document.SearchHeader.Quick_Detail.selectedIndex = 0;
		document.SearchHeader.submit();
	}
}

function quickSearch_Money(Idx) {
	if (Idx) {
		document.SearchHeader.action = 'http://www.sumai.mecyes.co.jp/search/bukkenlist.php';
		document.SearchHeader.SearchKey.value='Top_Money';
		document.SearchHeader.Quick_Feature.selectedIndex = 0;
		document.SearchHeader.Quick_Town.selectedIndex = 0;
		document.SearchHeader.Quick_Detail.selectedIndex = 0;
		document.SearchHeader.submit();
	}
}

function quickSearch_Town(Idx) {
	if (Idx && Idx != '-') {
		document.SearchHeader.action = 'http://www.sumai.mecyes.co.jp/search/bukkenlist.php';
		document.SearchHeader.SearchKey.value='Top_Town';
		document.SearchHeader.Quick_Price.selectedIndex = 0;
		document.SearchHeader.Quick_Feature.selectedIndex = 0;
		document.SearchHeader.Quick_Detail.selectedIndex = 0;
		document.SearchHeader.submit();
	}
}

function quickSearch_Detail(Idx) {
	if (Idx) {
		document.SearchHeader.action = 'http://www.sumai.mecyes.co.jp/search/bukkenlist.php';
		document.SearchHeader.SearchKey.value = Idx;
		document.SearchHeader.Quick_Price.selectedIndex = 0;
		document.SearchHeader.Quick_Feature.selectedIndex = 0;
		document.SearchHeader.Quick_Town.selectedIndex = 0;
		document.SearchHeader.submit();
	}
}

function gotoLoanSimulate(Idx) {
	document.SearchHeader.action = 'http://www.sumai.mecyes.co.jp/search/LoanSimulate.php';
	document.SearchHeader.Quick_Price.selectedIndex = 0;
	document.SearchHeader.Quick_Feature.selectedIndex = 0;
	document.SearchHeader.Quick_Town.selectedIndex = 0;
	document.SearchHeader.Quick_Detail.selectedIndex = 0;
	document.SearchHeader.submit();
}

function winOpen(url,winname){
	window.open(url,winname,'scrollbars=1,resizable=1,toolbar=1,location=0,status=1,menubar=1,width=764,height=400');
}

DateMtd = new Date();
var NewWin;
function isChecked(WrtCook, URL) {
	var Count = 0;
	Arr_CokTmp = new Array();
	for (i = 0; i < document.Head2.elements.length; i++) {
		if (document.Head2.elements[i].type == 'checkbox') {
			if (document.Head2.elements[i].checked && document.Head2.elements[i].name=='Bukken[]') {
				if (WrtCook == 'y') {
					Arr_CokTmp[Arr_CokTmp.length] = document.Head2.elements[i].value;
				}
				Count++;
			}
		}
	}
	if (!Count) {
		alert('物件が選択されていません。');
	} else {
		if (WrtCook == 'y') {
			var Arr_DelCokTmp = new Array();
			var Arr_Tmp = new Array();
			Arr_DelCokTmp = document.cookie.split('; ');
			for (i = 0; i < Arr_DelCokTmp.length; i++) {
				if (Arr_DelCokTmp[i].substring(0,18) == 'Mecyes[MyFavorite]') {
					Arr_Tmp = Arr_DelCokTmp[i].split('=');
					myREG   = new RegExp(",","gi");
					Arr_Tmp[1] = "'" + Arr_Tmp[1].replace(myREG, "''") + "'";
					break;
				}
			}
			if (Arr_Tmp.length > 0) {
				for (i = 0; i < Arr_CokTmp.length; i++) {
					Arr_Tmp[1] = Arr_Tmp[1].replace("'" + Arr_CokTmp[i] + "'","");
				}
				myREG   = new RegExp("''","gi");
				Arr_Tmp[1] = Arr_Tmp[1].replace(myREG, ",");
				myREG   = new RegExp("'","gi");
				Arr_Tmp[1] = Arr_Tmp[1].replace(myREG, "");
				Arr_Tmp = Arr_Tmp[1].split(',');
				Arr_CokTmp = Arr_Tmp.concat(Arr_CokTmp);
			}
			while (Arr_CokTmp.length > 100) {
				Arr_CokTmp.shift(); 
			}
			DateMtd.setFullYear(2030);
			DateMtd.setMonth(12);
			DateMtd.setDate(31);
			DateMtd.setDate(31);
			DateMtd.setHours("23");
			DateMtd.setMinutes("59");
			DateMtd.setSeconds("59");
			ExpireStr = DateMtd.toGMTString(DateMtd.getTime());
			document.cookie = 'Mecyes[MyFavorite]' + '=' + Arr_CokTmp.join(",") + ';' + ' expires=' + ExpireStr + '; path=/;';
			if (!confirm('選択した物件をお気に入りに入れました。\n\nこのままお気に入りの一覧を表示しますか？ ')) { return; } else { document.Head2.target='_self'; }
		} else {
			/* var NewWin = window.open('','InputWindow','scrollbars=1,resizable=1,toolbar=1,location=1,status=1,menubar=1'); */
			/* document.Head2.target='InputWindow'; */
			document.Head2.target='_blank';
		}
		document.forms['Head2'].action = URL;
		document.forms['Head2'].submit();
	}
}

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;
			}
		}
	}
}
function winOpen(url,winname){
	window.open(url,winname,'scrollbars=1,resizable=1,toolbar=1,location=0,status=1,menubar=1,width=700,height=500');
}
function winOpen6464(url,winname){
	window.open(url,winname,'scrollbars=1,resizable=1,toolbar=1,location=0,status=1,menubar=1,width=640,height=640');
}
function winOpen0(url,winname){
	window.open(url,winname,'scrollbars=1,resizable=1,toolbar=1,location=0,status=1,menubar=1');
}
function winOpen1(url,winname,width,height){
	window.open(url,winname,'scrollbars=1,resizable=1,toolbar=1,location=0,status=1,menubar=1,width=' + width + ',height=' + height);
}
function set_SelValue(Sel,Id) {
	for (i = 0; i < Sel.options.length; i++) {
		if (Sel.options[i].value == Id) {
			Sel.selectedIndex = i;
			break;
		}
	}
}
function changeType(Val){
	document.Head2.MODE.value = "ChangeType";
	document.Head2.NowPage.value = "1";
	
	if(Val == "Ensen")
		document.Head2.action = location.protocol + "//" +
								location.hostname +":" + location.port + "/buy/sch_ensen_d.php";
	else
		document.Head2.action = location.protocol + "//" +
								location.hostname +":" + location.port +"/buy/sch_area_d.php";
	document.Head2.submit();
	
}
function changeType2(Val){
	document.Head2.MODE.value = "ChangeType";
	document.Head2.NowPage.value = "1";
	
	if(Val == "Ensen"){
		document.Head2.action = location.protocol + "//" +
								location.hostname +":" + location.port + "/buy/sch_ensen_d.php";
	}
	else{
		document.Head2.action = location.protocol + "//" +
								location.hostname +":" + location.port + "/buy/sch_area_d.php";
	}
	document.Head2.submit();
	
}

function moveToMansion(){
	document.getElementById('PREF_MV').value = "13";
	document.getElementById('Pref').value = "13";
	document.getElementById('Bukken_Type1').value = "3";
	document.getElementById('Bukken_Type2').value = "0";
	document.getElementById('Bukken_Type3').value = "0";
	document.directBukken.action = location.protocol + "//" +
								location.hostname +":" + location.port +"/buy/sch_area_lp.php";
	document.directBukken.submit();
}
function moveToHouse(){
	document.getElementById('PREF_MV').value = "13";
	document.getElementById('Pref').value = "13";
	document.getElementById('Bukken_Type1').value = "0";
	document.getElementById('Bukken_Type2').value = "2";
	document.getElementById('Bukken_Type3').value = "0";
	document.directBukken.action = location.protocol + "//" +
								location.hostname +":" + location.port +"/buy/sch_area_lp.php";
	document.directBukken.submit();
}
function moveToLand(){
	document.getElementById('PREF_MV').value = "13";
	document.getElementById('Pref').value = "13";
	document.getElementById('Bukken_Type1').value = "0";
	document.getElementById('Bukken_Type2').value = "0";
	document.getElementById('Bukken_Type3').value = "1";
	document.directBukken.action = location.protocol + "//" +
								location.hostname +":" + location.port +"/buy/sch_area_lp.php";
	document.directBukken.submit();
}

function refchk() {
	if((document.referrer != '') &&
		(document.referrer.indexOf(location.host) < 0)){
//		(document.referrer.indexOf("sumai.mecyes.co.jp") < 0)){
		DateMtd = new Date();
		DateMtd.setFullYear(2030);
		DateMtd.setMonth(12);
		DateMtd.setDate(31);
		DateMtd.setHours("23");
		DateMtd.setMinutes("59");
		DateMtd.setSeconds("59");
		ExpireStr = DateMtd.toGMTString(DateMtd.getTime());
		document.cookie = 'Mecyes[SerchEngine]' + '= ' + document.referrer + ';' + ' expires=' + ExpireStr + '; path=/;';
	}
}

function refdel() {
	if(document.cookie != '') {
		DateMtd = new Date();
		DateMtd.setFullYear(1980);
		DateMtd.setMonth(12);
		DateMtd.setDate(31);
		DateMtd.setHours("23");
		DateMtd.setMinutes("59");
		DateMtd.setSeconds("59");
		ExpireStr = DateMtd.toGMTString(DateMtd.getTime());
		document.cookie = 'Mecyes[SerchEngine]' + '= ' + document.referrer + ';' + ' expires=' + ExpireStr + '; path=/;';
	}
}