﻿/* 精品房源 */
function FillHouse(){
	try{
		$('scrollhousecontent').src = "/UserControls/Advertisement/ScrollHouse/Index.html?id=" + $('SearchCityId').value;
	}catch(e){}
}
FillHouse();

/* 搜索条 */
GetArea=function(cityid){ //获取行政区域
	/*new Ajax.Request('http://s.nettop.cn/CityJson/'+cityid+'/D.html',{*/
	new Ajax.Request('inc/searchData/'+cityid+'/D.html',{
		method:'get', 
		evalScripts:true,
		onSuccess: function(transport){
			var Data = transport.responseText.evalJSON();
			var num=Data.BigData.length;
			var str="<li><a onclick=\"javascript:Listing_Propertys_SearchBar_Select.selectarea('apf_id_8area','apf_id_8block','','区域不限','-1','searchbar_p1','apf_id_8area_blank');GetSection("+cityid+",-1);\" class=\"hov\" target=\"_self\">不限</a> </li>"
			for(var i=0;i<num;i++){
				str=str+"<li><a onclick=\"javascript:Listing_Propertys_SearchBar_Select.selectarea('apf_id_8area','apf_id_8block','','"+Data.BigData[i].Name+"','"+Data.BigData[i].Id+"','searchbar_p1','apf_id_8area_blank');GetSection("+cityid+","+Data.BigData[i].Id+");\" class=\"hov\" target=\"_sel\">"+Data.BigData[i].Name+"</a> </li>"
			}
			$("apf_id_8area").innerHTML="<ul>"+str+"</ul>";
		},onFailure: function() {
			$("apf_id_8area").innerHTML = "未读取到所需的数据";
		}, onException: function(obj, e) {
			$("apf_id_8area").innerHTML = e.name;
		}
	})
	$("apf_id_8block").innerHTML="<ul><li><a onclick=\"javascript:s_b.selectblock('-1','板块不限');\" target=\"_self\">请先选择区域</a></li></ul>";
}
GetSection=function(cityid,districtId){//获取片区
	$("apf_id_8block").innerHTML="<ul><li><a onclick=\"javascript:s_b.selectblock('-1','板块不限');\" target=\"_self\">请先选择区域</a></li></ul>";
	s_b.selectblock('-1','板块不限');
	$("searchbar_p2").value="-1";
	if(districtId > 0){
		new Ajax.Request('inc/searchData/'+cityid+'/D'+districtId+'.html',{
		method:'get', 
		onSuccess: function(transport){
		var Data = transport.responseText.evalJSON();
		var num=Data.BigData.length;
		var str="<li><a onclick=\"javascript:s_b.selectblock('-1','板块不限');\" target=\"_self\">不限</a></li>"
			for(var i=0;i<num;i++){
				str=str+"<li><a onclick=\"javascript:s_b.selectblock('"+Data.BigData[i].Id+"','"+Data.BigData[i].Name+"');\" target=\"_self\">"+Data.BigData[i].Name+"</a></li>"
			}
			$("apf_id_8block").innerHTML="<ul>"+str+"</ul>";
		},onFailure: function() {
			$("apf_id_8block").innerHTML = "未读取到所需的数据";
			}
		})
	}
}
SearchUrl=function(){
var usedhouse="http://www.foloda.com/PagesFor/ToFoloda.aspx?CityId={0}&foloda=foloda%E9%93%BE%E6%8E%A5&ToPageUrl=http%3A%2F%2Fwww.foloda.com%2FHouse%2FUsedHouse.aspx%3FKeys={1}&clubid=&districtid={2}&District={2}&pricebegin={3}&priceend={4}&UsedHousePrice={5}&areabegin=&areaend=&UsedHouseBuildArea4Query=&houseDoor={8}&Room={8}&sectionid={9}&Zone={9}";
var renthouse="http://www.foloda.com/PagesFor/ToFoloda.aspx?CityId={0}&foloda=foloda%E9%93%BE%E6%8E%A5&ToPageUrl=http%3A%2F%2Fwww.foloda.com%2FHouse%2FRentHouse.aspx%3FKeys={1}&clubid=&districtid={2}&District={2}&pricebegin={3}&priceend={4}&sectionid={9}&Zone={9}&tradeway=&houseDoor={8}&Room={8}";
var str="";
	if($('searchbar_p0').value=='1'){
		str=usedhouse;
		var p3=$('searchbar_p3_s').value;
		switch (p3){
			case "-1":
				str=str.replace("{3}","");
				str=str.replace("{4}","");
				str=str.replace("{5}","");
			break;
			case "1":
				str=str.replace("{3}","0");
				str=str.replace("{4}","30");
				str=str.replace("{5}","0-30");
			break;
			case "2":
				str=str.replace("{3}","30");
				str=str.replace("{4}","60");
				str=str.replace("{5}","30-60");
			break;
			case "3":
				str=str.replace("{3}","60");
				str=str.replace("{4}","100");
				str=str.replace("{5}","60-100");
			break;
			case "4":
				str=str.replace("{3}","100");
				str=str.replace("{4}","150");
				str=str.replace("{5}","100-150");
			break;
			case "5":
				str=str.replace("{3}","150");
				str=str.replace("{4}","200");
				str=str.replace("{5}","150-200");
			break;
			case "6":
				str=str.replace("{3}","200");
				str=str.replace("{4}","300");
				str=str.replace("{5}","200-300");
			break;
			case "7":
				str=str.replace("{3}","300");
				str=str.replace("{4}","400");
				str=str.replace("{5}","300-400");
			break;
			case "8":
				str=str.replace("{3}","400");
				str=str.replace("{4}","500");
				str=str.replace("{5}","400-500");
			break;
			case "9":
				str=str.replace("{3}","500");
				str=str.replace("{4}","100000");
				str=str.replace("{5}","2147483647");
			break;
		}
	}
	if($('searchbar_p0').value=='2'){
		str=renthouse;
		var p3=$('searchbar_p3_r').value;
		switch (p3){
			case "-1":
				str=str.replace("{3}","");
				str=str.replace("{4}","");
				str=str.replace("{5}","");
			break;
			case "1":
				str=str.replace("{3}","0");
				str=str.replace("{4}","500");
				str=str.replace("{5}","0-500");
			break;
			case "2":
				str=str.replace("{3}","500");
				str=str.replace("{4}","800");
				str=str.replace("{5}","500-800");
			break;
			case "3":
				str=str.replace("{3}","800");
				str=str.replace("{4}","1200");
				str=str.replace("{5}","800-1200");
			break;
			case "4":
				str=str.replace("{3}","1200");
				str=str.replace("{4}","2000");
				str=str.replace("{5}","1200-2000");
			break;
			case "5":
				str=str.replace("{3}","2000");
				str=str.replace("{4}","3000");
				str=str.replace("{5}","2000-3000");
			break;
			case "6":
				str=str.replace("{3}","3000");
				str=str.replace("{4}","4500");
				str=str.replace("{5}","3000-4500");
			break;
			case "7":
				str=str.replace("{3}","4500");
				str=str.replace("{4}","6000");
				str=str.replace("{5}","4500-6000");
			break;
			case "8":
				str=str.replace("{3}","6000");
				str=str.replace("{4}","10000");
				str=str.replace("{5}","6000-10000");
			break;
			case "9":
				str=str.replace("{3}","10000");
				str=str.replace("{4}","100000");
				str=str.replace("{5}","2147483647");
			break;
		}
	}
str=str.replace("{0}",$('SearchCityId').value);
var p1=$('searchbar_p1').value;
	if(p1!="-1"){
		str=str.replace("{2}",p1);
		str=str.replace("{2}",p1);
	}else{
		str=str.replace("{2}","");
		str=str.replace("{2}","");
	}
var p2=$('searchbar_p2').value;
	if(p2!="-1"){
		str=str.replace("{9}",p2);
		str=str.replace("{9}",p2);
	}else{
		str=str.replace("{9}","");
		str=str.replace("{9}","");
	}
var p5=$('searchbar_p5').value;
	if(p5!="-1"){
		str=str.replace("{8}",p5);
		str=str.replace("{8}",p5);
	}else{
		str=str.replace("{8}","");
		str=str.replace("{8}","");
	}
var key= document.getElementById('searchwords').value;
	if(key!="输入小区名称、地址或关键词"){
		str=str.replace("{1}",encodeURI(key));
		str=str.replace("{1}",encodeURI(key));
	}else{
		str=str.replace("{1}","");
		str=str.replace("{1}","");
	}
	window.location=str;
	//window.open(str);
}

