function Change()
{	
	ChangeSelect(document.frmSearchBox.zn.options[document.frmSearchBox.zn.selectedIndex].value);
}

function ChangeSelect(value)
{
	if (value==''){
		Clear();
		AddOption(document.frmSearchBox.pt,'ไม่ระบุ','');
		document.frmSearchBox.pt.options[0].selected=true;
	}
if (value=='2'){Clear();AddOption(document.frmSearchBox.pt,'ไม่ระบุ','');AddOption(document.frmSearchBox.pt,'CBD','1');AddOption(document.frmSearchBox.pt,'กรุงเทพชั้นใน','2');AddOption(document.frmSearchBox.pt,'กรุงเทพตะวันออก','6');AddOption(document.frmSearchBox.pt,'กรุงเทพตะวันออกเฉียงเหนือ','7');AddOption(document.frmSearchBox.pt,'กรุงเทพตอนเหนือ','8');AddOption(document.frmSearchBox.pt,'กรุงเทพตะวันตก','9');AddOption(document.frmSearchBox.pt,'กรุงเทพตอนใต้','10');document.frmSearchBox.pt.options[0].selected=true;}	if (value=='11'){Clear();AddOption(document.frmSearchBox.pt,'ไม่ระบุ','');AddOption(document.frmSearchBox.pt,'กำแพงเพชร','5');AddOption(document.frmSearchBox.pt,'เชียงราย','13');AddOption(document.frmSearchBox.pt,'เชียงใหม่','14');AddOption(document.frmSearchBox.pt,'นครสวรรค์','23');AddOption(document.frmSearchBox.pt,'น่าน','26');AddOption(document.frmSearchBox.pt,'พะเยา','32');AddOption(document.frmSearchBox.pt,'พิจิตร','35');AddOption(document.frmSearchBox.pt,'พิษณุโลก','36');AddOption(document.frmSearchBox.pt,'แพร่','39');AddOption(document.frmSearchBox.pt,'แม่ฮ่องสอน','43');AddOption(document.frmSearchBox.pt,'ลำปาง','51');AddOption(document.frmSearchBox.pt,'ลำพูน','52');AddOption(document.frmSearchBox.pt,'สุโขทัย','64');AddOption(document.frmSearchBox.pt,'อุตรดิตถ์','74');document.frmSearchBox.pt.options[0].selected=true;}	if (value=='12'){Clear();AddOption(document.frmSearchBox.pt,'ไม่ระบุ','');AddOption(document.frmSearchBox.pt,'กระบี่','1');AddOption(document.frmSearchBox.pt,'ชุมพร','12');AddOption(document.frmSearchBox.pt,'ตรัง','15');AddOption(document.frmSearchBox.pt,'นครศรีธรรมราช','22');AddOption(document.frmSearchBox.pt,'นราธิวาส','25');AddOption(document.frmSearchBox.pt,'ปัตตานี','31');AddOption(document.frmSearchBox.pt,'พังงา','33');AddOption(document.frmSearchBox.pt,'พัทลุง','34');AddOption(document.frmSearchBox.pt,'ภูเก็ต','40');AddOption(document.frmSearchBox.pt,'ยะลา','45');AddOption(document.frmSearchBox.pt,'ระนอง','47');AddOption(document.frmSearchBox.pt,'สงขลา','56');AddOption(document.frmSearchBox.pt,'สตูล','57');AddOption(document.frmSearchBox.pt,'สุราษฎร์ธานี','66');document.frmSearchBox.pt.options[0].selected=true;}	if (value=='13'){Clear();AddOption(document.frmSearchBox.pt,'ไม่ระบุ','');AddOption(document.frmSearchBox.pt,'กาฬสินธุ์','4');AddOption(document.frmSearchBox.pt,'ขอนแก่น','6');AddOption(document.frmSearchBox.pt,'ชัยภูมิ','11');AddOption(document.frmSearchBox.pt,'นครพนม','20');AddOption(document.frmSearchBox.pt,'นครราชสีมา','21');AddOption(document.frmSearchBox.pt,'บุรีรัมย์','27');AddOption(document.frmSearchBox.pt,'มหาสารคาม','41');AddOption(document.frmSearchBox.pt,'มุกดาหาร','42');AddOption(document.frmSearchBox.pt,'ยโสธร','44');AddOption(document.frmSearchBox.pt,'ร้อยเอ็ด','46');AddOption(document.frmSearchBox.pt,'เลย','53');AddOption(document.frmSearchBox.pt,'ศรีสะเกษ','54');AddOption(document.frmSearchBox.pt,'สกลนคร','55');AddOption(document.frmSearchBox.pt,'สุรินทร์','67');AddOption(document.frmSearchBox.pt,'หนองคาย','68');AddOption(document.frmSearchBox.pt,'หนองบัวลำภู','69');AddOption(document.frmSearchBox.pt,'อำนาจเจริญ','72');AddOption(document.frmSearchBox.pt,'อุดรธานี','73');AddOption(document.frmSearchBox.pt,'อุบลราชธานี','76');document.frmSearchBox.pt.options[0].selected=true;}	if (value=='14'){Clear();AddOption(document.frmSearchBox.pt,'ไม่ระบุ','');AddOption(document.frmSearchBox.pt,'ชัยนาท','10');AddOption(document.frmSearchBox.pt,'นครนายก','18');AddOption(document.frmSearchBox.pt,'เพชรบูรณ์','38');AddOption(document.frmSearchBox.pt,'ลพบุรี','50');AddOption(document.frmSearchBox.pt,'สมุทรสงคราม','59');AddOption(document.frmSearchBox.pt,'สระบุรี','62');AddOption(document.frmSearchBox.pt,'สิงห์บุรี','63');AddOption(document.frmSearchBox.pt,'สุพรรณบุรี','65');AddOption(document.frmSearchBox.pt,'อยุธยา','70');AddOption(document.frmSearchBox.pt,'อ่างทอง','71');AddOption(document.frmSearchBox.pt,'อุทัยธานี','75');document.frmSearchBox.pt.options[0].selected=true;}	if (value=='15'){Clear();AddOption(document.frmSearchBox.pt,'ไม่ระบุ','');AddOption(document.frmSearchBox.pt,'จันทบุรี','7');AddOption(document.frmSearchBox.pt,'ฉะเชิงเทรา','8');AddOption(document.frmSearchBox.pt,'ชลบุรี','9');AddOption(document.frmSearchBox.pt,'ตราด','16');AddOption(document.frmSearchBox.pt,'ปราจีนบุรี','30');AddOption(document.frmSearchBox.pt,'ระยอง','48');AddOption(document.frmSearchBox.pt,'สระแก้ว','61');document.frmSearchBox.pt.options[0].selected=true;}	if (value=='16'){Clear();AddOption(document.frmSearchBox.pt,'ไม่ระบุ','');AddOption(document.frmSearchBox.pt,'กาญจนบุรี','3');AddOption(document.frmSearchBox.pt,'ตาก','17');AddOption(document.frmSearchBox.pt,'ประจวบคีรีขันธ์','29');AddOption(document.frmSearchBox.pt,'เพชรบุรี','37');AddOption(document.frmSearchBox.pt,'ราชบุรี','49');document.frmSearchBox.pt.options[0].selected=true;}	
}

