﻿var spBorough = document.getElementById("spBorough");
var spPlate = document.getElementById("spPlate");
var spprice = document.getElementById("spprice");
var Fitment = document.getElementById("spFitment");

SetSelectValue();
function ShowDiv(divName,ShowType)
    {             
        var divControl = document.getElementById(divName);
        var Content = "<ul>";
        switch(ShowType)
        {
            //城区
            case "Borough"://显示区域的弹出信息
                for (i=0; i<AreaBoroughList.length; i++)
			    {
				    if (AreaBoroughList[i][0] == DCityID)//[0] [1] 第一列 第二列 
				    {
				        if(i == 0)
				        {
				            Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectBorough('0','城区不限');\">不限</a></li>";
				        }
					    Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectBorough('" + AreaBoroughList[i][2] + "','" + AreaBoroughList[i][1] + "');\">" + AreaBoroughList[i][1] + "</a></li>";
					}
				}
                
                break;
				//片区
            case "Plate"://显示板块的弹出信息                        
                for (i=0; i<AreaPlateList.length; i++)
			    {			        
			        if(i == 0 && hidBorough.value != "0")
			        {			            
			            Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('0','片区不限','Plate');\">不限</a></li>";
			        }
				    if (AreaPlateList[i][0] == hidBorough.value)//[0] [1] 第一列 第二列 
				    {				        
					    Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('" + AreaPlateList[i][2] + "','" + AreaPlateList[i][1] + "','Plate');\">" + AreaPlateList[i][1] + "</a></li>";
					}
				}
                break;
         	
			//价格
           	case "price"://显示价格的弹出信息
				Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('0','价格不限','price');\">价格不限</a></li>";
             	 for (i=0; i<priceList.length; i++)
			    {			        			            
			     Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('" + priceList[i][2] + "','" + priceList[i][1] + "','price');\">" + priceList[i][1] + "</a></li>"; 
				}
			  
            break;
			
			//房屋价格
           	case "HousePrice"://显示价格的弹出信息
				Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('0','价格不限','HousePrice');\">价格不限</a></li>";
             	 for (i=0; i<HousePriceList.length; i++)
			    {			        	            
			     Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('" + HousePriceList[i][2] + "','" + HousePriceList[i][1] + "','HousePrice');\">" + HousePriceList[i][1] + "</a></li>";
			        
				}
			  
            break;
			
			//新房价格
           	case "NewPrice"://显示价格的弹出信息 
				Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('0','价格不限','NewPrice');\">价格不限</a></li>";
             	 for (i=0; i<NewHousePrice.length; i++)
			    {			        	            
			     Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('" + NewHousePrice[i][2] + "','" + NewHousePrice[i][1] + "','NewPrice');\">" + NewHousePrice[i][1] + "</a></li>";
			        
				}
			  
            break;
			
			//装修
           	case "Fitment"://显示装修的弹出信息 
				 Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('0','装修不限','Fitment');\">装修不限</a></li>";
             	 for (i=0; i<FitmentList.length; i++)
			    {			        		            
			     Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('" + FitmentList[i][0] + "','" + FitmentList[i][1] + "','Fitment');\">" + FitmentList[i][1] + "</a></li>";  
				}
			  
            break;
			
			//房屋类型
           	case "House"://显示房屋类型的弹出信息                        
             	 for (i=0; i<HouseClass.length; i++)
			    {			        
			       			            
			     Content += "<li><a href=\"javascript:void(0);\" onClick=\"javascript:SelectValue('" + HouseClass[i][2] + "','" + HouseClass[i][1] + "','House');\">" + HouseClass[i][1] + "</a></li>";
			        
				}
			  
            break;
        }
			

        Content += "</ul>";
		divControl.innerHTML = Content;
		divControl.style.display = "block";
	}
	 
    function HideDiv(divName)
    {
        var divControl = document.getElementById(divName)
        divControl.style.display = "none";
    }
   
   //城区连动 
    function SelectBorough(boroughId,boroughName)
    {
        document.getElementById("Borough").style.display = "none";
        hidBorough.value = boroughId;        
        spBorough.innerHTML = boroughName;
               
        spPlate.innerHTML = "片区不限";
        hidPlate.value = "0";
		
    }
	
	
    //显示
    function SelectValue(id,name,controlName)
    {
        document.getElementById(controlName).style.display = "none";
		var ucName = "SearchBar1_";
		var ConValues=id;
        var hidControl = document.getElementById(ucName + "hid" + controlName);
        var spControl = document.getElementById("sp" + controlName);
        if(hidControl == null)
        {
            hidControl = "0";
			//hidControl = hidPrice
        }
        hidControl.value = id;        
        spControl.innerHTML = name; 
		
		if (ConValues=='HireHouse'){
			document.getElementById("spNewPrice").style.display='none';
			document.getElementById("spprice").style.display='none';
			document.getElementById("spHousePrice").style.display='';
		}
		
		if (ConValues=='NewHouse'){
			document.getElementById("spNewPrice").style.display='';
			document.getElementById("spprice").style.display='none';
			document.getElementById("spHousePrice").style.display='none';
		}
		
		if (ConValues=='OldHouse'){
			document.getElementById("spprice").style.display='';
			document.getElementById("spHousePrice").style.display='none';
			document.getElementById("spNewPrice").style.display='none';
		}
		
    }   
    

   function SetSelectValue()
   {    
        if(hidBorough.value != "0")
        {
            spBorough.innerHTML = spBoroughinnerHTML;
        }
        
        if(hidPlate.value != "0")
        {
            spPlate.innerHTML = spPlateinnerHTML;
        }
		
    }