/**********************************************************
也玩googlebar
***********************************************************/
var xmlHttp;
function createXMLHttpReauest()
{
if (window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function doSearch()
{
createXMLHttpReauest();
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.open("GET","searchData.xml",true);
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readystate==4)
{
if(xmlHttp.status==200)
{
callBack();
//setTimeout('callBack1()',3000)
}
}
}
function callBack()
{
var results=xmlHttp.responseXML;
var textValue=document.getElementById("searchText").value;
var property;
var intNum=0;
selectData=new Array();
var properties=results.getElementsByTagName("property");
for(var i=0;i<properties.length;i++)
{
property=properties[i].firstChild.nodeValue;
if(property.indexOf(textValue)!=-1)
{
selectData[intNum]=property;
intNum++;
}
}
if(selectData.length!=0)
{
document.getElementById("showDIV").style.display = "block";
document.getElementById("showList").style.display = "block";
document.getElementById("showList").options.size = 0; //
if(selectData.length<6)
{
document.getElementById("showList").size = selectData.length; //
}
else
{
document.getElementById("showList").size =6
}
}
for (var i = 0; i < selectData.length; i++)
{
document.getElementById("showList").options[i] = new Option(selectData[i],selectData[i]); //
}
if(textValue=="")
{
document.getElementById("showList").style.display = "none";
document.getElementById("showDIV").style.display = "none";
return;
}
}
function selectValue(object)
{
var searchText=document.getElementById("searchText");
searchText.value=object.options[object.selectedIndex].text;
document.getElementById("showList").style.display = "none";
document.getElementById("showDIV").style.display = "none";
}
function foucsChange()
{
if(window.event.keyCode==40)
{
document.getElementById('showList').focus();
}
}
function upSelect(object)
{
if(window.event.keyCode==8)
{
document.getElementById('searchText').focus();
}
if(window.event.keyCode==13)
{
document.getElementById("showList").style.display = "none";
document.getElementById("showDIV").style.display = "none";
}
if(window.event.keyCode==40)
{
if(object.selectedIndex<selectData.length-1)
{
document.getElementById("searchText").value=object.options[object.selectedIndex+1].text;
}
else
{
document.getElementById("searchText").value=object.options[object.selectedIndex].text;
}
}
if(window.event.keyCode==38)
{
if(object.selectedIndex>1)
{
document.getElementById("searchText").value=object.options[object.selectedIndex-1].text;
}
else
{
document.getElementById("searchText").value=object.options[0].text;
}
}
}
function hiddenList()
{
document.getElementById("showList").style.display = "none";
document.getElementById("showDIV").style.display = "none";
}
/**********************************************************
用户名重复验证
***********************************************************/
function callBack1()
{
var results=xmlHttp.responseXML;
var textValue=document.getElementById("username").value;
if(textValue=="")
{
document.getElementById("message").style.display = "none";
return;
}
var property;
var properties=results.getElementsByTagName("property");
for(var i=0;i<properties.length;i++)
{
property=properties[i].firstChild.nodeValue;
if(property==textValue)
{
document.getElementById("message").style.display = "block";
document.getElementById("message").innerHTML="该用户名已存在";
document.getElementById("message").style.color="red";
break;
}
else
{
document.getElementById("message").style.display = "block";
document.getElementById("message").innerHTML="可以注册";
document.getElementById("message").style.color="green";
}
}
}