﻿var _c = _h = 0;
var num = 0;
$H(function(){
    $H('#play > a').click(function(){
        var i = $H(this).attr('alt') - 1;
        clearInterval(_h);
        _c = i;
        play();
        change(i);      
    })
    $H("#pic img").hover(function(){clearInterval(_h)}, function(){play()});
})
function play(){
    if(bHouse.n!=1){
        _h = setInterval("auto()", 3000);
    }
}
function change(i){
    $H('#play > a').removeClass('pick').eq(i).addClass('pick').blur();
    $H("#pic img").hide().eq(i).fadeIn('slow');
}
function auto(){    
    if(bHouse.n==1){
        _c = 0;
    }else{
        _c = _c > bHouse.n-2 ? 0 : _c + 1;
    }
    change(_c);
}

var priceRange=["60万以下","60-100万","100-150万","150-300万","300万以上"];
var areaRange=["60㎡以下","60-90㎡","90-140㎡","140㎡以上"];
var unitPriceRange=["6000元/㎡以下","6000-10000元/㎡","10000-15000元/㎡","15000元/㎡以上"];

var bHouse = {
    //隐藏对象
    n :0,
    houseListArray : new Array(),
    lastShowMap : null,
    CloseDom : function(obj,id){
        bHouse.houseListArray['drop'+id].hide();
        obj.style.display = "none";
    },
    initHouseListItem : function(id){
        bHouse.houseListArray['drop'+id]=new DropDownPanel('itemDrop'+id,'itemDropPane'+id,'');
    },//隐藏小地图
    hidePopMap : function(id){
        houseListArray['drop'+id].hide();
    },//列表显示小地图
    showPopMap : function(e,id,x,y,type){
        e=e||window.event;
        var obj =null;
        if(e)obj=e.srcElement||e.target;
        if(obj && obj.tagName && obj.tagName.toLowerCase()=="a" || obj && obj.tagName.toLowerCase()=="img" ) return;
        if(bHouse.lastShowMap && bHouse.lastShowMap!=bHouse.houseListArray['drop'+id]){
            bHouse.lastShowMap.hide();
        }
        if(!x || !y || (x==0 && y==0)){
                return;
        }else{
             if(!bHouse.houseListArray['drop'+id]){bHouse.initHouseListItem(id);}
             bHouse.lastShowMap=bHouse.houseListArray['drop'+id];
             var url = null;
             switch(type){
                case "new":
                    url = "/house/newhousemap_"+id+".html";
                    break;
                case "lease":
                    url = "/house/leasemap_"+id+".html";
                    break;
                case "trade":
                    url = "/house/trademap_"+id+".html";
                    break;
             }
             $P("gotoBigmap").href = url;
             $P("mapClose").href ="javascript:bHouse.CloseDom($P('pageMapSmall'),"+id+")";
             if(bHouse.houseListArray['drop'+id]){
                bHouse.houseListArray['drop'+id].showEle($P('pageMapSmall'));
             }
             PageMap.setCenter(x,y);
        }
    },
    KeyEvent : function(e){
            if(e.keyCode==13){
               submitSel(); 
            if (window.event){e.returnvalue=false;e.cancelBubble=true;return false;}else{e.preventDefault(); return false;}
            }
        },
    //获取评论
    getCommentContent : function(page,id,type,issub,container){
            var url = "/com/ajaxComment.aspx?id="+id+"&type="+type+"&issub="+issub+"&page="+page;
            var strCon = Methods.getAjaxStr(url);
            var bs = "bHouse.getCommentContent(__0__,"+id+",'"+type+"','false','"+container+"')";
            $P(container).innerHTML = bHouse.getContent(strCon,bs,page);
            
    },//提交评论
    submitComment : function(page,id,type,issub,container,jt,pt,hj,wy,content){
        if(content == ""){
            alert("评论内容不能为空！");
            return;
        }
        var url = "/com/ajaxComment.aspx?id="+id+"&type="+type+"&issub="+issub+"&jt="+jt+"&pt="+pt+"&hj="+hj+"&wy="+wy+"&page="+page+"&content="+escape(content);
        alert("添加评论成功！");
        $P("ComContent").value = "";
        var strCon = Methods.getAjaxStr(url);
        var bs = "bHouse.getCommentContent(__0__,"+id+",'"+type+"','false','"+container+"')";
        $P(container).innerHTML = bHouse.getContent(strCon,bs,1);
    },//获取留言
    getMessageContent : function(page,id,type,issub,container){
        var url = "/com/ajaxMessage.aspx?id="+id+"&type="+type+"&issub="+issub+"&page="+page;
        var strCon = Methods.getAjaxStr(url);
        var bs = "bHouse.getMessageContent(__0__,"+id+",'"+type+"','false','"+container+"')";
        $P(container).innerHTML = bHouse.getContent(strCon,bs,page);
    },//提交留言信息
    submitMessage : function(id,type,issub,container,content,quoteid){
        if(content == ""){
            alert("留言内容不能为空！");
            return;
        }
		//id 信息ID
		//type 用户还是VIP　
		//qid 用户ID
        var url = "/com/ajaxMessage.aspx?id="+id+"&type="+type+"&issub="+issub+"&content="+escape(content)+"&qid="+quoteid;
        alert("添加留言成功！");
		window.open(url);
        $P("quoteText").innerText = "";
        $P("quoteText").value = "";
        $P("ComContent").value = "";
        var strCon = Methods.getAjaxStr(url);
        var bs = "bHouse.getMessageContent(__0__,"+id+",'"+type+"','false','"+container+"')";
        $P(container).innerHTML = bHouse.getContent(strCon,bs,1);
    },
    getContent : function(content,_baseScript,page){
        var ctx = new Array();
        var num = content.match("\\d+");
        ctx[ctx.length] = content.replace(content.match("#\\d+#"),"");
        var pageObj = new PagerObj(num, page, 5);
        pageObj.baseScript = _baseScript;
        ctx[ctx.length] = pageObj.MapBuildPager();
        return ctx.join('');
    },//加载360看房cfg.js
    InitKf : function(cityDomain,houseType,id){
        //var showUrl = "house/new/kf360.aspx?title=&type="+houseType+"&id="+id+"&sid=";
        var first = "http://res.fangtuwang.com/fullimg/"+cityDomain+"/"+houseType+"/"+id + "/";
        var oformat = "<a target=\"_blank\" href=\"{0}\">{1}</a>";
        var url = first + "cfg.js";
        var ctx = new Array();
        var ht = null;
        switch(houseType.toLowerCase())
        {
            case "building": ht="bld";break;
            case "trade": ht="tra";break;
            case "lease":ht="lea"; break;            
        }
        Methods.loadJS(url,"fc360-"+id,fc360Loaded);
        function fc360Loaded(){
            if(!(fullImgVar && fullImgVar[ht+id]))return;
            for(var i=0;i<fullImgVar[ht+id].length;i++){
                //ctx[ctx.length] = oformat.replace("{0}",first+fullImgVar[ht+id][i].id).replace("{1}",fullImgVar[ht+id][i].title);//title="+escape(fullImgVar[ht+id][i].title)+"&
                ctx[ctx.length] = oformat.replace("{0}","/house/kf360.aspx?type="+houseType+"&id="+id+"&sid="+fullImgVar[ht+id][i].id).replace("{1}",fullImgVar[ht+id][i].title);
            }
            $P("kf360").innerHTML =　$P("kf360").innerHTML　+ ctx.join('');
        }
    },
    setOptionClass : function(){
        var OpArr = new Array();
        var currUrl = window.location.href;
        OpArr = Methods.getAllParams(currUrl);
        if(OpArr != null){
            for(j = 0;j < OpArr.length;j ++ ){
                if(OpArr[j] == "k"){
                    $H('#key').focus().val(unescape(Methods.getURLParam(currUrl,'k')));
                    if($P("k"))
                    {
                        $H('#k').focus().val(unescape(Methods.getURLParam(currUrl,'k')));
                    }
                }
                else if(OpArr[j] == "odb"){
                    var orderValue = Methods.getURLParam(currUrl,"odb");
                    if(orderValue.trim() != ''){
                        var ArrOrder = new Array();
                        ArrOrder = orderValue.split("-");
                        //$P(ArrOrder[0]).className = "Order" + (ArrOrder[1] == 0 ? "" : ArrOrder[1]) ;
                    }
                }
                else if(OpArr[j] == "peer"){
                    index = Methods.getURLParam(currUrl,OpArr[j]) == 80 ? 2 : (Methods.getURLParam(currUrl,OpArr[j]) == 40 ? 1 : 0);
                    for(i = 0;i<3;i++){
                        $P("peer"+i).className = "show_num";
                    }
                    $P("peer"+index).className = "show_num_pick";
                }
                else if(OpArr[j] == "regioncode"){
                    index = Methods.getURLParam(currUrl,OpArr[j]);
                    if(index && index != ""){$P("rg"+index).className = "pick";$P("rg0").className=""}else{$P("rg0").className="pick"}
                }
                else if(OpArr[j]=="bp"){
                    index = Methods.getURLParam(currUrl,OpArr[j]);
                    if(index && index != ""){
                        if($P("p"+index))
                        {
                            $P("p"+index).className = "pick";$P("p0").className=""
                        }
                        values = index.split("-");
                        if(values[0])$P("sprice").value = values[0];
                        if(values[1])$P("eprice").value = values[1];
                    }else{
                        $P("p0").className="pick"
                    };
                }
            }
        }
    },
    classChange : function(key,index){
        for(i = 0;i < 20;i ++ ){
            if($P(key + i)){
                $P(key + i).className = "";
            }
            else{
                break;
            }
        }
        if($P(key + index))$P(key + index).className = "quick_s_pick";
    },
    askPublish : function(){
        if($P("head_publish")){
            if($P("head_publish").style.display == "none"){$P("head_publish").style.display="block";}else{$P("head_publish").style.display="none";}
        }
    },
    LoadFlash : function(containerId,id,w,h,bt,pt,mt,ct,mon,pit){
        var url = encodeURIComponent("/com/getchartdata.aspx?id="+id+"&w="+w+"&h="+h+"&bt="+bt+"&pt="+pt+"&mt="+mt+"&ct="+ct+"&mon="+mon+"&pit="+pit);     
        Methods.createChart(containerId,url);
    },
    LoadPieFlash:function(flashContainerId,id,w,h,bt,pt,mt,ct,mon,pit,descContainerId)
    {
        //flash加载
        var url = "/com/getchartdata.aspx?id="+id+"&w="+w+"&h="+h+"&bt="+bt+"&pt="+pt+"&mt="+mt+"&ct="+ct+"&mon="+mon+"&pit="+pit; 
        Methods.createChart(flashContainerId,encodeURIComponent(url),w,h);    
        try{
            var selType = null;           
            var resultArr = new Array();
            var result= Methods.getAjaxStr(url,true);            
            eval("var data ="+result);
            var dataArr = data.elements[0].values;   
            switch(pit)
            {
                case 0:selType=priceRange;break;//总价
                case 1:selType=unitPriceRange;break;//均价
                case 2:selType=areaRange;break;//面积
            }    
            if(mt=='trade'){        
                for(i=0;i<dataArr.length;i++)
                {                              
                  resultArr[resultArr.length] = "<input type='button' value='' class='ccolor"+(i+1)+"'/> "+selType[i]+"  成交<span class='f4'>"+dataArr[i].value+"</span>套 占<span class='f1'>"+dataArr[i].label+"</span><br/> ";
                }
            }else{
                for(i=0;i<dataArr.length;i++)
                {                              
                  resultArr[resultArr.length] = "<input type='button' value='' class='ccolor"+(i+1)+"'/> "+selType[i]+"  <span class='f4'>"+dataArr[i].value+"</span>个楼盘 占<span class='f1'>"+dataArr[i].label+"</span><br/> ";
                }
            }
            $P(descContainerId).innerHTML =resultArr.join(""); 
            for(i=0;i<10;i++)
            {
                if($P(mt+i)==null) break;
                $P(mt+i).className="";                 
            }            
            $P(mt+pit).className="pick";
        }
        catch(e)
        {}
    }
}


