
//涓�涓媗wl
var $=function(node){
	return document.getElementById(node);
}
var objectValue;
function keyupdeal(e,curCity,objectId,flag){
	var ss=document.getElementById("select_type").value;
	if(ss!=1) return;
	var keyc;
	if(window.event)
	{
		keyc=e.keyCode;
	}else if(e.which){
		keyc=e.which;
	}
	if(keyc!=40 && keyc!=38 && keyc!=13){
		temp_str=$(objectId).value;
		if(temp_str!=objectValue&&temp_str!=""){
		//	if(objectId==objectId){
				ajax_local(curCity,objectId,flag);	
			//}
		}
	}
}

function removeM(){
	if($("suggestLocalSearch")){//lwl
		document.body.removeChild($("suggestLocalSearch"));
	}
}
 
function ajax_local(curCity,objectId,flag){
	var currentCity=$(curCity).value;
	
	
	
	var select_type=$("select_type").value;
	
	if(flag!=null){select_type=1;}
	var localSearchKey=$(objectId).value;
	var myAjax;
	var url="SuggestPOI.jsp";
	var pars="localSearchKey="+localSearchKey+"&LocalSearchCity="+currentCity+"&select_type="+select_type+"&objectId="+objectId;
	var options={
		method:"post",
		parameters: pars,
		onComplete:function(originalRequest){showAjaxData_local(originalRequest,objectId)}
	};
	 myAjax=new Ajax.Request(url,options);
}

 function getLength(attr,objectId)
     {
         var offset = 0;
         var item =document.getElementById(objectId);
         while(item)
          {
              offset += item[attr];
              item = item.offsetParent;
          } 
          return offset; 
     } 


function showAjaxData_local(originalRequest,objectId){

	var ss=originalRequest.responseText;
	if($("suggestLocalSearch")){//lwl
		document.body.removeChild($("suggestLocalSearch"));
	}
    	
	var no=ss.split("<li").length-1;
	if(no==0) return;
	var input=document.getElementById(objectId);
	var newdiv=document.createElement("div");
	newdiv.id="suggestLocalSearch";
	//newdiv.style.width=300;
	newdiv.style.height=214*no/10;
	newdiv.style.position="absolute";
	
	     var width = input.offsetWidth;
        var left = getLength("offsetLeft",objectId);
        var top = getLength("offsetTop",objectId) + input.offsetHeight;
           
        newdiv.style.left = left + "px";
        newdiv.style.border='black 1px solid';
        newdiv.style.top = top + "px"; 
        newdiv.style.width = width + "px";
	
    newdiv.style.zIndex=11;
    newdiv.style.background="white";
    newdiv.style.border="1px solid #24334a";
    document.body.appendChild(newdiv);
	$("suggestLocalSearch").innerHTML=ss;
}
function myTrim(str){     
     return  str.replace(/^\s+/,'').replace(/\s+$/,'');   
}
function location(){
	if($("suggestLocalSearch")){
		ajax_local("key");
	}
}

function keydowndeal(e,objectId){
	objectValue=$(objectId).value;
	var keyc;
	if(window.event){
		keyc=e.keyCode;
	}else if(e.which){
		keyc=e.which;
	}
	//鍒ゆ柇鏄惁涓哄湪灞備笂闈㈠崟鍑籈nter閿�
	if(keyc==13){
		//if(objectId==objectId){
			if($("suggestLocalSearch")){//lwl
				document.body.removeChild($("suggestLocalSearch"));
		//	}
		}
	}
	if(keyc==38||keyc==40){
		set_style_out(objectId,j);
		if(keyc==40){
			if(j<$$$(objectId+"LI").length){
				j++;
				if(j>=$$$(objectId+"LI").length){
					j=-1;
				}
			}
			if(j>=$$$(objectId+"LI").length){
					j=-1;
			}
		}else if(keyc==38){
			if(j>=0){
				j--;
				if(j<=-1){
					j=$$$(objectId+"LI").length;
				}
			}else{
				j=$$$(objectId+"LI").length-1;
			}
		}
		set_style(objectId,j);
		return;
	}
	j=-1;
	
}

