var DivTem="<div style=\"position:absolute;z-index:1;font-weight:normal;display:none;float:left; width:363px; height:50px;\" id=\"showDorpList\"><div id=showDorpListw style=\"padding:5px 10px 5px 5px;background:url(/main/images/list_01.gif) repeat-y;\"><div id=\"showDorpListcontent\"></div></div><div><img src=/main/images/list_04.gif></div></div>"  //显示层
var ArrayList; //显示数据
//var ArrayStr="cd,成都|cs,长沙|cc,长村|sc,四川|dnpx,电脑培训|dnrz,电脑认证".split("|");  //信息数据
var IndexOf=-1 //选中文件;
var I_W,I_H,I_L,I_T  //定位参数
var _Obj
var _selected=false;
//定位div显示
  function $(s)
  {
	return document.getElementById(s);
   }
document.write(DivTem);

//定位

function ChangeInput(id)
{	
	_Obj=id
	TemStr=id.value;
	var ShowListStr="";  //初始化
	I_W=id.offsetWidth;  //输入框宽度;
	I_H=id.offsetHeight;  //输入框高度;
	I_T=id.offsetTop+I_H;  //定位
	I_L=id.offsetLeft; //定位
	
	while(id = id.offsetParent)
	{
		I_T  += id.offsetTop;
		I_L += id.offsetLeft;
	}

	$("showDorpList").style.top=I_T+"px";
	$("showDorpList").style.left=I_L+"px";
	$("showDorpList").style.width=I_W+"px";

	ArrayList=new Array;

	
	var okjs=0
	for (i=0;i<ArrayStr.length;i++ )
	{
		var Ename=ArrayStr[i].split(",");

		//输入中英文对比
		
		if ((Ename[0].substr(0,TemStr.length).toUpperCase() ==TemStr.toUpperCase()  || Ename[1].substr(0,TemStr.length)==TemStr) && TemStr!="")
		{
			if (12>okjs)
			{
			
			ShowListStr=ShowListStr+"<div id='dorplist_"+okjs+"' style=\"cursor:hand;height:18px;padding-top:6px; display:block;\" width=\"348px\" onclick=clickSure(\""+okjs+"\") onmouseover=dorpMovei('"+okjs+"') onmouseout=dorpMoveo('"+okjs+"')>"+Ename[1]+"</div>"
			
			//ShowListStr=ShowListStr+"<li id='dorplist_"+okjs+"' style=\"cursor:hand; height:18px; padding-top:6px;  display:block; \" width=\"340px\" onclick=clickSure(\""+okjs+"\") onmouseover=dorpMovei('"+okjs+"') onmouseout=dorpMoveo('"+okjs+"')>"+Ename[1]+"</li>"
			
			
			ArrayList[okjs]=Ename[1];//
			okjs+=1;
			}

		}
	}

	if (ShowListStr!="")
	{
	$("showDorpListcontent").innerHTML=ShowListStr;
	$("showDorpList").style.display="";
	}else
	{
	$("showDorpList").style.display="none";
	}

}


function dorpMovei(i)
{
IndexOf=i
//alert(i)
var id="dorplist_"+i;
try
{
document.all(id).style.width="100%";
document.all(id).style.backgroundColor="#F3F8DE";
document.all(s-list).style.color="#0B4958"
}
catch (e)
{
}

}

function dorpMoveo(i)
{
IndexOf=i
var id="dorplist_"+i;
try
{
	document.all(id).style.width="100%";
document.all(id).style.backgroundColor="";
document.all(id).style.color="";
}
catch (e)
{
}

}


function upDownKey(Code,id)
{
	if (Code==38)
	{
		IndexOf-=1
	
	if (ArrayList.length==0)
		{
		dorpMovei(0);
		}else
		{
		if (IndexOf>=0)
		{
		dorpMovei(IndexOf);
		}else
		{
		IndexOf=ArrayList.length;
		}}
	}

	if (Code==40)
	{
		
	
		if (ArrayList.length==0)
		{
		dorpMovei(0);
		}else
		{
		IndexOf+=1
		if (IndexOf<ArrayList.length)
		{
		dorpMovei(IndexOf);
		}else
		{
		IndexOf=-1;
		}
		}
		

//ArrayList.length=0;	
		
	}
//alert(IndexOf)
	if (Code==13)
	
{
if ($("showDorpList").style.display=="none")	
	{document.all("lyform").submit();

		}
		else		
{if (_selected)	{document.all("lyform").submit();
		}
             else
		{
		if (IndexOf>=0)
		{
clickSure(IndexOf)
		}
		}	
	} 
	}

	//
}

function clickSure(i)
{
_Obj.value=ArrayList[IndexOf];
IndexOf=-1;
_selected=true;
$("showDorpList").style.display="none";
return false;
}

function ClickSubmit()
{
  return false;
}
