
///////将后台数据都提取到前台
////<div id="mylist" style="position:absolute;width:146px; height:198px;display:none;z-index: 1;overflow:scroll;"></div>
var Citys;
function showList(sInput,hiddenInput,gasket,hql)     //主要是用来显示信息
{
	if(Citys!=undefined)
	{
		var CodeFrame,CCodeFrame;
		var Codeinputname
		CodeFrame = ''
		CodeFrame += '<table id=tbl9 width=100% height=18 class="tbl_box" bgcolor="#FFFFFF" style="font-size:12px;">';
		  var o;
		  Codeinputname = document.getElementById(sInput);     //得到的是输入的值
		  o=Codeinputname.value.trim();
		  CCodeFrame = document.getElementById(gasket);      //得到的是显示在div里面的值
		  if(o=="")
		  	{
		  	HiddenME(gasket);
		  	return;
		  	}
		 	var ac = 0;
		  for(var i=0;i<Citys.length;i++)   
		  {
		  	var mm = Citys[i].split(",");
		    if(startWith(mm[1],o)||startWith(mm[2].toUpperCase(),o.toUpperCase()))
		    {
		    	ac=1;
					CodeFrame += '<tr onmouseover="bgColor='+"'#cccccc'"+';this.style.cursor='+"'hand'"+'" onmouseout="bgColor='+"'#ffffff'"+'">';
					CodeFrame += '<td onclick="javascript:clickitem('+"'"+sInput+"','"+mm[1]+"--"+mm[2]+"','"+hiddenInput+"','"+mm[0]+"','"+gasket+"'"+');">';
		    		CodeFrame += mm[1] +" &nbsp;&nbsp;&nbsp;" +mm[2] ;
					CodeFrame += '</td></tr>';
		    	}
		  }
		 
		CodeFrame += '</table>';
		 if(ac==0)
		  return;
		  var str="hidden";
		HideOrShowGasket("xialaliebiao_A,xialaliebiao_B,xialaliebiao_C",str);
		document.getElementById(hiddenInput).value="";
		document.getElementById(gasket).innerHTML=CodeFrame;
		
		 var eT=0,eL=0,p=Codeinputname;
		 var sT=document.body.scrollTop,sL=document.body.scrollLeft;
		 var eH=p.height,eW=p.width;
		
		 var ttop  = Codeinputname.offsetTop;     //TT控件的定位点高
		 var thei  = Codeinputname.clientHeight;  //TT控件本身的高
		 var tleft = Codeinputname.offsetLeft;    //TT控件的定位点宽
		 var ttyp  = Codeinputname.type;          //TT控件的类型
		 while (Codeinputname = Codeinputname.offsetParent){ttop+=Codeinputname.offsetTop; tleft+=Codeinputname.offsetLeft;}
		 CCodeFrame.style.top  = ((ttyp=="image")? ttop+thei : ttop+thei+6)+'px';
		 CCodeFrame.style.left = tleft+'px';
		 CCodeFrame.style.display="block";
		 try{HiddenSelect();}catch(err){}
	 }
	 else
	 {
	 	ListByHQL.ListItems(hql,function(msg){
		 	if(msg!="")
		 	{
		 		Citys = msg.split(":");
		 		showList(sInput,hiddenInput,gasket,hql);
		 		}
	 		});
	 }
}
function clickitem(sInput,item,hiddenInput,value,gasket)   //在点击的时候把值赋进去
{
	var Codeinputname,CCodeFrame;
	Codeinputname = document.getElementById(sInput);
	Codeinputname.value=item;
	var hiddenInput = document.getElementById(hiddenInput);
	hiddenInput.value=value;
	CCodeFrame = document.getElementById(gasket);
	CCodeFrame.style.display="none";
	CCodeFrame.innerHTML="";
	var str="";
	HideOrShowGasket("xialaliebiao_A,xialaliebiao_B,xialaliebiao_C",str);
}


String.prototype.trim=function(){
       return this.replace(/(^\s*)|(\s*$)/g,'');
   }
function startWith(str,sub)
{
	if(!str) return false;
	if(!sub) return true;
	return str.substring(0,sub.length)==sub;
}
function HiddenME(mygasket)                     //主要是用来把下拉框隐藏
{
	try{
	document.getElementById(mygasket).style.display="none";
	
	}catch(err){}
}