var isProjDrive=false;
var isProjOther=false;
__initOterControl=function()
{
    $("lnkother").onclick=$("other_device").onclick=function()
    {
        isProjOther=true;
        $("other").style.display="";
        $("drive").style.display="none";
    }
    $("lnkdrive").onclick=$("other_drive").onclick=function()
    {
        $("other").style.display="none";
        $("drive").style.display="";
        if(document.popup != null){
            searchDriveInfo.end_x=searchOtherInfo.x;
            searchDriveInfo.end_y=searchOtherInfo.y;
            $("txtEnd").disabled=true;
        }
        else{
            $("txtEnd").value="";
            $("txtEnd").disabled=false;
            searchDriveInfo.end_x="";
            searchDriveInfo.end_y="";
        }
    }
    $("driveClose").onclick=function()
    {
        $("drive").style.display="none";
        closeOterSearch();
    }
    $("drive_next_close").onclick=function()
    {
        $("drive").style.display="none";
        $("drive_start").style.display="none";
        closeOterSearch();
    }
    $("drive_end_close").onclick=function()
    {
        $("drive").style.display="none";
        $("drive_start").style.display="none";
        $("drive_end").style.display="none";
        closeOterSearch();
    }
    $("otherClose").onclick=function()
    {
        $("other").style.display="none";
        isProjOther=false;
        closeOterSearch();
    }
    $("DriveChange").onclick=function()
    {
        var startName=$("txtStart").value;
        var endName=$("txtEnd").value;
        var start_x=searchDriveInfo.start_x;
        var start_y=searchDriveInfo.start_y;
        var end_x=searchDriveInfo.end_x;
        var end_y=searchDriveInfo.end_y;
        $("txtStart").value=endName;   
        $("txtEnd").value=startName;
        searchDriveInfo.startName=endName;
        searchDriveInfo.endName=startName;
        searchDriveInfo.start_x=end_x;
        searchDriveInfo.start_y=end_y;
        searchDriveInfo.end_x=start_x;
        searchDriveInfo.end_y=start_y;
        if(isProjDrive){
            if(searchDriveInfo.end_x!=""&&searchDriveInfo.end_y!=""){
                $("txtStart").disabled=false;
                $("txtEnd").disabled=true;
            }
            else{
                $("txtStart").disabled=true;
                $("txtEnd").disabled=false;
            }
        }
    }
}
__initOterControl();
__initDriveControl=function()
{
    $("txtEnd").onchange=function(){
        if(!isProjDrive)
        getEndPoint();
    }
    $("txtStart").onchange=function()
    {
        if(!isProjDrive)
        getStartPoint();
    }
    $("btnDrive").onclick=function()
    {
        searchDriveInfo.startName=$("txtStart").value;
        searchDriveInfo.startName = format(searchDriveInfo.startName);
        searchDriveInfo.endName=$("txtEnd").value;
        searchDriveInfo.endName = format(searchDriveInfo.endName);
        mapObj.hideTip();
        if(!isProjDrive)
        {
            if(searchDriveInfo.startName!=""&&searchDriveInfo.endName!=""&&searchDriveInfo.startName!=searchDriveInfo.endName)
            {
                mapObj.isDrive=true;
                if(searchDriveInfo.start_x!=""&&searchDriveInfo.start_y!=""&&searchDriveInfo.end_x!=""&&searchDriveInfo.end_y!="")
                {
                   setDriveStart();
                }
            }
            else {
                alert("请填写完整信息！");
                return;
            }
        }
        else
        {
            var keyword="";
            if(searchDriveInfo.start_x==""||searchDriveInfo.start_y=="")
            {
                keyword=searchDriveInfo.startName;
            }
            if(searchDriveInfo.end_x==""||searchDriveInfo.end_y=="")
            {
                keyword=searchDriveInfo.endName;
            }
            getPointByKeyword(keyword);
        }
        hideProjMarker();
        $("end_next_name").value=searchDriveInfo.endName;
        $("start_next_name").value=searchDriveInfo.startName;
        $("drive").style.display="none";
        $("drive_start").style.display="";
        $("start_next_list").options[0]=new Option(searchDriveInfo.startName);
        $("end_next_list").options[0]=new Option(searchDriveInfo.endName);
    }
}
setDriveStart=function()
{
    map.panTo(new GLatLng(searchDriveInfo.start_y,searchDriveInfo.start_x));
    map.clearOverlays();
    setPoint("start");
}
//获取终点坐标信息
getEndPoint=function()
{
    $("btnDriveNext").disabled=true;
    searchDriveInfo.endName=$("txtEnd").value;
    searchDriveInfo.endName = format(searchDriveInfo.endName);
    if(searchDriveInfo.endName!="") {
        getPointByKey("end");
    }
}
getStartPoint=function()
{
    $("btnDriveNext").disabled=true;
    searchDriveInfo.startName=$("txtStart").value;
    searchDriveInfo.startName = format(searchDriveInfo.startName);
    if(searchDriveInfo.startName!="") {
        getPointByKey("start");
    }
}
__initDriveControl();
//获取关键字坐标信息
getPointByKey=function(type)
{
    var keyWord="";
    mapObj.isDrive=true;
    $("btnDriveNext").disabled=true;
    if(type=="start") { keyWord=searchDriveInfo.startName; }
    else  keyWord=searchDriveInfo.endName
    var url="/public/xml.aspx?action=getdrivepointer&keyword="+escape(cityname+keyWord);  
    Xml.Request(url,null,function()
    {
        var content=this.responseXML.getElementsByTagName('driveinfo'); 
        if(content.length>0)
        {
            var px="",py="";
            for(i=0;i<content.length;i++)
            {  
                for(j=0;j<content[i].childNodes.length;j++) {
                    if(content[i].childNodes[j].nodeName=="px")px=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
                    if(content[i].childNodes[j].nodeName=="py")py=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
                }
                if(i==0)
                {
                    if(type=="start") {
                        searchDriveInfo.start_x=px;
                        searchDriveInfo.start_y=py;
                    }
                    else {
                        searchDriveInfo.end_x=px;
                        searchDriveInfo.end_y=py;
                    }
                }
            }
            if(searchDriveInfo.start_x!=""&&searchDriveInfo.start_y!=""&&searchDriveInfo.end_x!=""&&searchDriveInfo.end_y!="")
            {
                setDriveStart();
                $("btnDriveNext").disabled=false;
            }
        }
    });
}
getPointByKeyword=function(keyword)
{
    mapObj.isDrive=true;    
    $("btnDriveNext").disabled=true;
    var url="/public/xml.aspx?action=getdrivepointer&keyword="+escape(cityname+keyword);  
    Xml.Request(url,null,function()
    {
        var content=this.responseXML.getElementsByTagName('driveinfo'); 
        if(content.length>0)
        {
            var px="",py="";
            for(i=0;i<content.length;i++)
            {  
                for(j=0;j<content[i].childNodes.length;j++) {
                    if(content[i].childNodes[j].nodeName=="px")px=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
                    if(content[i].childNodes[j].nodeName=="py")py=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
                }
                if(i==0)
                {
                    if(searchDriveInfo.start_x==""||searchDriveInfo.start_y=="") {
                        searchDriveInfo.start_x=px;
                        searchDriveInfo.start_y=py;
                    }
                    else if(searchDriveInfo.end_x==""||searchDriveInfo.end_y==""){
                        searchDriveInfo.end_x=px;
                        searchDriveInfo.end_y=py;
                    }
                }
            }
            if(searchDriveInfo.start_x!=""&&searchDriveInfo.start_y!=""&&searchDriveInfo.end_x!=""&&searchDriveInfo.end_y!="")
            {
                setDriveStart();
                $("btnDriveNext").disabled=false;
            }
        }
    });
}
$("btnDriveNext").onclick=function()
{
    showDriveList();
}
$("btnDrivePre").onclick=function()
{
    $("drive_start").style.display="none";
    $("drive").style.display="";
}
$("btnDriveBack").onclick=function()
{
    $("drive_start").style.display="";
    $("drive_end").style.display="none";
}
$("driveReset").onclick=function()
{
    $("drive_end").style.display="none";
    $("drive").style.display="";
}
$("driveBack").onclick=function()
{
    $("driveBack").disabled=true;
    map.clearOverlays();
    var startname=searchDriveInfo.startName;
    var endname=searchDriveInfo.endName;
    var start_x=searchDriveInfo.start_x;
    var start_y=searchDriveInfo.start_y;
    var end_x=searchDriveInfo.end_x;
    var end_y=searchDriveInfo.end_y;
    $("txtStart").value=endname;   
    $("txtEnd").value=startname;
    searchDriveInfo.startName=endname;
    searchDriveInfo.endName=startname;
    searchDriveInfo.start_x=end_x;
    searchDriveInfo.start_y=end_y;
    searchDriveInfo.end_x=start_x;
    searchDriveInfo.end_y=start_y;
    $("start_name").innerHTML=searchDriveInfo.startName;
    $("end_name").innerHTML=searchDriveInfo.endName;
    setPoint("start");
    setPoint("end");
    directionsPanel = $("driveline1");
    directions = new GDirections("",directionsPanel);
    GEvent.addListener(directions,'load',driverlinelist);
    GEvent.addListener(directions,'error',function(){alert('查询路线错误，请返回上一步重新查询');});
    directions.load("from: "+searchDriveInfo.start_y+", "+searchDriveInfo.start_x+" to: "+searchDriveInfo.end_y+", "+searchDriveInfo.end_x,{getPolyline:true});
}
//查询驾车路线
var directionsPanel;
var directions;
var GRoute;
showDriveList=function()
{
    map.clearOverlays();
    if(searchDriveInfo.start_x == "" || searchDriveInfo.start_y == "" || searchDriveInfo.end_x == "" || searchDriveInfo.end_y == ""){
	    alert("驾车查询起始点设置错误，请重试");
	    return;
    }
    setPoint("start");
    setPoint("end");
    $("driveline").innerHTML="";
    $("drive_end").style.display="";
    $("start_name").innerHTML=searchDriveInfo.startName;
    $("end_name").innerHTML=searchDriveInfo.endName;
    $("drive_start").style.display="none";
    directionsPanel = $("driveline1");
    directions = new GDirections(null,directionsPanel);
    GEvent.addListener(directions,'load',driverlinelist);
    GEvent.addListener(directions,'error',function(){alert('查询路线错误，请返回上一步重新查询');});
    directions.load("from: "+searchDriveInfo.start_y+", "+searchDriveInfo.start_x+" to: "+searchDriveInfo.end_y+", "+searchDriveInfo.end_x,{getPolyline:true});
}
var startMarker=null;
var endMarker=null;
function setPoint(type)
{
    var drivePoint=null;
    var iconImg="";
    var markertitle="";
    if(type=="start"){ 
        drivePoint = new GLatLng(searchDriveInfo.start_y,searchDriveInfo.start_x);
        iconImg=imgurl+"icon_start.gif";
        markertitle="起点："+searchDriveInfo.startName;
    }
    else{ 
        drivePoint = new GLatLng(searchDriveInfo.end_y,searchDriveInfo.end_x); 
        iconImg=imgurl+"icon_end.gif";
        markertitle="终点："+searchDriveInfo.endName;
    }
    var newIcon= new GIcon();
    newIcon.image = iconImg;
    newIcon.shadow = imgurl+"marker_trans.png";
    newIcon.iconSize = new GSize(26, 34);
    newIcon.shadowSize = new GSize(37, 35);
    newIcon.iconAnchor = new GPoint(10, 35);
    newIcon.infoWindowAnchor = new GPoint(0, 0);  
    var markerOptions = {icon:newIcon,title:markertitle};
    startMarker=new GMarker(drivePoint,markerOptions);
    map.addOverlay(startMarker);
}
var polyline = [];
var markerBounds=[];
function driverlinelist()
{
	var routeline = directions.getRoute(0);
    var steps = routeline.getNumSteps();
    var v_html = "";
    var turn = "";
	var linepoint_r = [];//行车路线总的路线坐标数组
	var linepointofstep_r = [];//行车路线的各段的路线坐标数组
	var alllength = 0;
	var dist = 0;
	$("driveTime").innerHTML="/"+directions.getDuration().html;
	$("driveDistance").innerHTML=directions.getDistance().html
	var linepol = directions.getPolyline();
	var linepolnum = linepol.getVertexCount();
	for(var i = 0;i<linepolnum;i++){
		var linepoint  = linepol.getVertex(i);
		linepoint_r[i] = new GLatLng(linepoint.lat().toString(),linepoint.lng().toString());
	}
	markerBounds[0] = linepol.getBounds().getSouthWest();
    markerBounds[1] = linepol.getBounds().getNorthEast();
    panMap();
	var stepindexpre = 0;
	for(var i = 0;i<steps;i++)
	{
		var step = routeline.getStep(i);
		var linestr = step.getDescriptionHtml();
		dist = step.getDistance().html;
		var stepindex = step.getPolylineIndex();
		if(i > 0)
		{
			var stepnum = parseInt(i-1);
			linepointofstep_r[stepnum] = [];
			for(var j = stepindexpre;j<=stepindex;j++){
				linepointofstep_r[stepnum][j] = linepoint_r[j];
			}
		}
		if(i == steps-1)
		{
			var stepnum = parseInt(i);
			linepointofstep_r[stepnum] = [];
			for(var j = stepindex;j<=linepoint_r.length;j++){
				linepointofstep_r[stepnum][j] = linepoint_r[j];
			}
		}
		for(var j = 0;j<linepointofstep_r.length;j++)
	    {
  	        polyline[j] = new GPolyline(linepointofstep_r[j], "#ff0000", 6,1);
		    map.addOverlay(polyline[j]);
	    }
		//组织右侧列表数据
		v_html += '<li id="driver_step_'+i+'" onclick="foldline(\''+i+'\',\''+steps+'\')">'+parseInt(i+1)+'.'+linestr+"&nbsp;"+dist+'</li>';
		stepindexpre = stepindex;
		alllength += parseInt(dist);
	}
	if(v_html!="")
	{
	    $("driveline").innerHTML=v_html;
	    $("driveBack").disabled=false;
	}
}	
function panMap(bounds)
{
	var bounds = bounds || new GLatLngBounds(markerBounds[0],markerBounds[1]);
 	var zoom = map.getBoundsZoomLevel(bounds);
 	var orizoom = map.getZoom();
 	if(zoom > orizoom) zoom = orizoom;
	if(zoom > 10) map.setCenter(bounds.getCenter(),zoom);
}
//画线路并控制左边列表.num为第几条线路,count全部线路数.
function foldline(num,count)
{
    try
    {
	    for(var i=0;i<count;i++)
	    {
		    var id = "driver_step_"+i;
		    if(polyline[i])
		    {
			    polyline[i].setStrokeStyle({color: "#ff0000"});
		    }
	    }
	    var tr_id = "driver_step_"+num;
	    polyline[num].setStrokeStyle({color: "#00BD0A"});
    }catch(e){}
}
//周边
var otherCondition=[];
var otherBaseMarkers=new Array();
otherCondition[0]={index:0,id:"btnBuilding",searchtype:"building",serachname:"楼盘",markers:otherBaseMarkers};
otherCondition[1]={index:1,id:"btnBus",searchtype:"bus",serachname:"公交车",markers:otherBaseMarkers};
otherCondition[2]={index:2,id:"btnHotel",searchtype:"hotel",serachname:"餐饮",markers:otherBaseMarkers};
otherCondition[3]={index:3,id:"btnBank",searchtype:"bank",serachname:"银行",markers:otherBaseMarkers};
otherCondition[4]={index:4,id:"btnSuperMarket",searchtype:"supermarket",serachname:"超市",markers:otherBaseMarkers};
otherCondition[5]={index:5,id:"btnShop",searchtype:"shop",serachname:"商场",markers:otherBaseMarkers};
otherCondition[6]={index:6,id:"btnSchool",searchtype:"school",serachname:"学校",markers:otherBaseMarkers};
otherCondition[7]={index:7,id:"btnHospital",searchtype:"hospital",serachname:"医院",markers:otherBaseMarkers};
//otherCondition[8]={index:8,id:"btnFurniture",searchtype:"furniture",serachname:"装修公司",markers:otherBaseMarkers};
//otherCondition[9]={index:9,id:"btnDecoration",searchtype:"decoration",serachname:"商家",markers:otherBaseMarkers};
otherCondition[8]={index:8,id:"btnGasstation",searchtype:"gasstation",serachname:"加油站",markers:otherBaseMarkers};
initOtherObj=function(obj)
{
    obj.onclick=function() 
    {
        try {
            mapObj.hideTip();
	        this.disabled=true;
	        searchtype=this.searchtype;
	        otherIndex=this.index;
	        this.markers=otherCondition[otherIndex].markers;
	        if(this.checked) {
	            if(searchtype=="building") {
	                showProjMarker();
	            }
	            else CreateOtherMarker(this);  
	            this.disabled=false;      
	        }
	        else {
	            if(searchtype=="building"){
	                hideProjMarker();
	            }
	            else DeleteOtherMarker(this);
                this.disabled=false;
	        }
	    }
	    catch(e){}
    }
}
for(var i=0;i<otherCondition.length;i++)
{
    var otherObj=$(otherCondition[i].id);
    otherObj.index=otherCondition[i].index;
    otherObj.searchtype=otherCondition[i].searchtype;
    otherObj.searchname=otherCondition[i].serachname;
    initOtherObj(otherObj);
}
CreateOtherMarker=function(obj)
{
	if(obj.searchtype=="furniture"){
	    search_near_home();
	}
	else if(obj.searchtype=="decoration"){
	    search_near_zs();
	}
	else{
	    searchnear(obj.searchname);
	}
}
DeleteOtherMarker=function(obj)
{
	if('undefined' != typeof map)
	{
		if('undefined' != typeof obj.markers)
		{
        	
        	for (var i = 0; i < obj.markers.length; i++) 
            {
	            map.removeOverlay(obj.markers[i].marker());
            }
		}
	}
}
function searchnear(searchname)
{
	var currPoint=map.getCenter();
	var px=currPoint.lng();
	var py=currPoint.lat();
	if(py == "" || px == ""){ return; }
	gLocalSearch.setCenterPoint(new GLatLng(py,px));
	gLocalSearch.execute(searchname);
}
function search_near_zs()
{
	var currPoint=map.getCenter();
	var px=currPoint.lng();
	var py=currPoint.lat();
	var url="/public/xml.aspx?action=GetDealPoint&px="+px+"&py="+py;
    Xml.Request(url,null,showSearchZs);
}
function showSearchZs()
{
    var content=this.responseXML.getElementsByTagName("shop");
    otherCondition[otherIndex].markers=new Array();
    if(content&&content.length>0)
    {
        for(i=0;i<content.length;i++) 
        {  
            var V = {};
            for(j=0;j<content[i].childNodes.length;j++)
            {
		        if(content[i].childNodes[j].nodeName=="name")V.title=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="id")V.id=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="tel")V.tel=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="address")V.address=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="px")V.lng=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="py")V.lat=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';		        
            }
            V.listtype = searchtype;
		    V.num = i;
		    otherCondition[otherIndex].markers.push(new LocalResult(V,i));
        }
    }
}
function search_near_home()
{
	var currPoint=map.getCenter();
	var px=currPoint.lng();
	var py=currPoint.lat();
	var url="/public/xml.aspx?action=GetHomePoint&px="+px+"&py="+py;
    Xml.Request(url,null,showSearchHome);
}
function showSearchHome()
{
    var content=this.responseXML.getElementsByTagName("shop");
    otherCondition[otherIndex].markers=new Array();
    if(content&&content.length>0)
    {
        for(i=0;i<content.length;i++) 
        {  
            var V = {};
            for(j=0;j<content[i].childNodes.length;j++)
            {
		        if(content[i].childNodes[j].nodeName=="name")V.title=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="id")V.id=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="tel")V.tel=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="address")V.address=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="px")V.lng=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';
		        if(content[i].childNodes[j].nodeName=="py")V.lat=content[i].childNodes[j].firstChild? content[i].childNodes[j].firstChild.data : '';		        
            }
            V.num = i;
            V.listtype = searchtype;
		    otherCondition[otherIndex].markers.push(new LocalResult(V,i));
        }
    }
}
var maxLat=-90;
var maxLng=-180;
var minLat=90;
var minLng=180;
var gLocalSearch;
var gSearchForm;
//gLocalSearch = new GlocalSearch();
//gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);
//gLocalSearch.ADDRESS_LOOKUP_DISABLED;
//gLocalSearch.setResultSetSize(google.search.Search.LARGE_RESULTSET);
function OnLocalSearch() 
{
    if (!gLocalSearch.results) return;
    for (var i = 0; i < otherCondition[otherIndex].markers.length; i++) {
        if (!otherCondition[otherIndex].markers[i].selected()) {
	        map.removeOverlay(otherCondition[otherIndex].markers[i].marker());
        }
    }
    otherCondition[otherIndex].markers=new Array();
    var len = gLocalSearch.results.length;
    for (var i = 0; i < len; i++) {
        otherCondition[otherIndex].markers.push(new LocalResult(gLocalSearch.results[i],i));
    }
}
function LocalResult(result,i) 
{
    this.result_ = result;
    this.result_["num"] = i;
    this.resultNode_ = this.unselectedHtml();
    var nearicon = getnearphoto(i);
    var marker2=new GMarker(new GLatLng(parseFloat(this.result_.lat),parseFloat(this.result_.lng)));
    map.addOverlay(this.marker(nearicon));
    if(Math.abs(this.marker().getLatLng().lat()*1)<=90&&Math.abs(this.marker().getLatLng().lng()*1)<=180)
    {
	    if(maxLat<this.marker().getLatLng().lat()) maxLat=this.marker().getLatLng().lat();
	    if(maxLng<this.marker().getLatLng().lng()) maxLng=this.marker().getLatLng().lng();
	    if(minLat>this.marker().getLatLng().lat()) minLat=this.marker().getLatLng().lat();
	    if(minLng>this.marker().getLatLng().lng()) minLng=this.marker().getLatLng().lng();
    }
}
LocalResult.prototype.marker = function(opt_icon) 
{
    if (this.marker_) return this.marker_;
    var marker = new GMarker(new GLatLng(parseFloat(this.result_.lat),parseFloat(this.result_.lng)),opt_icon);
    GEvent.bind(marker, "click", this, function() {
  	marker.openInfoWindow(
    this.unselectedHtml());
    });
    this.marker_ = marker;
    return marker;
}
LocalResult.prototype.select = function() 
{
    if (!this.selected()) 
    {
        this.selected_ = true;
        map.removeOverlay(this.marker());
        this.marker_ = null;
        map.addOverlay(this.marker(G_DEFAULT_ICON));
        document.getElementById("selected").appendChild(this.selectedHtml());
        this.resultNode_.parentNode.removeChild(this.resultNode_);
    }
}
LocalResult.prototype.unselectedHtml = function() 
{
    var listtype = "";
    if('undefined' != typeof this.result_.listtype) {
	    listtype = this.result_.listtype;
    }
    var name = "";
    if('undefined' != typeof this.result_.title) {
	    name = this.result_.title;
    }
    var tel = "";
    if('undefined' != typeof this.result_.phoneNumbers) {
	    tel = this.result_.phoneNumbers[0].number;
    }
    var address = "";
    if('undefined' != typeof this.result_.streetAddress) {
	    address = this.result_.streetAddress;
    }
    if(listtype=="furniture"||listtype=="decoration") {
        tel=this.result_.tel;
        address=this.result_.address;
    }
    var sContent = "";  
    sContent="<div style='font-size:12px;margin:0px;padding:0px;width:200px'><b><div>"+parseInt(this.result_.num+1)+"."+name+" </div></b><div>地址："+address+" </div>"
    if(tel&&tel!="") {
        sContent+="<div style='color:orange'>电话："+tel+" </div>";
    }
    sContent+="<div>";
    return sContent;
}
LocalResult.prototype.selectedHtml = function() {
  return this.result_.html.cloneNode(true);
}
LocalResult.prototype.selected = function() {
  return this.selected_;
}
function getnearphoto()
{
	var gSmallIcon = new GIcon();
	var dotphoto = imgurl+"icon_"+searchtype+".gif";
    gSmallIcon.image = dotphoto;
    gSmallIcon.shadow = imgurl+"marker_trans.png";
    gSmallIcon.iconSize = new GSize(16, 16);
    gSmallIcon.shadowSize = new GSize(22, 20);
    gSmallIcon.iconAnchor = new GPoint(6, 20);
    gSmallIcon.infoWindowAnchor = new GPoint(0, 1);
    return gSmallIcon;
}
closeOterSearch=function()
{
    InitDriveInfo();
    if(mapObj.isDrive){
        map.clearOverlays();
        mapObj.isDrive=false;
    }
    for(var i=0;i<otherCondition.length;i++)
    {
        var otherCheck=$(otherCondition[i].id);
        if(typeof otherCondition[i].markers!="undefined") {
            for(var j=0;j<otherCondition[i].markers.length;j++) {
                map.removeOverlay(otherCondition[i].markers[j].marker());
            }
        }
        if(otherCondition[i].searchtype=="building") {
            otherCheck.checked=true;
        }
        else {
            otherCheck.checked=false;
        }
    }
}
InitDriveInfo=function(){
    if(document.popup == null){
        isProjDrive=false;
        $("txtEnd").disabled=false;
        $("txtStart").disabled=false;
        $("txtEnd").value="";
        $("txtStart").value="";
        $("DriveChange").style.display="none";        
        searchDriveInfo.startName="";
        searchDriveInfo.endName="";
        searchDriveInfo.start_x="";
        searchDriveInfo.start_y="";
        searchDriveInfo.end_x="";
        searchDriveInfo.end_y="";
    }
}
hideProjMarker=function(){
    try{ 
        for(var j=0;j<markers.length;j++){
            markers[j].hide();
        }
        if(mapOjb.keyMarker)
        {
            mapOjb.keyMarker.hide();
        }
    }catch(e){}
}
showProjMarker=function(){
    try{ 
        for(var j=0;j<markers.length;j++){
            markers[j].show();
        }
        if(mapOjb.keyMarker)
        {
            mapOjb.keyMarker.show();
        }
    }catch(e){}
}
//格式化字符串
format=function(str){
	str = str.replace(/(^\s*)|(\s*$)/g, "");
	str = str.replace(/\s/g,"");
	return str;
}