function Clear()
{
	while(document.frmSearchBox.pt.options.length>0)
		document.frmSearchBox.pt.options[0]=null;		
}

function AddOption(obj,label,value)
{
	var oOption = new Option(label,value);
	var i = obj.options.length;
	eval('obj.options[' + i + ']=oOption');
}

function WriteBox()
{
	document.write('<img src="/images/h_search.gif">');

	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="2">');
	document.write('<form name="frmSearchBox" action="/property/listing.asp">');

	document.write('<tr> ');
	document.write('<td width="43%"><font face="ms Sans Serif, thonburi" size="2" color="#3F8411">ทำเล</font><br>');
	document.write('<select name="zn" onChange="Change();">');
	document.write('<option value="">ไม่ระบุ</option>');
	document.write('<option value=2>กรุงเทพฯ</option>');
	document.write('<option value=\'11\'>ภาคเหนือ</option>');document.write('<option value=\'12\'>ภาคใต้</option>');document.write('<option value=\'13\'>ภาคอีสาน</option>');document.write('<option value=\'14\'>ภาคกลาง</option>');document.write('<option value=\'15\'>ภาคตะวันออก</option>');document.write('<option value=\'16\'>ภาคตะวันตก</option>');
	document.write('</select>');
	document.write('</td>');

	document.write('<td width="57%"><font face="ms Sans Serif, thonburi" size="2" color="#3F8411">ประเภทที่อยู่อาศัย</font><br>');
	document.write('<select name="ht">');
	document.write('<option value="">ไม่ระบุ</option>');
	document.write('<option value=\'3\'>คอนโดมีเนียม</option>');document.write('<option value=\'10\'>ทาวน์เฮาส์</option>');document.write('<option value=\'14\'>ที่ดิน</option>');document.write('<option value=\'2\'>บ้านเดี่ยว</option>');document.write('<option value=\'9\'>บ้านแฝด</option>');document.write('<option value=\'18\'>โรงงาน / คลังสินค้า</option>');document.write('<option value=\'13\'>อพาร์ทเมนท์</option>');document.write('<option value=\'19\'>อาคารพาณิชย์</option>');document.write('<option value=\'12\'>อาคารสำนักงาน</option>');document.write('<option value=\'11\'>โฮมออฟฟิศ</option>');
	document.write('</select>');
	document.write('</td>');
	document.write('</tr>');

	document.write('<tr> ');

	document.write('<td width="43%">');
	document.write('<font face="ms Sans Serif, thonburi" size="2" color="#3F8411">เขต/จังหวัด</font><br>');
	document.write('<select name="pt">');
	document.write('<option value="">ไม่ระบุ</option>');
	document.write('</select>');
	document.write('</td>');

	document.write('<td width="57%"> ');
	document.write('<font face="ms Sans Serif, thonburi" size="2" color="#3F8411">ราคา<br>');
	document.write('<select name="mn" >');
	document.write('<option selected value="0">ไม่ระบุ</option>');
	document.write('<option value="500000">5 แสน</option>');
	for(i=1;i<=10;i++)
		document.write('<option value="' + i +'000000">' + i +' ล้าน</option>');
	
	document.write('</select>');
	document.write('<font size="2" face="ms Sans Serif, thonburi" color="#3F8411"> ถึง ');
	document.write('<select name="mx">');
	document.write('<option selected value="0">ไม่ระบุ</option>');
	document.write('<option value="500000">5 แสน</option>');
	for(i=1;i<=10;i++)
		document.write('<option value="' + i +'000000">' + i +' ล้าน</option>');
	document.write('</select>');
	document.write('&nbsp;<input type="image" name="btn" value="go" src="/images/ic_go1.gif" align=absmiddle> <a href="javascript:frmSearchBox.submit();" class="link_sub_menu">ค้นหา</a></font>');
	document.write('</td>');

	document.write('</tr>');

	document.write('</form>');
	document.write('</table>');
}
