var xmlHttp1;
var temp1;
//Ajax是建立在XMLHttp组件下的技术，本例详细语法参考压缩包内xmlhttp手册

//建立XMLHTTP对象调用MS的ActiveXObject方法，如果成功（IE浏览器）则使用MS ActiveX实例化创建一个XMLHTTP对象 非IE则转用建立一个本地Javascript对象的XMLHttp对象 （此方法确保不同浏览器下对AJAX的支持）
function createXMLHttp1(){
    if(window.ActiveXObject){
        xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest){
        xmlHttp1 = new XMLHttpRequest();
    }
}

//建立主过程
function startxmlHttp1(){
    createXMLHttp1(); //建立xmlHttp 对象
    xmlHttp1.onreadystatechange =dodo1; //xmlHttp下的onreadystatechange方法 控制传送过程
    xmlHttp1.open("get","/responseXML/getkw.asp?kw="+document.getElementById("code1").value.toLowerCase(),false); //传送方式 读取的页面 异步与否
    xmlHttp1.send(); //发送
}

function dodo1(){
    if(xmlHttp1.readystate==4){ // xmlHttp下的readystate方法 4表示传送完毕
        if(xmlHttp1.status==200){ // xmlHttp的status方法读取状态（服务器HTTP状态码） 200对应OK 404对应Not Found（未找到）等
             temp1=xmlHttp1.responseText; //xmlHttp的responseText方法 得到读取页数据
           }
}
}

function checkcode1()
{
   var code1value=document.getElementById("code1").value.toLowerCase();
   if(code1value.replace( /\s*$/, "")=="")
   {
	  return false;
	}
   startxmlHttp1();
   var alltxt=temp1;
   var alltxtpp=alltxt.toLowerCase();
   //var alltxt_xiang=alltxt.split("|");
   var alltxt_xiang1=alltxtpp.split("|");
   var inhtml="<ul style=\"margin: 0; padding: 0;width:100%;text-align:left\">"
   var isyou=0;
   for (i=0;i<alltxt_xiang1.length;i++)
   {
       if (alltxt_xiang1[i].substr(0,code1value.length)==code1value)
       {
	   
	    var alltxt_xiangtemp=alltxt_xiang1[i].split(",");
		inhtml=inhtml+"<li onclick=\"document.getElementById('code1').value=this.innerHTML;document.getElementById('showmenu1').style.display='none';\" onmouseover=\"this.style.backgroundColor='#efefef'\" onmouseout=\"this.style.backgroundColor=''\"  style=\"margin: 0; padding: 0;width:100%;text-align:left\">"+alltxt_xiangtemp[1].replace( /\s*$/, "")+"</li>";
		
		isyou=1;
       }
   }
   inhtml=inhtml+"</ul>";
   if (isyou==1)
   {
       document.getElementById("showmenu1").innerHTML=inhtml;
       document.getElementById("showmenu1").style.display="";
   }
   else
   {
       document.getElementById("showmenu1").innerHTML="";
       document.getElementById("showmenu1").style.display="none";
   }
   if (code1value=="")
   {
       document.getElementById("showmenu1").innerHTML="";
       document.getElementById("showmenu1").style.display="none";
   }
}

function suggestOver1(div_value)
{
	document.getElementById("showmenu1").className='suggest_link_over';
}
function sugggestOut(div_value)
{
	document.getElementById("showmenu1").className='suggest_link';
}

var gFloatDivID = "showmenu1";   // 浮动窗体ID
var onClickPage1Self=null;// 响应点击Page的自定义操作
document.onclick = onClickPage1;

function onClickPage1() {
	// 关闭浮动的窗口
	closeFloatDiv1();
	if(onClickPage1Self != null) {
		onClickPage1Self();
	}
	hide1('showmenu1');
}
function hide1(oid) {
	if (document.getElementById(oid)!=null) {
		document.getElementById(oid).style.display = 'none';
	}
}
function closeFloatDiv1() {
	var f = document.getElementById(gFloatDivID);
	if(f) {
		f.style.display = "none";
	}
}