///
///积分相关处理
///
var scoreGrade={ 
    red:"<a href='http://www.fangtoo.com/about/integral_intro.html'target='_blank'><img src='/content/images/grade_heart.gif' title='(_sc_分)'></a>",   
    yellow:"<a href='http://www.fangtoo.com/about/integral_intro.html'target='_blank'><img src='/content/images/grade_diamond.gif' title='(_sc_分)'></a>",
    blue:"<a href='http://www.fangtoo.com/about/integral_intro.html'target='_blank'><img src='/content/images/grade_crown.gif' title='(_sc_分)'></a>",   
     
    getGradeImg:function(score)
    {        
        if(score<0) return "";       
        var result="";
        if(score>=0 && score<4000)            {result=scoreGrade.makeGradeImg(scoreGrade.red.replace("_sc_",score),1);}
        else if(score>=4001 && score<6000)    {result=scoreGrade.makeGradeImg(scoreGrade.red.replace("_sc_",score),2);}            
        else if(score>=6001 && score<8000)    {result=scoreGrade.makeGradeImg(scoreGrade.red.replace("_sc_",score),3);}
        else if(score>=8001 && score<12000)   {result=scoreGrade.makeGradeImg(scoreGrade.red.replace("_sc_",score),4);}
        else if(score>=12001 && score<16000)  {result=scoreGrade.makeGradeImg(scoreGrade.red.replace("_sc_",score),5);}
        else if(score>=16001 && score<22000)  {result=scoreGrade.makeGradeImg(scoreGrade.yellow.replace("_sc_",score),1);}
        else if(score>=22001 && score<28000)  {result=scoreGrade.makeGradeImg(scoreGrade.yellow.replace("_sc_",score),2);}
        else if(score>=28001 && score<36000)  {result=scoreGrade.makeGradeImg(scoreGrade.yellow.replace("_sc_",score),3);}
        else if(score>=36001 && score<50000)  {result=scoreGrade.makeGradeImg(scoreGrade.yellow.replace("_sc_",score),4);}
        else if(score>=50001 && score<80000)  {result=scoreGrade.makeGradeImg(scoreGrade.yellow.replace("_sc_",score),5);}            
        else if(score>=80001 && score<110000)   {result=scoreGrade.makeGradeImg(scoreGrade.blue.replace("_sc_",score),1);}
        else if(score>=110001 && score<150000)  {result=scoreGrade.makeGradeImg(scoreGrade.blue.replace("_sc_",score),2);}
        else if(score>=150001 && score<200000)  {result=scoreGrade.makeGradeImg(scoreGrade.blue.replace("_sc_",score),3);}
        else if(score>=200001 && score<260000)  {result=scoreGrade.makeGradeImg(scoreGrade.blue.replace("_sc_",score),4);}
        else if(score>=260001)  {result=scoreGrade.makeGradeImg(scoreGrade.blue.replace("_sc_",score),5);} 
        return result;
    },
    makeGradeImg:function(imgStr,num)
    {
        var imgList = "";
        for(i=0;i<num;i++)
        {
            imgList += imgStr; 
        }       
        return imgList;
    }       
}
//地图搜索
/*******************Modify by Yyl****************************************/
/*******************Date:2008-09-03**************************************/
var mapSearch=
{
    _type:"",
    iPageIndex:1,
    goToStation : function(l,b,bhId,CName)
    {
        if(PageMap.mapB){
            PageMap.mapB.showPane = true;
            PageMap.mapB.showFlagPane(l,b,bhId,CName);
        }
    },
    mapInit:function()
    {
        mapSearcher = new FtMapSearch();
        mapSearcher.onMapSearchResponse = mapSearch.searchMapPositionResponse;
    },
    getDataByKeyword:function(pageIndex)
    {
        var url ="/House/DataOffer.aspx";
        url = Methods.editParam(url,"page",pageIndex);
        url = Methods.editParam(url,"k",$P('kmap').value.trim());
        url = Methods.editParam(url,"ajax","yes");
        url = Methods.editParam(url,"type","jsonbuildinglist");
        return Methods.getAjaxStr(url);
    },
    searchMapPosition:function(pageIndex,k,type)
    {
        //alert(null);
        if(k=='' || k=='请输入关键词')
        {
		    alert('必须输入起关键字');
		    return;
	    }
	    else
	    {
	        $P("kmap").value = k;
	    }
	    mapSearcher.searchMap("杭州市",k,10,pageIndex);
	    mapSearcher.setType(FtMapSearch.Position);
	    _type=type;
	    iPageIndex = pageIndex;
	    if(type=="trade"||type=="lease")
	        $P("ContainerHouse").style.display ="none";
	    $P("ContainerDiv").innerHTML = "<img src='/content/images/loading.gif' title='正在检索数据...'/>正在检索位置信息....";
	    $P("ContainerDiv").display="";
    },
    searchMapPositionResponse:function(data)
    {
        var gettingData;
        gettingData = mapSearch.getDataByKeyword(data.pageNum);
        eval(gettingData);
        var ctx = new Array();
        var go = false;
        var i;
        pagecount = parseInt(data.totalCount % data.peer == 0?data.totalCount/data.peer : data.totalCount/data.peer + 1);
	    if(_type == "trade"||_type=="lease")
	    {
	        if(_type=="trade")
	            FCConfig.houType=1;
	        else
	            FCConfig.houType=2;
	        head ="<div class=\"map_menu\">"	+
		    "<ul class=\"set_map_menu\">"	+
		    "    <li><a href=\"javascript:MapHouse.getHouseList();\">"+(FCConfig.houType==1?"二手房":"出租房")+"</a></li>"	+
		    "    <li><a class=\"map_menu_pick\" href=\"#\">位置</a></li>"	+
		    "</ul>"	+"\n"+
		    "<div class=\"set_map_right\">"	+
		    "    <a class=\"tb_detail_type\" href=\""+(FCConfig.houType==1?"/house/trade/":"/house/lease/")+"\" target=\"_blank\">老版找房模式</a></div>"	+
		    "</div>"	+
		    "<div class=\"set_page\">"	+
		    "    <div class=\"set_left\">"+
		    "        <span>搜索 <strong>"+$P("kmap").value+"</strong> 共"+data.totalCount+"条&nbsp;第"+data.pageNum+"/"+pagecount+"页</span>"	+
		    "    </div>"	+"\n"+
		    "</div>"	+"\n"+
		    "<div id=\"ftBusSearchContainer\">"	+"\n";
        }
        else if(_type=="new")
        {
	         head =		"            <div class=\"map_menu\">"	+
		        "                <ul class=\"set_map_menu\">"	+
		        "                    <li><a href=\"javascript:NewHouse.ajaxSearch(1,'','');\">所有楼盘</a></li>"	+
		        "                    <li><a class=\"map_menu_pick\" href=\"#\">位置</a></li>"	+
		        "                </ul>"	+"\n"+
		        "                <div class=\"set_map_right\">"	+
		        "                    <a class=\"tb_detail_type\" href=\"/house/new/list\" target=\"_blank\">详细表格模式</a></div>"	+
		        "            </div>"	+
		        "            <div class=\"set_page\">"	+
		        "                <div class=\"set_left\">"+
		        "                    <span>搜索 <strong>"+$P("kmap").value+"</strong> 共"+data.totalCount+"条&nbsp;第"+data.pageNum+"/"+pagecount+"页</span>"	+
		        "                </div>"	+"\n"+
		        "            </div>"	+"\n"+
		        "            <div id=\"ftBusSearchContainer\">"	+"\n";
       }
	    ctx[ctx.length] = head; 
	    ctx[ctx.length] = "<div id=\"ftBusSearchContainerMap\">";
	    var temp;
	    var body="<div class=\"mapPosionItem\" onmouseover=\"this.className=\'mapPosionItemOver\'\" onclick=\"javascript:mapSearch.goToStation({2},{3},{7},{8});\" onmouseout=\"this.className=\'mapPosionItem\'\">"
                    + "<div class=\"mapPosionItemName\">"	
                    +"{0}"+".<a title=\""+"{1}"+"\" href=\"javascript:mapSearch.goToStation({2},{3},{7},{8});\">"+"{4}"+"</a>{6}"	
                    +"</div>"+"<div class=\"mapPosionItemAddr\">"	
                    +"{5}"+"</div>"+"</div>";
	    if(parseInt(data.pageNum) < (parseInt(BuildingList["PageItem"])/parseInt(BuildingList["PageSize"])))
        {
            for(i=0;i<data.peer;i++)
            {
                var mp = FtMap.eMapToGis(BuildingList["List"][i]["PosX"],BuildingList["List"][i]["PosY"]);
                if(!go)
                {
                    mapSearch.goToStation(mp.l,mp.b,BuildingList["List"][i]["bhId"],"'"+BuildingList["List"][i]["BuildingName"]+"'");
                    go = true;
                }
                temp = body;
                temp = mapSearch.format(temp,(i+1),"",mp.l,mp.b,BuildingList["List"][i]["BuildingName"],BuildingList["List"][i]["Addr"],"[精确定位]",BuildingList["List"][i]["bhId"],"'"+BuildingList["List"][i]["BuildingName"]+"'");
                ctx[ctx.length] = temp;                
            }
        }
        else if(parseInt(data.pageNum) == Math.ceil(parseInt(BuildingList["PageItem"])/parseInt(BuildingList["PageSize"])))
        {
            var num = parseInt(BuildingList["PageItem"]) 
                        - Math.floor(parseInt(BuildingList["PageItem"])/parseInt(BuildingList["PageSize"]))*(parseInt(BuildingList["PageSize"]));
            for(i=0;i<num;i++)
            {
                var mp = FtMap.eMapToGis(BuildingList["List"][i]["PosX"],BuildingList["List"][i]["PosY"]);
                 if(!go)
                {
                    mapSearch.goToStation(mp.l,mp.b,BuildingList["List"][i]["bhId"],"'"+BuildingList["List"][i]["BuildingName"]+"'");
                    go = true;
                }
                temp = body;
                temp = mapSearch.format(temp,(i+1),"",mp.l,mp.b,BuildingList["List"][i]["BuildingName"],BuildingList["List"][i]["Addr"],"[精确定位]",BuildingList["List"][i]["bhId"],"'"+BuildingList["List"][i]["BuildingName"]+"'");
                ctx[ctx.length] = temp;        
            }
            if(data.length>=data.peer-num)
            {
                for(i=0;i<data.peer-num;i++)
                {

                    temp = body;
                    temp = mapSearch.format(temp,(i+1),data[i].type,data[i].point.l,data[i].point.b,data[i].name,data[i].addr,"[模糊定位]",0,"'"+data[i].name+"'");
                    ctx[ctx.length] = temp;             
                }
            }
            else
            {
                for(i=0;i<data.length;i++)
                {
                    temp = body;
                    temp = mapSearch.format(temp,(i+1),data[i].type,data[i].point.l,data[i].point.b,data[i].name,data[i].addr,"[模糊定位]",0,"'"+data[i].name+"'");
                    ctx[ctx.length] = temp;     
                }
            }
        }
        else if(parseInt(data.pageNum) > (parseInt(BuildingList["PageItem"])/parseInt(BuildingList["PageSize"])))
        {
            for(i=0;i<data.length;i++)
            {
                if(!go)
                {
	                mapSearch.goToStation(data[i].point.l,data[i].point.b,0,data[i].name);
	                go=true;
	            }

                 temp = body;
                 temp = mapSearch.format(temp,(i+1),data[i].type,data[i].point.l,data[i].point.b,data[i].name,data[i].addr,"[模糊定位]",0,"'"+data[i].name+"'");
                 ctx[ctx.length] = temp; 
            }
        } 
	    ctx[ctx.length] ="</div>";
	    var tnum;
	    if(parseInt(data.totalCount)>100)
	    {
	        tnum = 100;
	    }
	    else
	    {
	        tnum = parseInt(data.totalCount);
	    }
	    var pageObj = new PagerObj(parseInt(tnum), parseInt(data.pageNum), parseInt(data.peer));
	    pageObj.baseScript = "mapSearch.searchMapPosition(__0__,'"+$P("kmap").value+"')";
	    ctx[ctx.length] = pageObj.MapBuildPager();
	    ctx[ctx.length] = "</div>";
	    $P("ContainerDiv").innerHTML = ctx.join('');
    },
    format:function() 
    {
        if( arguments.length == 0 )
            return null; 

        var str = arguments[0]; 
        for(var i=1;i<arguments.length;i++) 
        {
            var re = new RegExp('\\{' + (i-1) + '\\}','gm');
            str = str.replace(re, arguments[i]);
        }
        return str;
    }
}
/***************************************************************/