/*加在页面的最后
<script type="text/javascript">
	GetArea(1); // 传城市Id
</script>

<script type="text/javascript">
	Event.observe('apf_id_8stat_blank', 'mouseover', function(event) {
		new Listing_Property_SearchBar_Blank().display('apf_id_8stat','apf_id_8stat_blank');
	});
</script>

<script type="text/javascript">
	Event.observe('apf_id_8area_blank', 'mouseover', function(event) {
		new Listing_Property_SearchBar_Blank().display('apf_id_8area','apf_id_8area_blank');
	});
</script>

<script type="text/javascript">
	var s_b = new Listing_Propertys_SearchBr_Selector();
	s_b.initblock('apf_id_8block','searchbar_p2','apf_id_8block_blank');
</script>

<script type="text/javascript">
	Event.observe('apf_id_8block_blank', 'mouseover', function(event) {
		new Listing_Property_SearchBar_Blank().display('apf_id_8block','apf_id_8block_blank');
	});
</script>

<script type="text/javascript">
	Event.observe('apf_id_8model_blank', 'mouseover', function(event) {
		new Listing_Property_SearchBar_Blank().display('apf_id_8model','apf_id_8model_blank');
	});
</script>

<script type="text/javascript">
	Event.observe('apf_id_8saleprice_blank', 'mouseover', function(event) {
		new Listing_Property_SearchBar_Blank().display('apf_id_8saleprice','apf_id_8saleprice_blank');
	});
</script>

<script type="text/javascript">
	Event.observe('apf_id_8rentprice_blank', 'mouseover', function(event) {
		new Listing_Property_SearchBar_Blank().display('apf_id_8rentprice','apf_id_8rentprice_blank');
	});
</script>
*/

