
//涓�涓媗wl
var $=function(node){
	return document.getElementById(node);
}
var objectValue;
function keyupdealBus(e,curCity,objectId){
	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!=""){
				ajax_Bus(curCity,objectId);	
		}
	}
}


 
function ajax_Bus(curCity,objectId){
	var currentCity=$(curCity).value;
	var SearchKey=$(objectId).value;
	var myAjax;
	var url="SuggestPOI2.jsp";
	var pars="SearchKey="+SearchKey+"&SearchCity="+currentCity+"&objectId="+objectId;
	var options={
		method:"post",
		parameters: pars,
		onComplete:function(originalRequest){showAjaxData_Bus(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_Bus(originalRequest,objectId){
	var ss=originalRequest.responseText;
	if($("ajaxBusDiv")){
		document.body.removeChild($("ajaxBusDiv"));
	}
    	
	var no=ss.split("<li").length-1;
	if(no==0) return;
	var input=document.getElementById(objectId);
	var newdiv=document.createElement("div");
	newdiv.id="ajaxBusDiv";
	//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);
	$("ajaxBusDiv").innerHTML=ss;
}
function location(){
	if($("ajaxBusDiv")){
		ajax_local("key");
	}
}

function keydowndealBus(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($("ajaxBusDiv")){
				document.body.removeChild($("ajaxBusDiv"));
		}
	}
	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;





