document.writeln('<xml id="test" src=""></xml>');
document.writeln('<div id="divcitylist" name="divcitylist" style="position:absolute;width:250px;font-size:12px;border:1px solid #cccccc;padding:5px;display:none;z-index:999;background:#FFFFFF;text-align:left;" citylayer="alllay">');
document.writeln('	<div id="proment" name="proment" style="line-height:150%;color:#cccccc;border-bottom:1px dotted #cccccc" citylayer="title">请输入中文或拼音</div>');
document.writeln('	<div style="height:270px;text-align:left;" id="newslist" name="newslist" citylayer="content">');
document.writeln('	  <table width="100%" border="0" cellpadding="0" cellspacing="0" id="citylist" datasrc="#test" datafld="city" citylayer="contenttable">');
document.writeln('	  <tbody>');
document.writeln('        <tr>');
document.writeln('          <td height="27" id="city_item" onmouseover="this.className=\'mouse_over_td\'" onmouseout="this.className=\'\'" citylayer="cityrow" onclick="returncity(this.childNodes.item(1).innerText)" align="left"><div datafld="ename" style="width:134px;float:left;text-align:left;"  citylayer="ename"></div><div datafld="cname" style="width:102px;text-align:right;float:left" citylayer="cname"></div></td>');
document.writeln('        </tr>');
document.writeln('		</tbody>');
document.writeln('      </table>');
document.writeln('	</div>');
document.writeln('	<div style="text-align:center;height:25px;line-height:25px;" citylayer="pages" id="cityfoot"> </div>');
document.writeln('</div>');

var citystr;
var outobj;
function document.onkeyup(){
	//alert("test");
	with(window.event.srcElement){		
		if (getAttribute("ajaxcity")=="city" && tagName == "INPUT"){
			citystr=value;
			sendcity(value)
			//document.getElementById("proment").innerHTML=value;
			//var url="ajaxcity.asp?keyword="+value;
//			xmlHttp=GetXmlHttpObject(getcitylist);
//			xmlHttp.open("GET",url,true);
//			xmlHttp.send(null);
		}
	}	
}
//function document.onmouseover(){
//	with(window.event.srcElement){
//		if (id=="city_item"){
//			className="mouse_over_td";;
//		}
//	}
//}
//
//
//function document.onmouseout(){
//	with(window.event.srcElement){
//		if (id=="city_item"){
//			className="";
//		}
//	}
//}
function sendcity(str,page){
	var url="ajaxcity.asp?keyword="+escape(str)+"&page="+page;
	
	xmlHttp=GetXmlHttpObject(getcitylist);
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function changecitypage(str1,page1){
	sendcity(str1,page1);
}

function selectcity(obj){

  
	outobj=obj;
	with (window.event.srcElement){
		if (getAttribute("ajaxcity")=="city" && tagName == "INPUT"){
			sendcity(obj.value)
			var dads  = document.all.divcitylist.style;
			  var ttop  = obj.offsetTop;     
			  var thei  = obj.clientHeight;  
			  var tleft = obj.offsetLeft;    
			  var ttyp  = obj.type;          
			  while (obj = obj.offsetParent){ttop+=obj.offsetTop; tleft+=obj.offsetLeft;}
			  dads.top  = (ttyp=="image")? ttop+thei : ttop+thei+6;
			  dads.left = tleft;
			  dads.display = '';
		}
	}
}
function document.onclick(){
 
  with(window.event.srcElement)
  {
	if (getAttribute("citylayer")==null && tagName != "INPUT")
    document.all.divcitylist.style.display="none";
  }
}
function getcitylist(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
		//if(xmlHttp.responseText!="参数错误"){alert(xmlHttp.responseText);}
		xmldoc.loadXML(xmlHttp.responseText);
		var root=xmldoc.documentElement;
		var proobj=document.getElementById("proment");
		var countitem=parseInt(root.childNodes.item(0).text);
		
		if (citystr!=null&&citystr!=""){
			if(countitem==0){
				proobj.innerHTML="对不起，没找到:"+citystr;
			}else{
				proobj.innerHTML=citystr+",共有"+root.childNodes.item(0).text+"项,按拼音排序!"
			}
			
			document.getElementById("cityfoot").innerHTML="";
				
			for (i=1;i<=Math.ceil(countitem/10);i++){
				document.getElementById("cityfoot").innerHTML+="<div class='mouse_out_page' onclick=\changecitypage('"+citystr+"',"+i+")\ citylayer=\pages\  onmouseover=\"this.className='mouse_over_page'\" onmouseout=\"this.className='mouse_out_page'\">"+i+"</div>";
			}
		}
		document.getElementById("test").XMLDocument.loadXML(xmlHttp.responseText);
	} 
	
}

function returncity(strcity){
	outobj.value=strcity;
	document.all.divcitylist.style.display="none";
}