﻿var id;
function retrieveURL(url,sid){
	id = sid;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processStateChange;
		try {
			req.open("POST", url, true);
		}catch(e){
		  alert("Server Communication Problem "+e);
		}
		req.send(null);
	} else if(window.ActiveXObject){
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if(req){
			req.onreadystatechange=processStateChange;
			req.open("POST", url, true);
			req.send();
		}

	}
}
function processStateChange() {
	if (req.readyState == 4){ 
		if (req.status == 200){ 
			var responseStr=req.responseText;
			if(responseStr.length>0)
			{
				array=responseStr.split('|');
				document.getElementById("search_suggest").innerHTML="";
				for(var i=0;i<array.length;i++)
				{
					if(array[i]!="")
					{
						document.getElementById("search_suggest").innerHTML+="<div class='itemBg' onclick='beClick(" + i + ")'>" + array[i] + "</div>";
					}
				}
				document.getElementById("search_suggest").innerHTML+="<div class='item_button' onclick='hiddenDiv();'><font color='#999999'>关闭</font></div>";
				document.getElementById("search_suggest").style.display="inline";
			}
			else
			{
				document.getElementById("search_suggest").style.display="none";
			}
		}
	}
}
function hiddenDiv(){
	document.getElementById("search_suggest").style.display="none";
}
function beClick(i){
	document.getElementById("sstr").value=array[i];
	document.getElementById("search_suggest").style.display="none";
	document.getElementById("sstr").focus();
}
function ShowSrh(id){
	for(i=1;i<=3;i++){
		var ee1="srh" + i + "";
		var ee2="srh_0" + i + "";
		var e1=eval("document.getElementById(\"" + ee1 + "\")");
		var e2=eval("document.getElementById(\"" + ee2 + "\")");
		if(i==id*1){
			e1.style.display="";
			e2.style.backgroundColor="#FFF";
		}else{
			e1.style.display="none";
			e2.style.backgroundColor="";
		}
	}
	if(id==1){document.getElementById("sstr").focus();}else if(id==2){document.getElementById("psstr").focus();}else{document.getElementById("asstr").focus();}
}
function chk_srh(){
	if(document.getElementById("sstr").value=="" || document.getElementById("sstr").value=="姓名"){
		alert("请填写搜索内容！");
		document.getElementById("sstr").focus();
		return false;
	}
	return true;
}
function chk_paintsrh(){
	if(document.getElementById("psstr").value=="" || document.getElementById("psstr").value=="关键字"){
		alert("请填写查找关键字！");
		document.getElementById("psstr").focus();
		return false;
	}
	return true;
}
function chk_artsrh(){
	if(document.getElementById("asstr").value=="" || document.getElementById("asstr").value=="关键字"){
		alert("请填写查找关键字！");
		document.getElementById("asstr").focus();
		return false;
	}
	return true;
}