/****************************Cookie操作***********************************/ 
 var oCookie = { 
 //添加Cookie
  setCookie:function(sName, sValue, oExpires, sPath, sDomain, bSecure) {
      var sCookie = sName + "=" + encodeURIComponent(sValue);  
      if (oExpires) {
          sCookie += "; expires=" + oExpires.toUTCString();
      }  
      if (sPath) {
          sCookie += "; path=" + sPath;
      }  
	  
      if (sDomain) {
          sCookie += "; domain=" + sDomain;
      }  
      if (bSecure) {
          sCookie += "; secure";
      }  
	  
      document.cookie = sCookie;
  },
          
//读取Cookie                                
 getCookie:function(sName) { 

     var sRE = "(?:; )?" + sName + "=([^;]*);?";
     var oRE = new RegExp(sRE);
     if (oRE.test(document.cookie)) {      
         return decodeURIComponent(RegExp["$1"]);
		  
     } else {
         return "";
     } 
 }, 
 getCookieByName:function(name){
	    var arg = name + "=";  
	    var alen = arg.length;  
	    var clen = document.cookie.length;  
	    var i = 0;
	    while (i < clen) 
	    {    
		    var j = i + alen;    
		    if (document.cookie.substring(i, j) == arg)      
		    return oCookie.getCookieVal (j);    
		    i = document.cookie.indexOf(" ", i) + 1;    
		    if (i == 0) break;   
	    }  
	    return null;
},
getCookieVal:function(offset){
	var endstr = document.cookie.indexOf(";", offset);
	if(endstr == -1){
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
},
                
//删除Cookie
 deleteCookie:function(sName, sPath, sDomain) {
     var sCookie = sName + "=; expires=" + (new Date(0)).toGMTString();
     if (sPath) {
         sCookie += "; path=" + sPath;
     } 
     if (sDomain) {
         sCookie += "; domain=" + sDomain;
     }     
     document.cookie = sCookie;
 }
 };
 
 //最新浏览房源列表
 var oHouseCookie = {
        //个数   
        count:10,  
        ///  根据房源类型获取cookie名称        
        GetCookieName:function(houseType)
        {
            var cookieName = null;
            switch (houseType)
            {
                case 1: cookieName = "leaHouseList"; break;
                case 2: cookieName = "traHouseList"; break;
            }
            return cookieName;
        }, 
      
        // 存储最近浏览房源   
        // 房源类型(1 置换房 2 出租房 3 新楼盘)
        SetRecentVisitedHouse:function(houseInfo,houseType)
        {
            if (houseInfo.trim()!="" && houseType > 0 && houseType<7)
            {              
                
				var cookieHouseList = null;
                var cookieName = oHouseCookie.GetCookieName(houseType);    
                //已经浏览的房源列表
                cookieHouseList = oHouseCookie.GetRecentVisitedHouseList(houseType,true);             
                if (cookieHouseList.trim()=="")
                {//当前没有游览记录
					cookieHouseList = houseInfo;
                }
                else
                {
                    
					if (cookieHouseList.indexOf(houseInfo) >= 0)
                    {//是否已经存在当前浏览记录
						
						if (cookieHouseList.indexOf(houseInfo+"_0_") != -1) 
                        { 
                            cookieHouseList=cookieHouseList.replace(houseInfo+"_0_", ""); 
                        }
                        else if(cookieHouseList.indexOf("_0_"+houseInfo) != -1)
                        {
                            cookieHouseList=cookieHouseList.replace("_0_" + houseInfo, "");                            
                        } 
                        else
                        { 
                            cookieHouseList=cookieHouseList.replace(houseInfo, "");  
                        }                       
                    }                     
                    var ArrHouse = cookieHouseList.split("_0_");                  
                    if (ArrHouse.length >= oHouseCookie.count)
                    { //是否超出6个
						cookieHouseList = ArrHouse.slice(0,oHouseCookie.count-1).join("_0_");
                    }
                    if (cookieHouseList.trim()=="") { cookieHouseList = houseInfo; }
                    else { cookieHouseList = houseInfo + "_0_" + cookieHouseList; }                    
                }   
                var oDate = new Date();                
                oDate.setDate(oDate.getDate()+7);  
                oCookie.setCookie(cookieName,cookieHouseList,oDate,"/");
				//setCookie:function(sName, sValue, oExpires, sPath, sDomain, bSecure) {
            }
        },
       
        // 获取最近浏览过的房源列表 
        // <param name="isSp">是否保留分割符号(是：true;否:false)</param>
        GetRecentVisitedHouseList:function(houseType,isSp)
        {
            if (houseType > 10 || houseType < 1) return null;
            var cookieName =oHouseCookie.GetCookieName(houseType);            
            if (isSp)
            {
                return oCookie.getCookie(cookieName);
            }
            else
            {                
                return oCookie.getCookie(cookieName).replace(/_0_/g, "");
            }
        }
 }
/*************************************************************************/

/*************************************************************************/
/*首页滚动
/*2008.9.23
/*************************************************************************/
function ScrollObj(obj,objName,msgScrollDelay,msgScreenDelay,lines,cTagName)
{
    this.target = $P(obj);
    this.objStr = objName; 
    //子元素标签名
    this.cTagName = cTagName;
    this.target.style.overflow = "hidden";   
    
    this.msgMinIndex = 0;
    this.msgCnt = this.target.getElementsByTagName(this.cTagName).length; 
    this.lines = lines;
    this.msgMaxIndex = Math.floor(this.msgCnt/this.lines) - 1;
    this.msgIndex = this.msgMinIndex - 1; 
    //计算单条记录的高度
    var odl = this.target.getElementsByTagName(this.cTagName)[0];   
    var oStyle = null;
    if(odl)
    {
    if(window.getComputedStyle) {  oStyle = window.getComputedStyle(odl,"");   }
    else {  oStyle = odl.currentStyle;  }   
    this.msgItemHeight = odl.offsetHeight+ (isNaN(parseInt(oStyle.marginTop))?0:parseInt(oStyle.marginTop))+ (isNaN(parseInt(oStyle.marginBottom))?0:parseInt(oStyle.marginBottom));
    }
    else{this.msgItemHeight=0;}  
    this.msgScrollDelay = msgScrollDelay; //滚动延迟时间
    this.msgScreenDelay = msgScreenDelay; //一屏延迟时间
    var inst = this;
    inst.CloneMsgData();  
    this.target.onmouseover = function(){inst.Suspended();};
    this.target.onmouseout = function(){inst.Resume();};   
    this.timer = null;   
}

ScrollObj.prototype.CloneMsgData = function()
{   
    if(this.msgCnt*this.msgItemHeight<parseInt(this.target.style.height)) return; 
    var msgData = this.target.getElementsByTagName(this.cTagName);
    for(i=0;i<this.msgCnt;i++)
    {
        this.target.appendChild(msgData[i].cloneNode(true));
    }    
}

ScrollObj.prototype.ShowContentUp=function()
{    
     if (this.msgIndex > this.msgMaxIndex)
    {       
        //一个周期已经滚完，从头再开始
        this.msgIndex = 0;
        this.target.scrollTop = 0;
    }

    if (this.target.scrollTop < (this.msgIndex+1)*this.msgItemHeight*this.lines)
    {
        //一屏(滚动条数为单位)还没有滚到头
        this.target.scrollTop++;       
        this.timer = setTimeout(this.objStr+".ShowContentUp();", this.msgScrollDelay);
    }
    else
    {
        //一屏(滚动条数为单位)已经滚完，继续下一屏
        this.msgIndex++;
        this.timer = setTimeout(this.objStr+".ShowContentUp();", this.msgScreenDelay);
    }
}

ScrollObj.prototype.Suspended=function()
{   
    clearTimeout(this.timer);
}

ScrollObj.prototype.Resume=function()
{  
    this.ShowContentUp();
}

/*******************************************************************************************/
//用户登陆信息
var UserInfo = {
    adminUrl : "",
    LoginOut : function(){
        Methods.loadJS("http://user.fdushi.com/com/jsonlogin.htm?t=1",
                          "loginJs",
                    function(data) {
                        if (typeof (JSONLogin) != "undefined") {
                            alert(JSONLogin.messge);
                            if (JSONLogin.logined == "True") {
                                $H("<img style='display:none' src="+JSONLogin.bbsurl+" />");
                            }
                        }
                    });
                    
                var ht = '<h2><span class="FreePub">免费发布：</span><a href="http://user.fdushi.com/user/LeaseHouse/Add.htm" target="_blank">出租房</a>/<a href="http://user.fdushi.com/user/TradeHouse/Add.htm" target="_blank">二手房</a>&nbsp;<a href="http://user.fdushi.com/user/leaseReq/Add.htm" target="_blank">求租</a>/<a href="http://user.fdushi.com/user/tradereq/Add.htm" target="_blank">求购</a>&nbsp;|&nbsp;<a class="IVLeaveMsg" href="http://www.fdushi.com/Message/LeaveMessage.aspx" target="_blank">访客留言</a>&nbsp;|&nbsp;<a href="javascript:addBookmark()">收藏本站</a>&nbsp;|&nbsp;<a href="javascript:SetHome(this,window.location);">设为首页</a><br />您好，欢迎来房途网！<a href="http://user.fdushi.com/home/regist.htm" target="_blank">[免费注册]</a><a href="javascript:FtUtils.login();">[登录]</a></h2>';
                $H("#LoginInfo").html(ht);
    },
    isLogin : function(){
        var _uinfo = oCookie.getCookieByName("username");
		//var _uinfo = GetCookie("kshot","username");
        if(_uinfo==null){
            return false;
        }else{
            return true;
        }
    },
    CommentStates : function(){
        var _isLogin = UserInfo.isLogin();
        if(_isLogin){
            $H("#tbComment").css("display","block");
            $H("#tblogin").css("display","none");            
        }else{
            $H("#tbComment").css("display","none");
            $H("#tblogin").css("display","block");
        }
    },
    PublishInfo : function(u){//导航免费发布
        var _isLogin = UserInfo.isLogin();
        if(_isLogin){
            window.location.href = u;
        }else{
            UserInfo.adminUrl = u;
            FtUtils.login(null,null,null,'/html/login.html',UserInfo.LocationHref);
        }
    },
    LocationHref : function(u){
        var _isLogin = UserInfo.isLogin();
        if(_isLogin){
            window.location.href = UserInfo.adminUrl;
        }
    }    
}


//网站头上的搜索框
var searchBar = {
    key : Methods.getURLParam(window.location.href,"k"),
    //类别选择
    onChangeType : function(t){
        var htmlSource = "";
        switch(t){
            case '0'://小区房价
            htmlSource = "<input type='text' name='' id='key' class='ss_txt_b' \/>";
            $H("#searchSelect").html(htmlSource);
            $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
            $H('#key').searchAuto(function(){searchBar.onSearch('0')});
            break;
            case '1'://二手房
            htmlSource= '<select class=\"f_type\" id=\"r\">'
                           +'<option selected=\"selected\" value=\"\">户型</option>'
                           +'<option value=\"1\">1室</option>'
                           +'<option value=\"2\">2室</option>'
                           +'<option value=\"3\">3室</option>'
                           +'<option value=\"4\">4室</option>'
                           +'<option value=\"5\">5室</option>'
                           +'<option value=\"6\">5室以上</option>'
                           +'</select>'  + "\n"
                           + "<input type='text' name='' id='key' class='ss_txt_m' \/>";
            $H("#searchSelect").html(htmlSource);
            $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
            $H('#key').searchAuto(function(){searchBar.onSearch('1')});
            break;
            case '2'://出租房
            htmlSource =	"<select class=\"f_type\" id=\"r\">"	+"\n"+
	                        "     <option selected=\"selected\" value=\"\">户型</option>"	+"\n"+
	                        "     <option value=\"1\">1室</option>"	+"\n"+
	                        ""	+"\n"+
	                        "     <option value=\"2\">2室</option>"	+"\n"+
	                        "     <option value=\"3\">3室</option>"	+"\n"+
	                        "     <option value=\"4\">4室</option>"	+"\n"+
	                        "     <option value=\"5\">5室</option>"	+"\n"+
	                        "     <option value=\"6\">5室以上</option>"	+"\n"+
	                        "    </select>"	+"\n"+
	                        "<input type='text' name='' id='key' class='ss_txt_s' \/>";
	        $H("#searchSelect").html(htmlSource);
	        $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
	        $H('#key').searchAuto(function(){searchBar.onSearch('2')});
            break;
            case '3'://出租房
            htmlSource =	"<select class=\"f_type\" id=\"r\">"	+"\n"+
		                    "     <option selected=\"selected\" value=\"\">户型</option>"	+"\n"+
		                    "     <option value=\"1\">1室</option>"	+"\n"+
		                    ""	+"\n"+
		                    "     <option value=\"2\">2室</option>"	+"\n"+
		                    "     <option value=\"3\">3室</option>"	+"\n"+
		                    "     <option value=\"4\">4室</option>"	+"\n"+
		                    "     <option value=\"5\">5室</option>"	+"\n"+
		                    "     <option value=\"6\">5室以上</option>"	+"\n"+
		                    "    </select>"	+"\n"+
		                    "<input type='text' name='' id='key' class='ss_txt_s' \/>";
		    $H("#searchSelect").html(htmlSource);
		    $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
		    $H('#key').searchAuto(function(){searchBar.onSearch('3')});
            break;
            case '4'://地图找房
            htmlSource =	"<select class=\"f_type\" id=\"r\">"	+"\n"+
		                    "     <option selected=\"selected\" value=\"\">户型</option>"	+"\n"+
		                    "     <option value=\"1\">1室</option>"	+"\n"+
		                    ""	+"\n"+
		                    "     <option value=\"2\">2室</option>"	+"\n"+
		                    "     <option value=\"3\">3室</option>"	+"\n"+
		                    "     <option value=\"4\">4室</option>"	+"\n"+
		                    "     <option value=\"5\">5室</option>"	+"\n"+
		                    "     <option value=\"6\">5室以上</option>"	+"\n"+
		                    "    </select>"	+"\n"+
		                    "<input type='text' name='' id='key' class='ss_txt_s' \/>";
            $H("#searchSelect").html(htmlSource);
            $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
            $H('#key').searchAuto(function(){searchBar.onSearch('4')});
            break;
            case '5'://经纪人
            htmlSource =	"<select class=\"f_type\" id=\"r\">"	+"\n"+
		                    "     <option selected=\"selected\" value=\"\">户型</option>"	+"\n"+
		                    "     <option value=\"1\">1室</option>"	+"\n"+
		                    ""	+"\n"+
		                    "     <option value=\"2\">2室</option>"	+"\n"+
		                    "     <option value=\"3\">3室</option>"	+"\n"+
		                    "     <option value=\"4\">4室</option>"	+"\n"+
		                    "     <option value=\"5\">5室</option>"	+"\n"+
		                    "     <option value=\"6\">5室以上</option>"	+"\n"+
		                    "    </select>"	+"\n"+
		                    "<input type='text' name='' id='key' class='ss_txt_s' \/>";
            $H("#searchSelect").html(htmlSource);
            $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
            break;
            case '6'://找历史成交记录
            htmlSource = "<input type='text' name='' id='key' class='ss_txt_b' \/>";
            $H("#searchSelect").html(htmlSource);
            $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
            break;
        }
        
    },
    onSearch : function(t){
        if(t){
            tp=t;
        }else{
            tp = $H("#searchType").val();
        }
        var k = $H("#key").val();
        k = k.replace(/\s+/g,"");
        var urllink = window.location.href.toLowerCase();
	    switch(tp){
	        case '0'://小区房价
	            if(k=="输入小区名、地址") k="";
	            if(urllink.indexOf("/building/buildmap")!=-1 || urllink.indexOf("/building/pricemap")!=-1){
	                currUrl = "/building/pricemap.aspx?k="+encodeURIComponent(k);
	            }else{
	                currUrl = "/building/default.aspx?k="+encodeURIComponent(k);
	            }
	            //regioncode=Methods.getURLParam(urllink,"regioncode");
	            //bp=Methods.getURLParam(urllink,"bp");
	            //if(regioncode)currUrl=currUrl+"&regioncode="+regioncode;
	            //if(bp)currUrl=currUrl+"&bp="+bp;
	            window.open(currUrl,"_self");
	        break;
	        case '1'://二手房
	            if(k=="输入小区名、地址") k="";
	            regioncode=Methods.getURLParam(urllink,"regioncode");
	            var price="";
	            if($H("#price"))price=$H("#price").val();
	            nb=Methods.getURLParam(urllink,"nb");
	            t=Methods.getURLParam(urllink,"t");
	            //if(urllink.indexOf("/house/new/newhousemap") != -1 || urllink.indexOf("/house/newhousemap") != -1){
	                //currUrl = "/house/new/newhousemap.aspx?k="+encodeURIComponent(k);
					currUrl = "/Hlist.aspx?Htype=1&r="+$H("#r").val()+"&k="+encodeURIComponent(k);	
	           // }else{
	           //     currUrl = "/house/new/newhouselist.aspx?k="+encodeURIComponent(k);
	           // }
	            //if(regioncode)currUrl+="&regioncode="+regioncode;
	            //if(price)currUrl+="&price="+price;
	            //if(t)currUrl+="&t="+t;
	            //if(nb)currUrl+="&nb="+nb;
	            window.open(currUrl,"_self");
	        break;
	        case '2'://二手房
	            if(k=="输入小区名、地址") k="";
	           // if(urllink.indexOf("/house/trademap")!=-1 || urllink.indexOf("/trade/housemap")!=-1){	            
	                currUrl = "/Hlist.aspx?Htype=2&r="+$H("#r").val()+"&k="+encodeURIComponent(k);	                
	            //}else{	            
	             //    currUrl = "/house/trade/?r="+$H("#r").val()+"&p="+$H("#p").val()+"&k="+encodeURIComponent(k);	                
	            //}	           
	            window.open(currUrl,"_self");
	        break;
	        case '3'://出租房
	            if(k=="输入小区名、地址") k="";
	            
	            //if(urllink.indexOf("/house/leasemap")!=-1 || urllink.indexOf("/lease/housemap")!=-1){	            
	               currUrl = "/Hlist.aspx?Htype=3&r="+$H("#r").val()+"&k="+encodeURIComponent(k);	                
	            //}else{	            
	            //     currUrl = "/house/lease/?r="+$H("#r").val()+"&p="+$H("#p").val()+"&k="+encodeURIComponent(k);	                
	            //}	
	            window.open(currUrl,"_self");
	        break;
	        case '4'://地图搜索
	            if(k=="输入小区名、地址") k="";
	            currUrl = "/Hlist.aspx?Htype=4&r="+$H("#r").val()+"&k="+encodeURIComponent(k);	
	            window.open(currUrl,"_self");
	        break;
	        case '5'://经纪人
	            if(k=="输入小区名、地址") k="";
	            currUrl = "/Hlist.aspx?Htype=5&r="+$H("#r").val()+"&k="+encodeURIComponent(k);	
	            window.open(currUrl,"_self");
	        break;
	        case '6'://找历史成交记录
	            if(k=="输入小区名、地址") k="";
	            currUrl = "/datastar/statinfo2.aspx?k="+encodeURIComponent(k);
	            window.open(currUrl,"_self");
	        break;
	    }
    },
onSearch2 : function(t){
        if(t){
            tp=t;
        }else{
            tp = $H("#searchType").val();
        }
        var k = $H("#key").val();
        k = k.replace(/\s+/g,"");
        var urllink = window.location.href.toLowerCase();
		if(k=="输入楼盘名、地址") k="";
	    regioncode=Methods.getURLParam(urllink,"regioncode");
	    var price="";
	            if($H("#price"))price=$H("#price").val();
	            nb=Methods.getURLParam(urllink,"nb");
	            t=Methods.getURLParam(urllink,"t");
	            //if(urllink.indexOf("/house/new/newhousemap") != -1 || urllink.indexOf("/house/newhousemap") != -1){
	                //currUrl = "/house/new/newhousemap.aspx?k="+encodeURIComponent(k);
					currUrl = "/House/Nhouse.aspx?Htype=1&k="+encodeURIComponent(k);	
	           // }else{
	           //     currUrl = "/house/new/newhouselist.aspx?k="+encodeURIComponent(k);
	           // }
	            //if(regioncode)currUrl+="&regioncode="+regioncode;
	            //if(price)currUrl+="&price="+price;
	            //if(t)currUrl+="&t="+t;
	            //if(nb)currUrl+="&nb="+nb;
	            window.open(currUrl,"_self");
    },
    //初始加载时样式定位
    onOptionClass : function(t){
        if(!t)t='0';
	    switch(t){
	        case '0'://小区房价
	            $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
	            $H('#key').searchAuto(function(){searchBar.onSearch('0')});
	        break;
	        case '1'://新楼盘
	            $H("#key").example('输入楼盘名、地址',{class_name:'fgrey'});
	            $H('#key').searchAuto(function(){searchBar.onSearch('1')});
	        break;
	        case '2'://二手房
	           $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
	           $H('#key').searchAuto(function(){searchBar.onSearch('2')});
	        break;
	        case '3'://出租房
	            $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
	            $H('#key').searchAuto(function(){searchBar.onSearch('3')});
	        break;
	        case '4'://地图搜索
	            $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
	            $H('#key').searchAuto(function(){searchBar.onSearch('4')});
	        break;
	        case '5'://经纪人
	            $H("#key").example('输入经纪人名、所属公司名',{class_name:'fgrey'});
	        break;
	        case '6'://找历史成交记录
	            $H("#key").example('输入小区名、地址',{class_name:'fgrey'});
	        break;
	    }
    }
}

var Building={ 
    regionCode:'',
    searchByRegion:function(regionCode,ismap){
        var url=window.location.href;
        //var keyword=Methods.getURLParam(url,"k");
        var bp=Methods.getURLParam(url,"bp");
        if(ismap=="map")url="/building/pricemap.aspx";
        if(!regionCode) {regionCode=Building.regionCode;} 
        url = Methods.editParam(url,'regioncode',regionCode);
        //if(keyword=="输入小区名、地址")keyword="";
        url = Methods.editParam(url,'k',"");
        url = Methods.editParam(url,'bp',bp);
         url = Methods.editParam(url,'page',"1");
        window.open(url,"_self");
    },
    GotoSearch:function(){
		
        var urllink = window.location.href;
        if(urllink.toLowerCase().indexOf("/building/pricemap.aspx")!=-1 || urllink.toLowerCase().indexOf("/building/pricemap")!=-1){
            url = "/building/pricemap.aspx";
        }else{
            url = "/building/default.aspx";
        }
        if($P("k").value=="输入小区名、地址"){k=""}else{k=$P("k").value};
        url = Methods.editParam(url,'k',k);
//        var sprice = $P("sprice").value;
//        var eprice = $P("eprice").value;
//        if(sprice=="" && eprice!= ""){
//            if(Building.isNum(eprice)){bp = '0-'+eprice}else{alert('请输入数字');bp='';return;};
//        }else if(sprice=="" && eprice==""){
//            bp = "";
//        }else if(sprice!="" && eprice!=""){
//            if(Building.isNum(sprice) && Building.isNum(eprice)){
//                bp = sprice+'-'+eprice;
//            }
//        }else if(sprice!="" && eprice==""){
//            if(Building.isNum(sprice)){bp=sprice;}else{alert('请输入数字');return;}
//        }
//        url = Methods.editParam(url,'bp',bp);
        window.open(url,"_self");
    },
    searchByPrice:function(price,ismap){
        var url=window.location.href;
        var code = Methods.getURLParam(url,"regioncode")
        if(ismap=="map")url="/building/pricemap.aspx";
//        if(!price) {price=Building.regionCode;} else {$P("k").value="";}
        url = Methods.editParam(url,'bp',price);
        url = Methods.editParam(url,"regioncode",code);
        //var keyword=$P("k").value.trim();
        //if(keyword=="输入小区名、地址")keyword="";
        url = Methods.editParam(url,'k',"");
         url = Methods.editParam(url,'page',"1");
        window.open(url,"_self");
    },
    searchByPriceDIY:function(startPrice,endPrice){
        if(startPrice && !Building.isNum(startPrice)){alert("请输入起始价格");return;}
        if(endPrice && !Building.isNum(endPrice)){alert("请输入最高价格");return;}
        var url=window.location.href;
        if(!startPrice && !endPrice)return;
        if(!startPrice)startPrice=0;
        if(!endPrice)endPrice=0;
        if(endPrice-startPrice>0){
            price=startPrice+"-"+endPrice;
        }else{
            price=startPrice;
        }
        url = Methods.editParam(url,'bp',price);
        var keyword=$P("k").value.trim();
        if(keyword=="输入小区名、地址")keyword="";
        url = Methods.editParam(url,'k',"");
         url = Methods.editParam(url,'page',"1");
        window.open(url,"_self");
    },
    KeyEvent:function(e)
    {
        if(e.keyCode==13)
        {
           Building.GotoSearch();   
        }
    },
    KeyEventPrice:function(e){
        if(e.keyCode==13)
        {
            Building.searchByPriceDIY($P('sprice').value,$P('eprice').value)
        }
    },
    isNum:function(v){
        return /^\d{1,10}$/.test(v);
    },
    eventInit : function(){
        Methods.setObjEvent($P('k'),'keypress',Building.KeyEvent);
        Methods.setObjEvent($P('sprice'),'keypress',Building.KeyEventPrice);
        Methods.setObjEvent($P('eprice'),'keypress',Building.KeyEventPrice);
    }
}

var BuildMapSearch = {
    showId : 0,
    goToStation : function(l,b,bid,CName){
        if(PageMap.mapB){
            PageMap.mapB.showPane = true;
            PageMap.mapB.showFlagPane(l,b,bid,'ff');
        }
    },
    getDataList : function(pageIndex){
        var url ="/building/pricemap.aspx";
        var url2 = window.location.href;
        //var bp = Methods.getURLParam(url2,"bp");
        var sprice = $P("sprice").value;
        var eprice = $P("eprice").value;
        if(sprice=="" && eprice!= ""){
            if(Building.isNum(eprice)){bp = '0-'+eprice}else{alert('请输入数字');bp='';return;};
        }else if(sprice=="" && eprice==""){
            bp = "";
        }else if(sprice!="" && eprice!=""){
            if(Building.isNum(sprice) && Building.isNum(eprice)){
                bp = sprice+'-'+eprice;
            }
        }else if(sprice!="" && eprice==""){
            if(Building.isNum(sprice)){bp=sprice;}else{alert('请输入数字');return;}
        }
        
        var regioncode = Methods.getURLParam(url2,"regioncode");
        url = Methods.editParam(url,"page",pageIndex);
        var ky = $P('k').value.trim();
        if(ky=="输入小区名、地址")ky="";
        url = Methods.editParam(url,"k",ky);
        url = Methods.editParam(url,"bp",bp);
        url = Methods.editParam(url,"regioncode",regioncode);
        url = Methods.editParam(url,"ajax","yes");
        url = Methods.editParam(url,"type","jsonbuildinglist");
        return Methods.getAjaxStr(url);
    },
    GoSearch : function(pageIndex){
        var gettingData;
        gettingData = BuildMapSearch.getDataList(pageIndex);
        eval(gettingData);
        var totalItem =  BuildingList["PageItem"];
        var currentIndex =  BuildingList["PageIndex"];
        var pageSize =  BuildingList["PageSize"]; 
        var ctx = new Array();
        var go = false;
        var i;
        var mapX = "0";
        var mapY = "0";
        var classname = "price_map_item";
        var imgstyle = "none";
        var hangprice = "";
        var hangrate = "";
        var body =		"<dl id=\"item{0}\" class=\"{1}\" onmouseover=\"this.className=\'price_map_item_over\'\" onclick=\"javascript:BuildMapSearch.showItem(\'{0}\',{2},{3},{4},\'{5}\');\" onmouseout=\"this.className=\'price_map_item\'\">"	+"\n"+
                        "                            <dt><strong>{5}</strong>&nbsp;&nbsp;{6}{7}"	+"\n"+
                        "                            <div style=\"display: {9};\" id=\"itemdetail{0}\"><img src=\"http://imgs.fangtuwang.com/upload/hangzhou/building/bpg/sechang_bt_sl_m_120X30_{4}.png\" /><br /></div>"	+"\n"+
                        "                            {8}"	+"\n"+
                        "                            </dt>"	+"\n"+
                        ""	+"\n"+
                        "                            <dd><a href=\"/building/{4}\" target=\"_blank\">详细</a></dd>"	+"\n"+
                        "                         </dl>"	+"\n"+
                        ""
        if(gettingData != null)
        {
            for(i in BuildingList["List"])
            {
                var mp = FtMap.eMapToGis(BuildingList["List"][i]["PosX"],BuildingList["List"][i]["PosY"]);
                if(BuildingList["List"][i]["PosX"]==""){mapX = "0"}else{mapX=BuildingList["List"][i]["PosX"]};
                if(BuildingList["List"][i]["PosY"]==""){mapY = "0"}else{mapY=BuildingList["List"][i]["PosY"]};
                if(!go)
                {
                    BuildMapSearch.goToStation(mapX,mapY,BuildingList["List"][i]["bhId"],BuildingList["List"][i]["BuildingName"]);
                    go = true;
                }
                temp = body;                
                if(i==0){classname="price_map_item_over";imgstyle="block";}else{classname="price_map_item";imgstyle="none";}                
                if(BuildingList["List"][i]["hangPrice"]!="" && BuildingList["List"][i]["hangPrice"]!= "0"){
                    _price = parseFloat(BuildingList["List"][i]["hangPrice"]).toFixed(0);
                    if(_price=="0")_price="--";
                    hangprice = BuildMapSearch.format("<span class=\"f3\">均价：{0}</span><span class=\"fgrey\">元/㎡</span>",_price);
                }else{hangprice = "";}
                if(BuildingList["List"][i]["hangRate"]!="" && BuildingList["List"][i]["hangRate"]!="0"){
                    if(BuildingList["List"][i]["hangRate"].substring(0,1)=="-"){
                        hangrate = BuildMapSearch.format("&nbsp;<span class=\"f2\">{0}</span><br />",parseFloat(BuildingList["List"][i]["hangRate"]).toFixed(1)+"% ↓");
                    }else{
                        hangrate = BuildMapSearch.format("&nbsp;<span class=\"f1\">+{0}</span><br />",parseFloat(BuildingList["List"][i]["hangRate"]).toFixed(1)+"% ↑");   
                    }
                }else{hangrate = "<br />";}
                temp = BuildMapSearch.format(temp,i,classname,mapX,mapY,BuildingList["List"][i]["bhId"],BuildingList["List"][i]["BuildingName"],hangprice,hangrate,BuildingList["List"][i]["Addr"],imgstyle);                
                ctx[ctx.length] = temp;                
            }
        }
        var tnum;
        var pageObj = new PagerObj(totalItem,currentIndex,pageSize);
        pageObj.baseScript = "BuildMapSearch.GoSearch(__0__)";
        ctx[ctx.length] = pageObj.MapBuildPager();
        $P("divPageSum").innerHTML =  BuildMapSearch.format("共{0}条 第{1}/{2}页",pageObj.totalItem,pageObj.currentIndex,pageObj.lastIndex); 
        $P("ContainerDiv").innerHTML = ctx.join('');        
    },
    format:function() 
    {
        if( arguments.length == 0 )
            return null; 

        var str = arguments[0]; 
        for(var i=1;i<arguments.length;i++) 
        {
            var re = new RegExp('\\{' + (i-1) + '\\}','gm');
            str = str.replace(re, arguments[i]);
        }
        return str;
    },
    showItem : function(index,x,y,showPaneId,bName){
        if(BuildMapSearch.showId == index){
             if(x != 0 && y != 0){
                PageMap.showFlagPane(x,y,showPaneId,bName);    
            }
            return;
        }else{
            $P("itemdetail" + BuildMapSearch.showId).style.display = "none";
            $P("item" + BuildMapSearch.showId).className = "price_map_item";
            $P("item" + BuildMapSearch.showId).onmouseout=BuildMapSearch.mouseOutItem;
            $P("item" + index).className = "price_map_item_over";
            $P("item" + index).onmouseout=null;
            $P("itemdetail" + index).style.display = "block";
            BuildMapSearch.showId = index;
            if(x != 0 && y != 0){
                PageMap.showFlagPane(x,y,showPaneId,bName);    
            }
        }
    },
    mouseOutItem:function(e){
        e=e||event; 
        var tag=e.srcElement||e.target;
        var pa=tag.tagName.toLowerCase();
        while(pa!="dl"){
            tag=tag.parentNode;
            pa=tag.tagName.toLowerCase();
            if(pa=="body")return;
        }
        tag.className='price_map_item';
    }
}

function GotoPage(url,name)
{//js 页面跳转
    window.open(url,name);
}

function GotoSeekError()
{//纠错跳转
    var param = "returnurl="+encodeURIComponent(window.location.href);
    window.open("http://www.fangtoo.com/Message/SeekErrorInfo.aspx?"+param,"_blank");
}

/******************图片滚动广告*******************/
function preImageLoad(name){
    try{ 
    var strBtn = "";
    var strInit = "";
    var imgNum = eval("imgNum_"+name);
    var palyImgs = eval("palyImgs_"+name);    
    for(i=0;i<imgNum;i++)
    {
        strInit += "var imgpro" + i+" = new Image();";
        strInit += "imgpro" + i +".src = '"+palyImgs[i]+"';";
        if(i==0) strBtn += "<a alt='"+(i+1)+"' class='pick' href='javascript:void(0);'>"+(i+1)+"</a>";
        else{ strBtn += "<a alt='"+(i+1)+"' href='javascript:void(0);'>"+(i+1)+"</a>";}
    }
    eval(strInit);
    $P("play").innerHTML = strBtn;   
    windowInitScrip.push("bHouse.n="+imgNum+";play();");
    }
    catch(e){
    return;
    }
}

/************************************/