function form_submit(objectId,i){

	j=i;
	set_style(objectId,j);
}
function set_style(objectId,num){
	if(j==-1||j==$$$(objectId+"LI").length) return;
	for(var i=0;i<$$$(objectId+"LI").length;i++){
		var li_node=$$$(objectId+"LI")[i];
		li_node.className="";
	}
	if(j>=0 && j<$$$(objectId+"LI").length){
		var i_node=$$$(objectId+"LI")[j];
		$$$(objectId+"LI")[j].style.background='3366cc';
		$$$(objectId+"LI")[j].style.color='white';
		var ss=$$$(objectId+"LI")[j].innerHTML;
		$$$(objectId+"LI")[j].className="select";
	}
	if(ss==undefined) return;
	$(objectId).value=ss;
}
function mo(objectId,nodevalue){
	j=nodevalue;
		if(j==-1||j==$$$(objectId+"LI").length) return;
	for(var i=0;i<$$$(objectId+"LI").length;i++){
		var li_node=$$$(objectId+"LI")[i];
		li_node.className="";
	}
	if(j>=0 && j<$$$(objectId+"LI").length){
		var i_node=$$$(objectId+"LI")[j];
		$$$(objectId+"LI")[j].style.background='3366cc';
		$$$(objectId+"LI")[j].style.color='white';
		var ss=$$$(objectId+"LI")[j].innerHTML;
		$$$(objectId+"LI")[j].className="select";
	}
	if(ss==undefined) return;
}
function mo_out(objectId,nodevalue){
	j=nodevalue;
	if(j==-1||j==$$$(objectId+"LI").length) return;
	for(var i=0;i<$$$(objectId+"LI").length;i++){
		var li_node=$$$(objectId+"LI")[i];
		li_node.className="";
	}
	if(j>=0 && j<$$$(objectId+"LI").length){
		var i_node=$$$(objectId+"LI")[j];
		$$$(objectId+"LI")[j].style.background='white';
		$$$(objectId+"LI")[j].style.color='6e6e6e';
		var ss=$$$(objectId+"LI")[j].innerHTML;
		$$$(objectId+"LI")[j].className="select";
	}
	if(ss==undefined) return;
}

function set_style_out(objectId,num){
	
	if(j==-1||j==$$$(objectId+"LI").length) return;
	for(var i=0;i<$$$(objectId+"LI").length;i++){
		var li_node=$$$(objectId+"LI")[i];
		li_node.className="";
	}
	if(j>=0 && j<$$$(objectId+"LI").length){
		var i_node=$$$(objectId+"LI")[j];
		$$$(objectId+"LI")[j].style.background='white';
		$$$(objectId+"LI")[j].style.color='6e6e6e';
		var ss=$$$(objectId+"LI")[j].innerHTML;
		$$$(objectId+"LI")[j].className="select";
	}
	if(ss==undefined) return;
	$(objectId).value=ss;
}
var $$=function(node){
	return document.getElementsByTagName(node);
}
var $$$=function(node){
	return document.getElementsByName(node);
}
var j=-1;

function setLevel_(num,latlon){//lwl

	var ss=webgis.getCenter();
	if(num=='a'){
		webgis.centerAndZoom(ss,7);
	}else if(num=='b'){
		webgis.centerAndZoom(ss,9);
	}else if(num=='c'){
		webgis.centerAndZoom(ss,10);
	}else if(num=='d'){
		webgis.centerAndZoom(ss,14);
		//webgis.setCenter(ss);
	}
}
function change_over(obj){
	obj.style.cursor="hand";
	obj.style.backgroundColor="#f1f3f4";
}
function change_out(obj){
	obj.style.backgroundColor="#ffffff";
}
function setSel(str){//lwl
    with(document.all){    
        for(var i=0;i<select_type.options.length;i++){                
            if (select_type.options[i].value==str){
                select_type.selectedIndex=i;
                break;
            }
        }            
    }
}
function quanguo(){
if(document.getElementById("currentCityBus1").value=="全国"){
	document.getElementById("currentCityBus1").value="北京市";
}
if(document.getElementById("currentCityBus2").value=="全国"){
	document.getElementById("currentCityBus2").value="北京市";
}
if(document.getElementById("currentCityBus3").value=="全国"){
	document.getElementById("currentCityBus3").value="北京市";
}
if(document.getElementById("currentCityDrive1").value=="全国"){
	document.getElementById("currentCityDrive1").value="北京市";
}
if(document.getElementById("currentCityDrive2").value=="全国"){
	document.getElementById("currentCityDrive2").value="北京市";
}
}